diff --git a/src/Modal.tsx b/src/Modal.tsx index 491623cc..e6ffdf45 100644 --- a/src/Modal.tsx +++ b/src/Modal.tsx @@ -92,6 +92,11 @@ export const Modal: FC = ({ return ( diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 4940f4d8..7fc97e27 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -227,10 +227,7 @@ export const InCallView: FC = ({ const toggleVideo = useBehavior(muteStates.video.toggle$); const setAudioEnabled = useBehavior(muteStates.audio.setEnabled$); - // This function incorrectly assumes that there is a camera and microphone, which is not always the case. - // TODO: Make sure that this module is resilient when it comes to camera/microphone availability! useCallViewKeyboardShortcuts( - containerRef1, toggleAudio, toggleVideo, setAudioEnabled, diff --git a/src/room/LobbyView.tsx b/src/room/LobbyView.tsx index 65ca00c1..277ed61c 100644 --- a/src/room/LobbyView.tsx +++ b/src/room/LobbyView.tsx @@ -47,6 +47,7 @@ import { usePageTitle } from "../usePageTitle"; import { getValue } from "../utils/observable"; import { useBehavior } from "../useBehavior"; import { CallFooter } from "../components/CallFooter"; +import { useCallViewKeyboardShortcuts } from "../useCallViewKeyboardShortcuts"; interface Props { client: MatrixClient; @@ -91,6 +92,11 @@ export const LobbyView: FC = ({ const [settingsModalOpen, setSettingsModalOpen] = useState(false); const [settingsTab, setSettingsTab] = useState(defaultSettingsTab); + // This function incorrectly assumes that there is a camera and microphone, which is not always the case. + // TODO: Make sure that this module is resilient when it comes to camera/microphone availability! + // Next to the keyboard shortcuts, this is also responsible for catching escape key presses and forwarding the to mobile -> pip. + useCallViewKeyboardShortcuts(toggleAudio, toggleVideo, null, null, null); + const openSettings = useCallback( () => setSettingsModalOpen(true), [setSettingsModalOpen], diff --git a/src/useCallViewKeyboardShortcuts.test.tsx b/src/useCallViewKeyboardShortcuts.test.tsx index 5a327f83..b002c23e 100644 --- a/src/useCallViewKeyboardShortcuts.test.tsx +++ b/src/useCallViewKeyboardShortcuts.test.tsx @@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details. */ import { render } from "@testing-library/react"; -import { type FC, useRef, useState } from "react"; +import { type FC, useState } from "react"; import { expect, test, vi } from "vitest"; import { Button } from "@vector-im/compound-web"; import userEvent from "@testing-library/user-event"; @@ -39,9 +39,7 @@ const TestComponent: FC = ({ initialModalOpen = false, }) => { const [modalOpen, setModalOpen] = useState(initialModalOpen); - const ref = useRef(null); useCallViewKeyboardShortcuts( - ref, () => {}, () => {}, setAudioEnabled, @@ -49,8 +47,11 @@ const TestComponent: FC = ({ toggleHandRaised, ); return ( -
- + <> +
+ +
+ {/*// modal lives outside of the root*/} {modalOpen && ( = ({ )} -
+ ); }; @@ -164,12 +165,13 @@ test("unmuting happens in place of the default action", async () => { // container element that can be interactive and receive focus / keydown // events.