From 0ed354c8f4027e0eaf86b373f28aa75e13c4ec45 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 1 Dec 2023 15:57:21 -0500 Subject: [PATCH] fix(striker-ui): add return home to VNC window, reorganize RFB disconnect --- striker-ui/components/Display/FullSize.tsx | 34 +++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/striker-ui/components/Display/FullSize.tsx b/striker-ui/components/Display/FullSize.tsx index 544be304..af1d93b9 100644 --- a/striker-ui/components/Display/FullSize.tsx +++ b/striker-ui/components/Display/FullSize.tsx @@ -1,5 +1,6 @@ import { Close as CloseIcon, + Dashboard as DashboardIcon, Keyboard as KeyboardIcon, } from '@mui/icons-material'; import { Box, Menu, styled, Typography } from '@mui/material'; @@ -100,17 +101,18 @@ const FullSize: FC = ({ }, [serverUUID]); const disconnectServerVnc = useCallback(() => { + if (rfb?.current) { + rfb.current.disconnect(); + rfb.current = null; + } + setRfbConnectArgs(undefined); }, []); const reconnectServerVnc = useCallback(() => { - if (!rfb?.current) return; - - rfb.current.disconnect(); - rfb.current = null; - + disconnectServerVnc(); connectServerVnc(); - }, [connectServerVnc]); + }, [connectServerVnc, disconnectServerVnc]); const updateVncReconnectTimer = useCallback((): void => { const intervalId = setInterval((): void => { @@ -188,15 +190,33 @@ const FullSize: FC = ({ [disconnectServerVnc, onClickCloseButton], ); + const returnHomeElement = useMemo( + () => ( + { + if (!window) return; + + disconnectServerVnc(); + + window.location.assign('/'); + }} + > + + + ), + [disconnectServerVnc], + ); + const vncToolbarElement = useMemo( () => showScreen && ( <> {keyboardMenuElement} + {returnHomeElement} {vncDisconnectElement} ), - [keyboardMenuElement, showScreen, vncDisconnectElement], + [keyboardMenuElement, returnHomeElement, showScreen, vncDisconnectElement], ); useEffect(() => {