mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 03:20:46 +02:00
Improve loading speed of desktop app (#4865)
# Description of Changes Improve loading speed of desktop app by loading a default config until the backend has spawned.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useBackendHealth } from '@app/hooks/useBackendHealth';
|
||||
import { useAppConfig } from '@app/contexts/AppConfigContext';
|
||||
|
||||
/**
|
||||
* Desktop-only bridge that refetches the app config once the bundled backend
|
||||
* becomes healthy (and whenever it restarts). Keeps the UI responsive by using
|
||||
* default config until the real config is available.
|
||||
*/
|
||||
export function DesktopConfigSync() {
|
||||
const { status } = useBackendHealth();
|
||||
const { refetch } = useAppConfig();
|
||||
const previousStatus = useRef(status);
|
||||
|
||||
useEffect(() => {
|
||||
if (status === 'healthy' && previousStatus.current !== 'healthy') {
|
||||
refetch();
|
||||
}
|
||||
previousStatus.current = status;
|
||||
}, [status, refetch]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user