feat: fixed bugs

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-02-15 23:36:20 -08:00
parent 11b9ebd9cd
commit b9159a8329
6 changed files with 81 additions and 17 deletions

View file

@ -230,11 +230,19 @@ export function useDocuments(
async function setupElectricRealtime() {
// Cleanup previous subscriptions
if (syncHandleRef.current) {
syncHandleRef.current.unsubscribe();
try {
syncHandleRef.current.unsubscribe();
} catch {
// PGlite may already be closed during cleanup
}
syncHandleRef.current = null;
}
if (liveQueryRef.current) {
liveQueryRef.current.unsubscribe?.();
try {
liveQueryRef.current.unsubscribe?.();
} catch {
// PGlite may already be closed during cleanup
}
liveQueryRef.current = null;
}
@ -420,11 +428,19 @@ export function useDocuments(
return () => {
mounted = false;
if (syncHandleRef.current) {
syncHandleRef.current.unsubscribe();
try {
syncHandleRef.current.unsubscribe();
} catch {
// PGlite may already be closed during cleanup
}
syncHandleRef.current = null;
}
if (liveQueryRef.current) {
liveQueryRef.current.unsubscribe?.();
try {
liveQueryRef.current.unsubscribe?.();
} catch {
// PGlite may already be closed during cleanup
}
liveQueryRef.current = null;
}
};