[WEB-2706] fix: Add fallback when db initialisation fails (#5973)
* Add fallback when db initialization fails * add checks for instance.exec * chore: convert issue boolean fields to actual boolean value. * change instance exec code * sync issue to local db when inbox issue is accepted and draft issue is moved to project * chore: added project and workspace keys --------- Co-authored-by: rahulramesha <rahulramesham@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
2193e8c79c
commit
acba451803
8 changed files with 78 additions and 39 deletions
|
|
@ -9,7 +9,7 @@ import { rootStore } from "@/lib/store-context";
|
|||
// services
|
||||
import { IssueService } from "@/services/issue/issue.service";
|
||||
//
|
||||
import { ARRAY_FIELDS } from "./utils/constants";
|
||||
import { ARRAY_FIELDS, BOOLEAN_FIELDS } from "./utils/constants";
|
||||
import { getSubIssuesWithDistribution } from "./utils/data.utils";
|
||||
import createIndexes from "./utils/indexes";
|
||||
import { addIssuesBulk, syncDeletesToLocal } from "./utils/load-issues";
|
||||
|
|
@ -75,6 +75,7 @@ export class Storage {
|
|||
if (workspaceSlug !== this.workspaceSlug) {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
try {
|
||||
await startSpan({ name: "INIT_DB" }, async () => await this._initialize(workspaceSlug));
|
||||
return true;
|
||||
|
|
@ -125,6 +126,7 @@ export class Storage {
|
|||
return true;
|
||||
} catch (error) {
|
||||
this.status = "error";
|
||||
this.db = null;
|
||||
throw new Error(`Failed to initialize database worker: ${error}`);
|
||||
}
|
||||
};
|
||||
|
|
@ -467,5 +469,9 @@ export const formatLocalIssue = (issue: any) => {
|
|||
ARRAY_FIELDS.forEach((field: string) => {
|
||||
currIssue[field] = currIssue[field] ? JSON.parse(currIssue[field]) : [];
|
||||
});
|
||||
// Convert boolean fields to actual boolean values
|
||||
BOOLEAN_FIELDS.forEach((field: string) => {
|
||||
currIssue[field] = currIssue[field] === 1;
|
||||
});
|
||||
return currIssue as TIssue & { group_id?: string; total_issues: number; sub_group_id?: string };
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue