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:
natreex
2025-11-26 22:03:22 -05:00
parent 9648d9e9be
commit e1abcd9490
3 changed files with 48 additions and 22 deletions

View File

@@ -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);
}
)