diff --git a/.changeset/unlucky-hats-cover.md b/.changeset/unlucky-hats-cover.md new file mode 100644 index 000000000..50a2b8775 --- /dev/null +++ b/.changeset/unlucky-hats-cover.md @@ -0,0 +1,5 @@ +--- +"@powersync/common": patch +--- + +Fix hasSynced to change when there is no data on app load diff --git a/packages/common/src/client/AbstractPowerSyncDatabase.ts b/packages/common/src/client/AbstractPowerSyncDatabase.ts index 3bbd7eac3..04a654cb1 100644 --- a/packages/common/src/client/AbstractPowerSyncDatabase.ts +++ b/packages/common/src/client/AbstractPowerSyncDatabase.ts @@ -325,7 +325,10 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver { - this.currentStatus = new SyncStatus({ ...status.toJSON(), hasSynced: this.currentStatus?.hasSynced }); + this.currentStatus = new SyncStatus({ + ...status.toJSON(), + hasSynced: this.currentStatus?.hasSynced || !!status.lastSyncedAt + }); this.iterateListeners((cb) => cb.statusChanged?.(this.currentStatus)); } }); @@ -766,7 +769,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver t.replace(POWERSYNC_TABLE_MATCH, '')); - for (let table of mappedTableNames) { + for (const table of mappedTableNames) { changedTables.add(table); } }