From 605f957f9a7db55ffb92c241f147d8edb70e2eb5 Mon Sep 17 00:00:00 2001 From: Taso Date: Sat, 6 Mar 2021 10:38:10 -0500 Subject: [PATCH] feat(client/debug): Phone restart command (#145) Trigger a UI restart by entering the command `phone:restart` in the F8 console. --- phone/src/Phone.tsx | 2 ++ phone/src/ui/components/WindowSnackbar.tsx | 42 ++++++++++++++++++++++ resources/client/cl_main.ts | 20 +++++------ 3 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 phone/src/ui/components/WindowSnackbar.tsx diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx index bdfc83f..264bf63 100644 --- a/phone/src/Phone.tsx +++ b/phone/src/Phone.tsx @@ -28,6 +28,7 @@ import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility'; import { Snackbar } from './ui/components/Snackbar'; import { NotificationAlert } from './os/notifications/components/NotificationAlert'; import { useCallModal } from './os/call/hooks/useCallModal'; +import WindowSnackbar from './ui/components/WindowSnackbar'; function Phone() { const { apps } = useApps(); @@ -53,6 +54,7 @@ function Phone() { return (
+
{ + const [open, setOpen] = useState(false); + const [message, setMessage] = useState(''); + const [severity, setSeverity] = useState<'info' | 'error' | 'success'>('info'); + + const classes = useStyles(); + + useNuiEvent('PHONE', 'startRestart', () => { + setMessage('Restarting UI'); + setOpen(true); + setSeverity('error'); + setTimeout(() => window.location.reload(), 3000); + }); + + const handleClose = () => { + setOpen(false); + }; + + return ( + + + Phone - {message} + + + ); +}; + +export default WindowSnackbar; diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts index e8a928e..e24a467 100644 --- a/resources/client/cl_main.ts +++ b/resources/client/cl_main.ts @@ -46,15 +46,6 @@ const hidePhone = async (): Promise => { * Register Command and Keybinding * * * * * * * * * * * * * */ - -RegisterCommand( - 'phone:close', - async () => { - await hidePhone(); - }, - false, -); - RegisterCommand( 'phone', async () => { @@ -65,9 +56,16 @@ RegisterCommand( ); RegisterCommand( - 'phone:open', + 'phone:restart', async () => { - await showPhone(); + await hidePhone(); + SendNuiMessage( + JSON.stringify({ + app: 'PHONE', + method: 'startRestart', + data: {}, + }), + ); }, false, );