|
1 | 1 | 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'; |
3 | 3 | import { |
4 | 4 | Box, |
5 | 5 | Button, |
@@ -81,14 +81,23 @@ export default function SyncDiagnosticsPage() { |
81 | 81 | // Similar to db.currentState.hasSynced, but synchronized to the onChange events |
82 | 82 | const { synced_at } = await db.get<{ synced_at: string | null }>('SELECT powersync_last_synced_at() as synced_at'); |
83 | 83 | setlastSyncedAt(synced_at ? new Date(synced_at + 'Z') : null); |
84 | | - if (synced_at != null) { |
| 84 | + if (synced_at != null && !sync.syncStatus.dataFlowStatus.downloading) { |
85 | 85 | // These are potentially expensive queries - do not run during initial sync |
86 | 86 | const bucketRows = await db.getAll(BUCKETS_QUERY); |
87 | 87 | const tableRows = await db.getAll(TABLES_QUERY); |
88 | 88 | setBucketRows(bucketRows); |
89 | 89 | 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 | + } |
90 | 99 | } else { |
91 | | - // Fast query to show progress during initial sync |
| 100 | + // Fast query to show progress during initial sync / while downloading bulk data |
92 | 101 | const bucketRows = await db.getAll(BUCKETS_QUERY_FAST); |
93 | 102 | setBucketRows(bucketRows); |
94 | 103 | setTableRows(null); |
|
0 commit comments