From 19e8a3ca04e0a31b1cbfc5d2c4edda944e0a7da5 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Sat, 26 Nov 2022 09:29:32 -0600 Subject: [PATCH] feat: close peer list when leaving room --- src/components/Room/useRoom.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/Room/useRoom.ts b/src/components/Room/useRoom.ts index 8da6a5c..805d998 100644 --- a/src/components/Room/useRoom.ts +++ b/src/components/Room/useRoom.ts @@ -41,8 +41,14 @@ export function useRoom( ) const [numberOfPeers, setNumberOfPeers] = useState(1) // Includes this peer - const { setDoShowPeers, peerList, setPeerList, tabHasFocus, showAlert } = - useContext(ShellContext) + const { + setDoShowPeers, + peerList, + setPeerList, + tabHasFocus, + showAlert, + setIsPeerListOpen, + } = useContext(ShellContext) const settingsContext = useContext(SettingsContext) const [isMessageSending, setIsMessageSending] = useState(false) const [messageLog, _setMessageLog] = useState< @@ -104,8 +110,9 @@ export function useRoom( useEffect(() => { return () => { peerRoom.leaveRoom() + setIsPeerListOpen(false) } - }, [peerRoom]) + }, [peerRoom, setIsPeerListOpen]) useEffect(() => { setDoShowPeers(true)