mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 09:21:24 +08:00
fix(electron): type on handlers (#3747)
This commit is contained in:
@@ -44,10 +44,10 @@ export abstract class BaseSQLiteAdapter {
|
|||||||
try {
|
try {
|
||||||
if (!this.db) {
|
if (!this.db) {
|
||||||
logger.warn(`${this.path} is not connected`);
|
logger.warn(`${this.path} is not connected`);
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
const blob = await this.db.getBlob(key);
|
const blob = await this.db.getBlob(key);
|
||||||
return blob?.data;
|
return blob?.data ?? null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('getBlob', error);
|
logger.error('getBlob', error);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export class WorkspaceSQLiteDB extends BaseSQLiteAdapter {
|
|||||||
if (doc) {
|
if (doc) {
|
||||||
return encodeStateAsUpdate(doc);
|
return encodeStateAsUpdate(doc);
|
||||||
}
|
}
|
||||||
return null;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// non-blocking and use yDoc to validate the update
|
// non-blocking and use yDoc to validate the update
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
|
import type {
|
||||||
|
DBHandlers,
|
||||||
|
DialogHandlers,
|
||||||
|
WorkspaceHandlers,
|
||||||
|
} from '@toeverything/infra/type';
|
||||||
|
|
||||||
import { dbEvents, dbHandlers } from './db';
|
import { dbEvents, dbHandlers } from './db';
|
||||||
import { dialogHandlers } from './dialog';
|
import { dialogHandlers } from './dialog';
|
||||||
import { workspaceEvents, workspaceHandlers } from './workspace';
|
import { workspaceEvents, workspaceHandlers } from './workspace';
|
||||||
|
|
||||||
|
type AllHandlers = {
|
||||||
|
db: DBHandlers;
|
||||||
|
workspace: WorkspaceHandlers;
|
||||||
|
dialog: DialogHandlers;
|
||||||
|
};
|
||||||
|
|
||||||
export const handlers = {
|
export const handlers = {
|
||||||
db: dbHandlers,
|
db: dbHandlers,
|
||||||
workspace: workspaceHandlers,
|
workspace: workspaceHandlers,
|
||||||
dialog: dialogHandlers,
|
dialog: dialogHandlers,
|
||||||
};
|
} satisfies AllHandlers;
|
||||||
|
|
||||||
export const events = {
|
export const events = {
|
||||||
db: dbEvents,
|
db: dbEvents,
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export type DBHandlers = {
|
|||||||
getDocAsUpdates: (
|
getDocAsUpdates: (
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
subdocId?: string
|
subdocId?: string
|
||||||
) => Promise<Uint8Array>;
|
) => Promise<Uint8Array | false>;
|
||||||
applyDocUpdate: (
|
applyDocUpdate: (
|
||||||
id: string,
|
id: string,
|
||||||
update: Uint8Array,
|
update: Uint8Array,
|
||||||
@@ -164,7 +164,7 @@ export type DialogHandlers = {
|
|||||||
dbFileLocation?: string
|
dbFileLocation?: string
|
||||||
) => Promise<MoveDBFileResult>;
|
) => Promise<MoveDBFileResult>;
|
||||||
selectDBFileLocation: () => Promise<SelectDBFileLocationResult>;
|
selectDBFileLocation: () => Promise<SelectDBFileLocationResult>;
|
||||||
setFakeDialogResult: (result: any) => Promise<FakeDialogResult>;
|
setFakeDialogResult: (result: any) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UIHandlers = {
|
export type UIHandlers = {
|
||||||
|
|||||||
Reference in New Issue
Block a user