mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
Keep the sidebar opened or closed on reload
Previously, going to a full-width page and heading back to the terminal would default the sidebar to its opened state regardless of what it was before. Now it stores it in the GameRoot's state and also in the Settings so that it persists over reloads.
This commit is contained in:
@@ -106,6 +106,8 @@ interface IProps {
|
||||
player: IPlayer;
|
||||
router: IRouter;
|
||||
page: Page;
|
||||
opened: boolean;
|
||||
onToggled: (newValue: boolean) => void;
|
||||
}
|
||||
|
||||
export function SidebarRoot(props: IProps): React.ReactElement {
|
||||
@@ -337,8 +339,13 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
||||
}, []);
|
||||
|
||||
const classes = useStyles();
|
||||
const [open, setOpen] = useState(true);
|
||||
const [open, setOpen] = useState(props.opened);
|
||||
const toggleDrawer = (): void => setOpen((old) => !old);
|
||||
|
||||
useEffect(() => {
|
||||
props.onToggled(open);
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<Drawer open={open} anchor="left" variant="permanent">
|
||||
<ListItem classes={{ root: classes.listitem }} button onClick={toggleDrawer}>
|
||||
|
||||
Reference in New Issue
Block a user