diff --git a/App.tsx b/App.tsx index dd8f7bc..0ea36d1 100644 --- a/App.tsx +++ b/App.tsx @@ -62,6 +62,8 @@ const App: React.FC = () => { // WebSocket const wsRef = useRef(null); const connectionRef = useRef(connection); + const localRef = useRef(local); + const remoteRef = useRef(remote); // --- Helpers --- const addLog = useCallback((type: LogEntry['type'], message: string) => { @@ -101,7 +103,9 @@ const App: React.FC = () => { // Sync connection state to ref for WS callbacks useEffect(() => { connectionRef.current = connection; - }, [connection]); + localRef.current = local; + remoteRef.current = remote; + }, [connection, local, remote]); // --- WebSocket Setup --- useEffect(() => { @@ -264,9 +268,9 @@ const App: React.FC = () => { case 'success': addLog('success', data.message); if (connectionRef.current.connected) { - ws?.send(JSON.stringify({ command: 'LIST', path: remote.path })); + ws?.send(JSON.stringify({ command: 'LIST', path: remoteRef.current.path })); } - ws?.send(JSON.stringify({ command: 'LOCAL_LIST', path: local.path })); + ws?.send(JSON.stringify({ command: 'LOCAL_LIST', path: localRef.current.path })); break; case 'sites_list': @@ -295,9 +299,9 @@ const App: React.FC = () => { addLog('success', data.message); // Refresh lists if (data.path) { - ws?.send(JSON.stringify({ command: 'LOCAL_LIST', path: local.path })); + ws?.send(JSON.stringify({ command: 'LOCAL_LIST', path: localRef.current.path })); if (connectionRef.current.connected) { - ws?.send(JSON.stringify({ command: 'LIST', path: remote.path })); + ws?.send(JSON.stringify({ command: 'LIST', path: remoteRef.current.path })); } } break;