mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 09:46:25 +02:00
chore: ran both frontend and backend linting
This commit is contained in:
parent
99bd2df463
commit
5bd6bd3d67
21 changed files with 861 additions and 739 deletions
|
|
@ -1,54 +1,54 @@
|
|||
"use client"
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { initElectric, isElectricInitialized } from '@/lib/electric/client'
|
||||
import { useEffect, useState } from "react";
|
||||
import { initElectric, isElectricInitialized } from "@/lib/electric/client";
|
||||
|
||||
interface ElectricProviderProps {
|
||||
children: React.ReactNode
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* ElectricProvider initializes the Electric SQL client with PGlite
|
||||
*
|
||||
*
|
||||
* This provider ensures Electric is initialized before rendering children,
|
||||
* but doesn't block if initialization fails (app can still work without real-time sync)
|
||||
*/
|
||||
export function ElectricProvider({ children }: ElectricProviderProps) {
|
||||
const [initialized, setInitialized] = useState(false)
|
||||
const [error, setError] = useState<Error | null>(null)
|
||||
const [initialized, setInitialized] = useState(false);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip if already initialized
|
||||
if (isElectricInitialized()) {
|
||||
setInitialized(true)
|
||||
return
|
||||
setInitialized(true);
|
||||
return;
|
||||
}
|
||||
|
||||
let mounted = true
|
||||
let mounted = true;
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
await initElectric()
|
||||
await initElectric();
|
||||
if (mounted) {
|
||||
setInitialized(true)
|
||||
setError(null)
|
||||
setInitialized(true);
|
||||
setError(null);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to initialize Electric SQL:', err)
|
||||
console.error("Failed to initialize Electric SQL:", err);
|
||||
if (mounted) {
|
||||
setError(err instanceof Error ? err : new Error('Failed to initialize Electric SQL'))
|
||||
setError(err instanceof Error ? err : new Error("Failed to initialize Electric SQL"));
|
||||
// Don't block rendering if Electric SQL fails - app can still work
|
||||
setInitialized(true)
|
||||
setInitialized(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init()
|
||||
init();
|
||||
|
||||
return () => {
|
||||
mounted = false
|
||||
}
|
||||
}, [])
|
||||
mounted = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Show loading state only briefly, then render children
|
||||
// Electric SQL will sync in the background
|
||||
|
|
@ -57,13 +57,13 @@ export function ElectricProvider({ children }: ElectricProviderProps) {
|
|||
<div className="flex items-center justify-center min-h-screen">
|
||||
<div className="text-muted-foreground">Initializing...</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// If there's an error, still render children but log the error
|
||||
if (error) {
|
||||
console.warn('Electric SQL initialization failed, notifications may not sync:', error.message)
|
||||
console.warn("Electric SQL initialization failed, notifications may not sync:", error.message);
|
||||
}
|
||||
|
||||
return <>{children}</>
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue