diff --git a/web/core/local-db/storage.sqlite.ts b/web/core/local-db/storage.sqlite.ts index 099063aca1..e8735e87ff 100644 --- a/web/core/local-db/storage.sqlite.ts +++ b/web/core/local-db/storage.sqlite.ts @@ -148,7 +148,7 @@ export class Storage { }; syncWorkspace = async () => { - if (document.hidden || !rootStore.user.localDBEnabled) return; // return if the window gets hidden + if (document.hidden || !rootStore.user.localDBEnabled || !this.db) return; // return if the window gets hidden await Sentry.startSpan({ name: "LOAD_WS", attributes: { slug: this.workspaceSlug } }, async () => { await loadWorkSpaceData(this.workspaceSlug); }); @@ -173,7 +173,7 @@ export class Storage { }; syncIssues = async (projectId: string) => { - if (document.hidden || !rootStore.user.localDBEnabled) return false; // return if the window gets hidden + if (document.hidden || !rootStore.user.localDBEnabled || !this.db) return false; // return if the window gets hidden try { const sync = Sentry.startSpan({ name: `SYNC_ISSUES` }, () => this._syncIssues(projectId)); @@ -191,7 +191,7 @@ export class Storage { log("### Sync started"); let status = this.getStatus(projectId); if (status === "loading" || status === "syncing") { - logInfo(`Project ${projectId} is already loading or syncing`); + log(`Project ${projectId} is already loading or syncing`); return; } const syncPromise = this.getSync(projectId); @@ -290,7 +290,7 @@ export class Storage { !rootStore.user.localDBEnabled ) { if (rootStore.user.localDBEnabled) { - logInfo(`Project ${projectId} is loading, falling back to server`); + log(`Project ${projectId} is loading, falling back to server`); } const issueService = new IssueService(); return await issueService.getIssuesFromServer(workspaceSlug, projectId, queries); diff --git a/web/core/local-db/utils/load-issues.ts b/web/core/local-db/utils/load-issues.ts index 1524edea7d..1487cece71 100644 --- a/web/core/local-db/utils/load-issues.ts +++ b/web/core/local-db/utils/load-issues.ts @@ -8,7 +8,7 @@ import { issueSchema } from "./schemas"; export const PROJECT_OFFLINE_STATUS: Record = {}; export const addIssue = async (issue: any) => { - if (document.hidden || !rootStore.user.localDBEnabled) return; + if (document.hidden || !rootStore.user.localDBEnabled || !persistence.db) return; persistence.db.exec("BEGIN TRANSACTION;"); stageIssueInserts(issue); @@ -16,7 +16,7 @@ export const addIssue = async (issue: any) => { }; export const addIssuesBulk = async (issues: any, batchSize = 100) => { - if (!rootStore.user.localDBEnabled) return; + if (!rootStore.user.localDBEnabled || !persistence.db) return; for (let i = 0; i < issues.length; i += batchSize) { const batch = issues.slice(i, i + batchSize); @@ -32,7 +32,7 @@ export const addIssuesBulk = async (issues: any, batchSize = 100) => { } }; export const deleteIssueFromLocal = async (issue_id: any) => { - if (!rootStore.user.localDBEnabled) return; + if (!rootStore.user.localDBEnabled || !persistence.db) return; const deleteQuery = `delete from issues where id='${issue_id}'`; const deleteMetaQuery = `delete from issue_meta where issue_id='${issue_id}'`; @@ -44,7 +44,7 @@ export const deleteIssueFromLocal = async (issue_id: any) => { }; // @todo: Update deletes the issue description from local. Implement a separate update. export const updateIssue = async (issue: TIssue & { is_local_update: number }) => { - if (document.hidden || !rootStore.user.localDBEnabled) return; + if (document.hidden || !rootStore.user.localDBEnabled || !persistence.db) return; const issue_id = issue.id; // delete the issue and its meta data @@ -53,7 +53,7 @@ export const updateIssue = async (issue: TIssue & { is_local_update: number }) = }; export const syncDeletesToLocal = async (workspaceId: string, projectId: string, queries: any) => { - if (!rootStore.user.localDBEnabled) return; + if (!rootStore.user.localDBEnabled || !persistence.db) return; const issueService = new IssueService(); const response = await issueService.getDeletedIssues(workspaceId, projectId, queries); diff --git a/web/core/local-db/utils/query-executor.ts b/web/core/local-db/utils/query-executor.ts index 9002d5a7bf..357fbbbc40 100644 --- a/web/core/local-db/utils/query-executor.ts +++ b/web/core/local-db/utils/query-executor.ts @@ -1,9 +1,7 @@ -// import { SQL } from "./sqlite"; - import { persistence } from "../storage.sqlite"; export const runQuery = async (sql: string) => { - const data = await persistence.db.exec({ + const data = await persistence.db?.exec({ sql, rowMode: "object", returnValue: "resultRows", diff --git a/web/core/local-db/utils/query.utils.ts b/web/core/local-db/utils/query.utils.ts index fbc42fec99..520338e6af 100644 --- a/web/core/local-db/utils/query.utils.ts +++ b/web/core/local-db/utils/query.utils.ts @@ -4,8 +4,20 @@ import { issueSchema } from "./schemas"; import { wrapDateTime } from "./utils"; export const translateQueryParams = (queries: any) => { - const { group_by, sub_group_by, labels, assignees, state, cycle, module, priority, type, issue_type, ...otherProps } = - queries; + const { + group_by, + layout, + sub_group_by, + labels, + assignees, + state, + cycle, + module, + priority, + type, + issue_type, + ...otherProps + } = queries; const order_by = queries.order_by; if (state) otherProps.state_id = state; @@ -33,7 +45,7 @@ export const translateQueryParams = (queries: any) => { } // Fix invalid orderby when switching from spreadsheet layout - if ((group_by || sub_group_by) && Object.keys(SPECIAL_ORDER_BY).includes(order_by)) { + if (layout === "spreadsheet" && Object.keys(SPECIAL_ORDER_BY).includes(order_by)) { otherProps.order_by = "sort_order"; } // For each property value, replace None with empty string diff --git a/web/core/local-db/utils/utils.ts b/web/core/local-db/utils/utils.ts index 39c49d745c..cbe373fb2e 100644 --- a/web/core/local-db/utils/utils.ts +++ b/web/core/local-db/utils/utils.ts @@ -15,7 +15,7 @@ export const logError = (e: any) => { e = parseSQLite3Error(e); } Sentry.captureException(e); - console.log(e); + console.error(e); }; export const logInfo = console.info; diff --git a/web/next.config.js b/web/next.config.js index 1d191da3d8..fba54a17da 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -20,8 +20,6 @@ const nextConfig = { key: "Referrer-Policy", value: "origin-when-cross-origin", }, - { key: "Cross-Origin-Opener-Policy", value: "same-origin" }, - { key: "Cross-Origin-Embedder-Policy", value: "credentialless" }, ], }, ];