Skip to content

Commit ed461d0

Browse files
authored
Merge pull request #159 from powersync-ja/fix-diagnostics-status
[diagnostics-app] Fix sync status
2 parents b553527 + 0dbc38d commit ed461d0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import React from 'react';
2828
import { LOGIN_ROUTE, SCHEMA_ROUTE, SQL_CONSOLE_ROUTE, SYNC_DIAGNOSTICS_ROUTE } from '@/app/router';
2929
import { useNavigationPanel } from '@/components/navigation/NavigationPanelContext';
3030
import { signOut, sync, syncErrorTracker } from '@/library/powersync/ConnectionManager';
31-
import { usePowerSync, useStatus } from '@powersync/react';
31+
import { usePowerSync } from '@powersync/react';
3232
import { useNavigate } from 'react-router-dom';
3333

3434
export default function ViewsLayout({ children }: { children: React.ReactNode }) {
3535
const powerSync = usePowerSync();
3636
const navigate = useNavigate();
3737

38-
const syncStatus = useStatus();
38+
const [syncStatus, setSyncStatus] = React.useState(sync.syncStatus);
3939
const [syncError, setSyncError] = React.useState<Error | null>(null);
4040
const { title } = useNavigationPanel();
4141

@@ -86,6 +86,16 @@ export default function ViewsLayout({ children }: { children: React.ReactNode })
8686
[powerSync]
8787
);
8888

89+
// Cannot use `useStatus()`, since we're not using the default sync implementation.
90+
React.useEffect(() => {
91+
const l = sync.registerListener({
92+
statusChanged: (status) => {
93+
setSyncStatus(status);
94+
}
95+
});
96+
return () => l();
97+
}, []);
98+
8999
React.useEffect(() => {
90100
const l = syncErrorTracker.registerListener({
91101
lastErrorUpdated(error) {

0 commit comments

Comments
 (0)