Skip to content

Commit d53fd24

Browse files
committed
Skip slow queries while downloading.
1 parent ff10d69 commit d53fd24

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tools/diagnostics-app/src/app/views/sync-diagnostics.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NavigationPage } from '@/components/navigation/NavigationPage';
2-
import { clearData, db, syncErrorTracker } from '@/library/powersync/ConnectionManager';
2+
import { clearData, db, sync, syncErrorTracker } from '@/library/powersync/ConnectionManager';
33
import {
44
Box,
55
Button,
@@ -81,14 +81,23 @@ export default function SyncDiagnosticsPage() {
8181
// Similar to db.currentState.hasSynced, but synchronized to the onChange events
8282
const { synced_at } = await db.get<{ synced_at: string | null }>('SELECT powersync_last_synced_at() as synced_at');
8383
setlastSyncedAt(synced_at ? new Date(synced_at + 'Z') : null);
84-
if (synced_at != null) {
84+
if (synced_at != null && !sync.syncStatus.dataFlowStatus.downloading) {
8585
// These are potentially expensive queries - do not run during initial sync
8686
const bucketRows = await db.getAll(BUCKETS_QUERY);
8787
const tableRows = await db.getAll(TABLES_QUERY);
8888
setBucketRows(bucketRows);
8989
setTableRows(tableRows);
90+
} else if (synced_at != null) {
91+
// Busy downloading, but have already synced once
92+
const bucketRows = await db.getAll(BUCKETS_QUERY_FAST);
93+
setBucketRows(bucketRows);
94+
// Load tables if we haven't yet
95+
if (tableRows == null) {
96+
const tableRows = await db.getAll(TABLES_QUERY);
97+
setTableRows(tableRows);
98+
}
9099
} else {
91-
// Fast query to show progress during initial sync
100+
// Fast query to show progress during initial sync / while downloading bulk data
92101
const bucketRows = await db.getAll(BUCKETS_QUERY_FAST);
93102
setBucketRows(bucketRows);
94103
setTableRows(null);

0 commit comments

Comments
 (0)