Refactor imports, streamline database IPC handlers, and improve offline support
- Replace absolute import paths with relative paths for consistency across files. - Transition database operations in Electron main process to modular handlers in `ipc/book.ipc.ts` using the `createHandler` pattern. - Update database sync service to use `window.electron.invoke()` for improved reliability and structure. - Refactor `AddNewBookForm` to handle both online and offline book creation seamlessly.
This commit is contained in:
@@ -21,11 +21,8 @@ export async function getSyncStatus(): Promise<SyncProgress> {
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await window.electron.dbGetSyncStatus();
|
||||
if (!result.success) {
|
||||
throw new Error(result.error);
|
||||
}
|
||||
return result.data;
|
||||
const result = await window.electron.invoke<SyncProgress>('db:sync:status');
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Failed to get sync status:', error);
|
||||
return {
|
||||
@@ -46,11 +43,8 @@ export async function getPendingChanges(limit: number = 100) {
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await window.electron.dbGetPendingChanges(limit);
|
||||
if (!result.success) {
|
||||
throw new Error(result.error);
|
||||
}
|
||||
return result.data || [];
|
||||
const result = await window.electron.invoke<any[]>('db:sync:pending-changes', limit);
|
||||
return result || [];
|
||||
} catch (error) {
|
||||
console.error('Failed to get pending changes:', error);
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user