Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/unlucky-hats-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@powersync/common": patch
---

Fix hasSynced to change when there is no data on app load
9 changes: 6 additions & 3 deletions packages/common/src/client/AbstractPowerSyncDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
this.syncStreamImplementation = this.generateSyncStreamImplementation(connector);
this.syncStatusListenerDisposer = this.syncStreamImplementation.registerListener({
statusChanged: (status) => {
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));
}
});
Expand Down Expand Up @@ -766,7 +769,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
`SELECT DISTINCT tbl_name FROM sqlite_master WHERE rootpage IN (SELECT json_each.value FROM json_each(?))`,
[JSON.stringify(rootPages)]
);
for (let table of tables) {
for (const table of tables) {
resolvedTables.push(table.tbl_name.replace(POWERSYNC_TABLE_MATCH, ''));
}
}
Expand Down Expand Up @@ -937,7 +940,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
? filteredTables
: filteredTables.map((t) => t.replace(POWERSYNC_TABLE_MATCH, ''));

for (let table of mappedTableNames) {
for (const table of mappedTableNames) {
changedTables.add(table);
}
}
Expand Down