diff --git a/apps/readest-app/src/app/library/components/ReadingProgress.tsx b/apps/readest-app/src/app/library/components/ReadingProgress.tsx index ad4dc70c..fa53c53b 100644 --- a/apps/readest-app/src/app/library/components/ReadingProgress.tsx +++ b/apps/readest-app/src/app/library/components/ReadingProgress.tsx @@ -21,7 +21,7 @@ const ReadingProgress: React.FC = memo( ({ book }) => { const progressPercentage = useMemo(() => getProgressPercentage(book), [book]); - if (progressPercentage === null) { + if (progressPercentage === null || Number.isNaN(progressPercentage)) { return null; } diff --git a/apps/readest-app/src/app/reader/hooks/useProgressAutoSave.ts b/apps/readest-app/src/app/reader/hooks/useProgressAutoSave.ts index d401236c..edb6f381 100644 --- a/apps/readest-app/src/app/reader/hooks/useProgressAutoSave.ts +++ b/apps/readest-app/src/app/reader/hooks/useProgressAutoSave.ts @@ -13,10 +13,12 @@ export const useProgressAutoSave = (bookKey: string) => { // eslint-disable-next-line react-hooks/exhaustive-deps const saveBookConfig = useCallback( - throttle(async () => { - const config = getConfig(bookKey)!; - const settings = useSettingsStore.getState().settings; - await saveConfig(envConfig, bookKey, config, settings); + throttle(() => { + setTimeout(async () => { + const config = getConfig(bookKey)!; + const settings = useSettingsStore.getState().settings; + await saveConfig(envConfig, bookKey, config, settings); + }, 5000); }, 10000), [], ); diff --git a/apps/readest-app/src/hooks/useSync.ts b/apps/readest-app/src/hooks/useSync.ts index 7d822cfa..d9156ea6 100644 --- a/apps/readest-app/src/hooks/useSync.ts +++ b/apps/readest-app/src/hooks/useSync.ts @@ -117,18 +117,16 @@ export function useSync(bookKey?: string) { if (!bookId) { settings.lastSyncedAtConfigs = maxTime; setSettings(settings); - } else if (bookKey && config) { - config.lastSyncedAtConfig = maxTime; - setConfig(bookKey, config); + } else if (bookKey) { + setConfig(bookKey, { lastSyncedAtConfig: maxTime }); } break; case 'notes': if (!bookId) { settings.lastSyncedAtNotes = maxTime; setSettings(settings); - } else if (bookKey && config) { - config.lastSyncedAtNotes = maxTime; - setConfig(bookKey, config); + } else if (bookKey) { + setConfig(bookKey, { lastSyncedAtNotes: maxTime }); } break; }