From f8e21dbd4c5007e04ad8220f52ec5f899edcf8f6 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Thu, 20 Nov 2025 08:58:41 +0530 Subject: [PATCH] fix(sync): fixed sync issues affecting new accounts, closes #2481 (#2483) --- apps/readest-app/src/hooks/useSync.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/readest-app/src/hooks/useSync.ts b/apps/readest-app/src/hooks/useSync.ts index 0762b9bc..e3d1aa03 100644 --- a/apps/readest-app/src/hooks/useSync.ts +++ b/apps/readest-app/src/hooks/useSync.ts @@ -108,8 +108,9 @@ export function useSync(bookKey?: string) { const result = await syncClient.pullChanges(since, type, bookId, metaHash); setSyncResult({ ...syncResult, [type]: result[type] }); const records = result[type]; - if (!records?.length) return; - const maxTime = computeMaxTimestamp(records); + if (since > 0 && !records?.length) return; + // For since = 0, we set lastSyncedAt to now if no records returned + const maxTime = records?.length ? computeMaxTimestamp(records) : Date.now(); setLastSyncedAt(maxTime); // due to closures in React hooks the settings might be stale