38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import React from 'react';
|
|||
|
|
import { useKeyboardShortcuts } from '@/hooks/useKeyboardShortcuts';
|
||
|
|
import { usePwaManifestSync } from '@/hooks/usePwaManifestSync';
|
||
|
|
import { useQueuedMessageAutoSend } from '@/hooks/useQueuedMessageAutoSend';
|
||
|
|
import { useSessionAutoCleanup } from '@/hooks/useSessionAutoCleanup';
|
||
|
|
import { useWindowControlsOverlayLayout } from '@/hooks/useWindowControlsOverlayLayout';
|
||
|
|
import { setOptimisticRefs } from '@/sync/session-actions';
|
||
|
|
import { useSync } from '@/sync/use-sync';
|
||
|
|
|
||
|
|
const SyncOptimisticBridge: React.FC = () => {
|
||
|
|
const sync = useSync();
|
||
|
|
const addRef = React.useRef(sync.optimistic.add);
|
||
|
|
const removeRef = React.useRef(sync.optimistic.remove);
|
||
|
|
addRef.current = sync.optimistic.add;
|
||
|
|
removeRef.current = sync.optimistic.remove;
|
||
|
|
|
||
|
|
React.useEffect(() => {
|
||
|
|
setOptimisticRefs(
|
||
|
|
(input) => addRef.current(input),
|
||
|
|
(input) => removeRef.current(input),
|
||
|
|
);
|
||
|
|
}, []);
|
||
|
|
|
||
|
|
return null;
|
||
|
|
};
|
||
|
|
|
||
|
|
export function SyncAppEffects({ embeddedBackgroundWorkEnabled }: {
|
||
|
|
embeddedBackgroundWorkEnabled: boolean;
|
||
|
|
}) {
|
||
|
|
usePwaManifestSync();
|
||
|
|
useWindowControlsOverlayLayout();
|
||
|
|
useSessionAutoCleanup(embeddedBackgroundWorkEnabled);
|
||
|
|
useQueuedMessageAutoSend(embeddedBackgroundWorkEnabled);
|
||
|
|
useKeyboardShortcuts();
|
||
|
|
|
||
|
|
return <SyncOptimisticBridge />;
|
||
|
|
}
|