Refactor character, chapter, and story components to support offline mode
- Add `OfflineContext` and `BookContext` to components for offline state management. - Introduce conditional logic to toggle between server API requests and offline IPC handlers for CRUD operations. - Refine `TextEditor`, `DraftCompanion`, and other components to disable actions or features unavailable in offline mode. - Improve error handling and user feedback in both online and offline scenarios.
This commit is contained in:
10
app/page.tsx
10
app/page.tsx
@@ -475,7 +475,15 @@ function ScribeContent() {
|
||||
}
|
||||
response = await window.electron.invoke('db:chapter:last', currentBook?.bookId)
|
||||
} else {
|
||||
response = await System.authGetQueryToServer<ChapterProps | null>(`chapter/last-chapter`, session.accessToken, locale, {bookid: currentBook?.bookId});
|
||||
if (currentBook?.localBook) {
|
||||
if (!offlineMode.isDatabaseInitialized) {
|
||||
setCurrentChapter(undefined);
|
||||
return;
|
||||
}
|
||||
response = await window.electron.invoke('db:chapter:last', currentBook?.bookId)
|
||||
} else {
|
||||
response = await System.authGetQueryToServer<ChapterProps | null>(`chapter/last-chapter`, session.accessToken, locale, {bookid: currentBook?.bookId});
|
||||
}
|
||||
}
|
||||
if (response) {
|
||||
setCurrentChapter(response)
|
||||
|
||||
Reference in New Issue
Block a user