From c10b6435d46319af79c3b1f74e22b881f3343d50 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 27 Nov 2025 21:52:05 +0000 Subject: [PATCH] Don't download all documents when initial sync gets interrupted --- frontend/sync-client/src/persistence/database.ts | 4 ++++ frontend/sync-client/src/utils/data-structures/min-covered.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/sync-client/src/persistence/database.ts b/frontend/sync-client/src/persistence/database.ts index 2babdadf..dd519659 100644 --- a/frontend/sync-client/src/persistence/database.ts +++ b/frontend/sync-client/src/persistence/database.ts @@ -75,6 +75,10 @@ export class Database { Math.max(0, lastSeenUpdateId ?? 0) // the first updateId will be 1 which is the first integer after -1 ); + this.documents.forEach((doc) => + this.lastSeenUpdateIds.add(doc.metadata?.parentVersionId) + ); + this.hasInitialSyncCompleted = initialState.hasInitialSyncCompleted ?? false; this.logger.debug( diff --git a/frontend/sync-client/src/utils/data-structures/min-covered.ts b/frontend/sync-client/src/utils/data-structures/min-covered.ts index d55746df..be480597 100644 --- a/frontend/sync-client/src/utils/data-structures/min-covered.ts +++ b/frontend/sync-client/src/utils/data-structures/min-covered.ts @@ -28,8 +28,8 @@ export class CoveredValues { this.advanceMinWhilePossible(); } - public add(value: number): void { - if (value < this.minValue) { + public add(value: number | undefined): void { + if (value === undefined || value < this.minValue) { return; }