@@ -11,6 +11,7 @@ import { ref, computed, readonly, onMounted, onUnmounted } from 'vue';
1111import { computedAsync } from '@vueuse/core' ;
1212import { usePowerSyncInspector } from './usePowerSyncInspector' ;
1313import type { NuxtDatabaseImplementation } from '../utils/NuxtPowerSyncDatabase' ;
14+ import { SyncStatusSnapshot } from '@powersync/shared-internals' ;
1415
1516// queries
1617const BUCKETS_QUERY = `
@@ -308,17 +309,21 @@ export function usePowerSyncInspectorDiagnostics(): UsePowerSyncInspectorDiagnos
308309
309310 async function refreshState ( ) {
310311 if ( db . value ) {
311- const { synced_at } = await db . value . get < { synced_at : string | null } > (
312- 'SELECT powersync_last_synced_at() as synced_at'
312+ // FIXME: This relies on internal core extension APIs, why can't this use the
313+ // current sync status?
314+ const { status : rawStatus } = await db . value . get < { status : string } > (
315+ 'SELECT powersync_offline_sync_status() as status'
313316 ) ;
317+ const status = new SyncStatusSnapshot ( JSON . parse ( rawStatus ) , null ) ;
318+ const hasSyned = status . hasSynced ;
314319
315- uploadQueueStats . value = await db . value ? .getUploadQueueStats ( true ) ;
320+ uploadQueueStats . value = await db . value . getUploadQueueStats ( true ) ;
316321
317- if ( synced_at != null && ! syncStatus . value ? .downloading ) {
322+ if ( hasSyned && ! syncStatus . value . downloading ) {
318323 // These are potentially expensive queries - do not run during initial sync
319324 bucketRows . value = await db . value . getAll ( BUCKETS_QUERY ) ;
320325 tableRows . value = await db . value . getAll ( TABLES_QUERY ) ;
321- } else if ( synced_at != null ) {
326+ } else if ( hasSyned ) {
322327 // Busy downloading, but have already synced once
323328 bucketRows . value = await db . value . getAll ( BUCKETS_QUERY_FAST ) ;
324329 // Load tables if we haven't yet
0 commit comments