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:
@@ -198,13 +198,13 @@ export default function DraftCompanion() {
|
||||
infoMessage(t("draftCompanion.abortSuccess"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function handleQuillSenseRefined(): Promise<void> {
|
||||
if (chapter && session?.accessToken) {
|
||||
setIsRefining(true);
|
||||
setShowRefinedText(false);
|
||||
setRefinedText('');
|
||||
|
||||
|
||||
try {
|
||||
const response: Response = await fetch(`${configs.apiUrl}quillsense/refine`, {
|
||||
method: 'POST',
|
||||
@@ -260,21 +260,21 @@ export default function DraftCompanion() {
|
||||
const dataStr: string = line.slice(6);
|
||||
const data: {
|
||||
content?: string;
|
||||
totalCost?: number;
|
||||
totalPrice?: number;
|
||||
useYourKey?: boolean;
|
||||
aborted?: boolean;
|
||||
} = JSON.parse(dataStr);
|
||||
|
||||
if ('totalCost' in data && 'useYourKey' in data && 'totalPrice' in data) {
|
||||
if ('content' in data && data.content) {
|
||||
accumulatedText += data.content;
|
||||
setRefinedText(accumulatedText);
|
||||
}
|
||||
|
||||
else if ('useYourKey' in data && 'totalPrice' in data) {
|
||||
if (data.useYourKey) {
|
||||
setTotalPrice((prev: number): number => prev + data.totalPrice!);
|
||||
} else {
|
||||
setTotalCredits(data.totalPrice!);
|
||||
}
|
||||
} else if ('content' in data && data.content && data.content !== 'starting') {
|
||||
accumulatedText += data.content;
|
||||
setRefinedText(accumulatedText);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
console.error('Error parsing SSE data:', e);
|
||||
|
||||
Reference in New Issue
Block a user