mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
feat(client/debug): Phone restart command (#145)
Trigger a UI restart by entering the command `phone:restart` in the F8 console.
This commit is contained in:
3 files changed
+53
-11
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Snackbar, Typography } from '@material-ui/core';
|
||||
import { useNuiEvent } from '../../os/nui-events/hooks/useNuiEvent';
|
||||
import { Alert } from './Alert';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
position: 'absolute',
|
||||
width: 'auto',
|
||||
bottom: 20,
|
||||
},
|
||||
});
|
||||
// NOTE: Will make this more generic at some point for error handling as well
|
||||
const WindowSnackbar = () => {
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const [message, setMessage] = useState<string>('');
|
||||
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 (
|
||||
<Snackbar open={open} onClose={handleClose} className={classes.root}>
|
||||
<Alert severity={severity}>
|
||||
<Typography variant="body1">Phone - {message}</Typography>
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
);
|
||||
};
|
||||
|
||||
export default WindowSnackbar;
|
||||
Reference in new issue
Block a user