diff --git a/apps/electron/src/helper/db/base-db-adapter.ts b/apps/electron/src/helper/db/base-db-adapter.ts index afb68adc25..7d90c8a0bb 100644 --- a/apps/electron/src/helper/db/base-db-adapter.ts +++ b/apps/electron/src/helper/db/base-db-adapter.ts @@ -44,10 +44,10 @@ export abstract class BaseSQLiteAdapter { try { if (!this.db) { logger.warn(`${this.path} is not connected`); - return; + return null; } const blob = await this.db.getBlob(key); - return blob?.data; + return blob?.data ?? null; } catch (error) { logger.error('getBlob', error); return null; diff --git a/apps/electron/src/helper/db/workspace-db-adapter.ts b/apps/electron/src/helper/db/workspace-db-adapter.ts index 8eda459c4d..7ec8edc4af 100644 --- a/apps/electron/src/helper/db/workspace-db-adapter.ts +++ b/apps/electron/src/helper/db/workspace-db-adapter.ts @@ -128,7 +128,7 @@ export class WorkspaceSQLiteDB extends BaseSQLiteAdapter { if (doc) { return encodeStateAsUpdate(doc); } - return null; + return false; }; // non-blocking and use yDoc to validate the update diff --git a/apps/electron/src/helper/exposed.ts b/apps/electron/src/helper/exposed.ts index 19bd140e76..a6f6da3ec7 100644 --- a/apps/electron/src/helper/exposed.ts +++ b/apps/electron/src/helper/exposed.ts @@ -1,12 +1,24 @@ +import type { + DBHandlers, + DialogHandlers, + WorkspaceHandlers, +} from '@toeverything/infra/type'; + import { dbEvents, dbHandlers } from './db'; import { dialogHandlers } from './dialog'; import { workspaceEvents, workspaceHandlers } from './workspace'; +type AllHandlers = { + db: DBHandlers; + workspace: WorkspaceHandlers; + dialog: DialogHandlers; +}; + export const handlers = { db: dbHandlers, workspace: workspaceHandlers, dialog: dialogHandlers, -}; +} satisfies AllHandlers; export const events = { db: dbEvents, diff --git a/packages/infra/src/type.ts b/packages/infra/src/type.ts index ad845cc3e0..cee56f6247 100644 --- a/packages/infra/src/type.ts +++ b/packages/infra/src/type.ts @@ -94,7 +94,7 @@ export type DBHandlers = { getDocAsUpdates: ( workspaceId: string, subdocId?: string - ) => Promise; + ) => Promise; applyDocUpdate: ( id: string, update: Uint8Array, @@ -164,7 +164,7 @@ export type DialogHandlers = { dbFileLocation?: string ) => Promise; selectDBFileLocation: () => Promise; - setFakeDialogResult: (result: any) => Promise; + setFakeDialogResult: (result: any) => Promise; }; export type UIHandlers = {