Update database schema and synchronization logic
- Add `useEffect` in `ScribeLeftBar` for handling book state changes. - Extend `BooksSyncContext` with new properties and stricter typings. - Refine `Repositories` to include `lastUpdate` handling for synchronization processes. - Add comprehensive `fetchComplete*` repository methods for retrieving entity-specific sync data. - Enhance offline logic for chapters, characters, locations, and world synchronization. - Improve error handling across IPC handlers and repositories.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { createHandler } from '../database/LocalSystem.js';
|
||||
import Book, {CompleteBook, SyncedBook} from '../database/models/Book.js';
|
||||
import Book, {BookSyncCompare, CompleteBook, SyncedBook} from '../database/models/Book.js';
|
||||
import type { BookProps, GuideLine, GuideLineAI, Act, Issue, WorldProps } from '../database/models/Book.js';
|
||||
import Chapter from '../database/models/Chapter.js';
|
||||
import type { ChapterProps } from '../database/models/Chapter.js';
|
||||
@@ -130,6 +130,22 @@ ipcMain.handle('db:book:updateBasicInformation', createHandler<UpdateBookBasicDa
|
||||
)
|
||||
);
|
||||
|
||||
// GET /book/sync/to-client - Get book data to sync to client
|
||||
ipcMain.handle('db:book:sync:toServer', createHandler<BookSyncCompare, CompleteBook>(
|
||||
async function(userId: string, data:BookSyncCompare, lang: 'fr' | 'en'):Promise<CompleteBook> {
|
||||
return await Book.getCompleteSyncBook(userId, data, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// GET /book/sync/from-server - Get book data to sync from server
|
||||
ipcMain.handle('db:book:sync:toClient', createHandler<CompleteBook, boolean>(
|
||||
async function(userId: string, data:CompleteBook, lang: 'fr' | 'en'):Promise<boolean> {
|
||||
return await Book.syncBookFromServerToClient(userId, data, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// GET /book/guide-line - Get guideline
|
||||
ipcMain.handle('db:book:guideline:get',
|
||||
createHandler<GetGuidelineData, GuideLine | null>(async function(userId: string, data: GetGuidelineData, lang: 'fr' | 'en') {
|
||||
|
||||
Reference in New Issue
Block a user