Add offline mode logic for chapter operations and refactor IPC handlers
- Integrate `OfflineContext` into `TextEditor` and `ScribeChapterComponent` to handle offline scenarios for chapter CRUD operations. - Add conditional logic to switch between server API requests and offline IPC handlers (`db:chapter:add`, `db:chapter:remove`, `db:chapter:content:save`, `db:chapter:update`). - Refactor and rename IPC handlers (`db:chapter:create` to `db:chapter:add`, `db:chapter:delete` to `db:chapter:remove`) for consistency. - Update UI to disable certain actions when offline (e.g., GhostWriter button).
This commit is contained in:
@@ -107,7 +107,7 @@ ipcMain.handle('db:chapter:last', createHandler<string, ChapterProps | null>(
|
||||
);
|
||||
|
||||
// POST /chapter/add - Add new chapter
|
||||
ipcMain.handle('db:chapter:create', createHandler<AddChapterData, string>(
|
||||
ipcMain.handle('db:chapter:add', createHandler<AddChapterData, string>(
|
||||
function(userId: string, data: AddChapterData, lang: 'fr' | 'en'): string {
|
||||
return Chapter.addChapter(userId, data.bookId, data.title, 0, data.chapterOrder, lang);
|
||||
}
|
||||
@@ -115,8 +115,9 @@ ipcMain.handle('db:chapter:create', createHandler<AddChapterData, string>(
|
||||
);
|
||||
|
||||
// DELETE /chapter/remove - Remove chapter
|
||||
ipcMain.handle('db:chapter:delete', createHandler<string, boolean>(
|
||||
ipcMain.handle('db:chapter:remove', createHandler<string, boolean>(
|
||||
function(userId: string, chapterId: string, lang: 'fr' | 'en'): boolean {
|
||||
console.log(userId,chapterId,lang)
|
||||
return Chapter.removeChapter(userId, chapterId, lang);
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user