From d29b92058109af55a7ab5f94b52163eea1fb8d5c Mon Sep 17 00:00:00 2001 From: Timo K Date: Mon, 11 May 2026 17:53:09 +0200 Subject: [PATCH] use footer view model in lobby --- src/room/LobbyView.tsx | 44 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/room/LobbyView.tsx b/src/room/LobbyView.tsx index 277ed61c..cec9f6ac 100644 --- a/src/room/LobbyView.tsx +++ b/src/room/LobbyView.tsx @@ -38,6 +38,7 @@ import { useMediaQuery } from "../useMediaQuery"; import { E2eeType } from "../e2ee/e2eeType"; import { Link } from "../button/Link"; import { useMediaDevices } from "../MediaDevicesContext"; +import { ObservableScope } from "../state/ObservableScope"; import { useInitial } from "../useInitial"; import { useTrackProcessor, @@ -46,8 +47,10 @@ import { import { usePageTitle } from "../usePageTitle"; import { getValue } from "../utils/observable"; import { useBehavior } from "../useBehavior"; -import { CallFooter } from "../components/CallFooter"; +import { CallFooter, type FooterSnapshot } from "../components/CallFooter"; import { useCallViewKeyboardShortcuts } from "../useCallViewKeyboardShortcuts"; +import { createLobbyFooterViewModel } from "../components/CallFooterViewModel"; +import { type ViewModel } from "../state/ViewModel"; interface Props { client: MatrixClient; @@ -112,6 +115,7 @@ export const LobbyView: FC = ({ logger.error("Failed to navigate to /", error); }); }, [navigate]); + const hangup = confineToRoom ? undefined : onLeaveClick; const recentsButtonInFooter = useMediaQuery("(max-height: 500px)"); const recentsButton = !confineToRoom && ( @@ -184,6 +188,27 @@ export const LobbyView: FC = ({ useTrackProcessorSync(videoTrack); + const [footerVm, setFooterVm] = useState | null>( + null, + ); + useEffect(() => { + const footerScope = new ObservableScope(); + setFooterVm( + createLobbyFooterViewModel( + footerScope, + muteStates, + devices, + openSettings, + hangup, + // Logo and header are connected: only show the logo in SPA with header. + !hideHeader, + ), + ); + return (): void => { + footerScope.end(); + }; + }, [devices, hangup, hideHeader, muteStates, onLeaveClick, openSettings]); + // TODO: Unify this component with InCallView, so we can get slick joining // animations and don't have to feel bad about reusing its CSS return ( @@ -227,18 +252,11 @@ export const LobbyView: FC = ({ {!recentsButtonInFooter && recentsButton} - - {recentsButtonInFooter && recentsButton} - + {footerVm !== null && ( + + {recentsButtonInFooter && recentsButton} + + )} {client && (