diff --git a/app/src/App.tsx b/app/src/App.tsx index a2fab4485..08f003845 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -89,6 +89,7 @@ export default function App() { // const [isConnected, setIsConnected] = useState(socket.connected); // const [fooEvents, setFooEvents] = useState([]); + const [connected, setConnected] = useState(false); const [selectionSchema, setSelectionSchema] = useState({}); const [modifierSchema, setModifierSchema] = useState({}); const [sceneSchema, setSceneSchema] = useState({}); @@ -226,6 +227,7 @@ export default function App() { useEffect(() => { function onConnect() { + setConnected(true); socket.emit( "webclient:connect", (data: { name: string; room: string; authenticated: boolean }) => { @@ -277,6 +279,10 @@ export default function App() { }); } + function onDisconnect() { + setConnected(false); + } + function onSelectionSchema(receivedSchema: any) { setSelectionSchema(receivedSchema); } @@ -373,6 +379,7 @@ export default function App() { } socket.on("connect", onConnect); + socket.on("disconnect", onDisconnect); socket.on("selection:schema", onSelectionSchema); socket.on("modifier:schema", onModifierSchema); socket.on("scene:schema", onSceneSchema); @@ -397,6 +404,7 @@ export default function App() { return () => { socket.off("connect", onConnect); + socket.off("disconnect", onDisconnect); socket.off("selection:schema", onSelectionSchema); socket.off("modifier:schema", onModifierSchema); socket.off("scene:schema", onSceneSchema); @@ -834,6 +842,7 @@ export default function App() { setBookmarks={setBookmarks} selectedFrames={selectedFrames} setSelectedFrames={setSelectedFrames} + connected={connected} /> void; // Replace with actual type if known setSelectedFrames: (selectedFrames: IndicesState) => void; + connected: boolean; } const FrameProgressBar: React.FC = ({ @@ -259,6 +260,7 @@ const FrameProgressBar: React.FC = ({ bookmarks, setBookmarks, setSelectedFrames, + connected, }) => { const [linePosition, setLinePosition] = useState(0); const [disabledFrames, setDisabledFrames] = useState([]); @@ -398,6 +400,25 @@ const FrameProgressBar: React.FC = ({ > 1 + {!connected && ( + + Not connected to server} + > +
+ Loading... +
+
+ + )}