Add error handling, enhance syncing, and refactor deletion logic

- Introduce new error messages for syncing and book deletion in `en.json`.
- Update `DeleteBook` to support local-only deletion and synced book management.
- Refine offline/online behavior with `deleteLocalToo` checkbox and update related state handling.
- Extend repository and IPC methods to handle optional IDs for updates.
- Add `SyncQueueContext` for queueing offline changes and improving synchronization workflows.
- Enhance refined text generation logic in `DraftCompanion` and `GhostWriter` components.
- Replace PUT with PATCH for world updates to align with API expectations.
- Streamline `AlertBox` by integrating dynamic translation keys for deletion prompts.
This commit is contained in:
natreex
2026-01-10 15:50:03 -05:00
parent 060693f152
commit 7f34421212
26 changed files with 506 additions and 100 deletions

View File

@@ -53,28 +53,33 @@ interface CreateBookData {
interface AddIncidentData {
bookId: string;
name: string;
incidentId?: string;
}
interface AddPlotPointData {
bookId: string;
name: string;
incidentId: string;
plotPointId?: string;
}
interface AddIssueData {
bookId: string;
name: string;
issueId?: string;
}
interface AddWorldData {
bookId: string;
worldName: string;
id?: string;
}
interface AddWorldElementData {
worldId: string;
elementName: string;
elementType: number;
id?: string;
}
interface SetAIGuideLineData {
@@ -235,7 +240,7 @@ ipcMain.handle(
'db:book:incident:add',
createHandler<AddIncidentData, string>(
function(userId: string, data: AddIncidentData, lang: 'fr' | 'en') {
return Book.addNewIncident(userId, data.bookId, data.name, lang);
return Book.addNewIncident(userId, data.bookId, data.name, lang, data.incidentId);
}
)
);
@@ -261,7 +266,8 @@ ipcMain.handle('db:book:plot:add', createHandler<AddPlotPointData, string>(
data.bookId,
data.incidentId,
data.name,
lang
lang,
data.plotPointId
);
}
)
@@ -283,7 +289,7 @@ ipcMain.handle(
// POST /book/issue/add - Add issue
ipcMain.handle('db:book:issue:add', createHandler<AddIssueData, string>(
function(userId: string, data: AddIssueData, lang: 'fr' | 'en') {
return Book.addNewIssue(userId, data.bookId, data.name, lang);
return Book.addNewIssue(userId, data.bookId, data.name, lang, data.issueId);
}
)
);
@@ -314,7 +320,7 @@ ipcMain.handle('db:book:worlds:get', createHandler<GetWorldsData, WorldProps[]>(
// POST /book/world/add - Add world
ipcMain.handle('db:book:world:add', createHandler<AddWorldData, string>(
function(userId: string, data: AddWorldData, lang: 'fr' | 'en') {
return Book.addNewWorld(userId, data.bookId, data.worldName, lang);
return Book.addNewWorld(userId, data.bookId, data.worldName, lang, data.id);
}
)
);
@@ -327,7 +333,8 @@ ipcMain.handle('db:book:world:element:add', createHandler<AddWorldElementData, s
data.worldId,
data.elementName,
data.elementType.toString(),
lang
lang,
data.id
);
}
)