Skip to content

Commit 51276e0

Browse files
committed
* Simplified drawerbar
1 parent 98425c3 commit 51276e0

File tree

7 files changed

+11
-21
lines changed

7 files changed

+11
-21
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ yarn-error.log*
2424

2525
.idea
2626
.idea/*
27+
dist/*

src/components/App/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function App() {
3636
<BrowserRouter>
3737
<DropZone>
3838
<Topbar/>
39-
<Drawerbar/>
4039
<CssBaseline/>
4140
<Switch>
4241
<Route path={"/settings"}>

src/components/Drawerbar/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ChevronRightIcon from '@material-ui/icons/ChevronRight';
99
import ListItem from '@material-ui/core/ListItem';
1010
import ListItemIcon from '@material-ui/core/ListItemIcon';
1111
import ListItemText from '@material-ui/core/ListItemText';
12-
import {useSelector, useDispatch} from "react-redux";
12+
import {useSelector} from "react-redux";
1313
import InfoIcon from '@material-ui/icons/Info';
1414
import BuildIcon from "@material-ui/icons/Build";
1515
import HelpIcon from "@material-ui/icons/Help";
@@ -37,31 +37,29 @@ const useStyles = makeStyles(theme => ({
3737

3838
const ipcRenderer = window.require('electron').ipcRenderer;
3939

40-
const Drawerbar = () => {
40+
const Drawerbar = ({open, onClose}) => {
4141

4242
const language = useSelector(state => state.MainReducer.languages[state.MainReducer.languageIndex]);
43-
const open = useSelector(state => state.MainReducer.drawerOpen);
4443
const selectedItem = useSelector(state => state.MainReducer.selectedListItem);
4544

4645
const history = useHistory();
4746

4847
const classes = useStyles();
4948
const theme = useTheme();
50-
const dispatch = useDispatch();
5149

5250
/**
5351
* Function that is called when the drawer should close
5452
*/
5553
const handleDrawerClose = () => {
56-
dispatch({type: "SET_DRAWEROPEN", drawerOpen: false});
54+
onClose();
5755
};
5856

5957
/**
6058
* Handle a page change
6159
* @param index The index of the page
6260
*/
6361
const handleIndexChange = (index) => {
64-
dispatch({type: "SET_DRAWEROPEN", drawerOpen: false});
62+
onClose();
6563
if (selectedItem === index) return;
6664

6765
switch (index) {
@@ -138,7 +136,6 @@ const Drawerbar = () => {
138136
<ListItemText primary={language.exit}/>
139137
</ListItem>
140138
</List>
141-
142139
</Drawer>
143140
);
144141
};

src/components/Topbar/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import CloseIcon from '@material-ui/icons/Close';
1313
import MinimizeIcon from "@material-ui/icons/Minimize";
1414
import FullScreenIcon from "@material-ui/icons/Fullscreen";
1515
import FullscreenExitIcon from "@material-ui/icons/FullscreenExit";
16+
import Drawerbar from "../Drawerbar";
1617

1718
const drawerWidth = 220;
1819
const useStyles = makeStyles(theme => ({
@@ -46,7 +47,6 @@ const ipcRenderer = window.require('electron').ipcRenderer;
4647
const Topbar = () => {
4748

4849
const classes = useStyles();
49-
const open = useSelector(state => state.MainReducer.drawerOpen);
5050
const languageIndex = useSelector(state => state.MainReducer.languageIndex);
5151
const language = useSelector(state => state.MainReducer.languages[state.MainReducer.languageIndex]);
5252
const minimizeEnabled = useSelector(state => state.MainReducer.minimizeEnabled);
@@ -56,6 +56,7 @@ const Topbar = () => {
5656

5757
const [anchorEl, setAnchorEl] = useState(null);
5858
const [fullScreen, setFullScreen] = useState(false);
59+
const [drawerOpen, setDrawerOpen] = useState(false);
5960
const languageOpen = Boolean(anchorEl);
6061

6162
ipcRenderer.on("window-maximized", () => {
@@ -70,7 +71,7 @@ const Topbar = () => {
7071
* Open the drawer
7172
*/
7273
const openDrawer = () => {
73-
dispatch({type: "SET_DRAWEROPEN", drawerOpen: true});
74+
setDrawerOpen(true);
7475
};
7576

7677
/**
@@ -114,9 +115,9 @@ const Topbar = () => {
114115
return (
115116
<div className={classes.root}>
116117
<AppBar position="fixed" color={"primary"}
117-
className={open ? classes.appBarShift + ' ' + classes.appBar : classes.appBar}>
118+
className={drawerOpen ? classes.appBarShift + ' ' + classes.appBar : classes.appBar}>
118119
<Toolbar>
119-
<IconButton edge="start" className={open ? classes.hide : null} color="inherit"
120+
<IconButton edge="start" className={drawerOpen ? classes.hide : null} color="inherit"
120121
aria-label="menu" onClick={openDrawer}>
121122
<MenuIcon/>
122123
</IconButton>
@@ -194,6 +195,7 @@ const Topbar = () => {
194195
</IconButton>
195196
</Toolbar>
196197
</AppBar>
198+
<Drawerbar open={drawerOpen} onClose={() => setDrawerOpen(false)}/>
197199
<Toolbar/>
198200
</div>
199201
);

src/reducers/MainReducer/Actions/MainActions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {createAction} from 'redux-actions';
22

33
export const setLanguageIndex = createAction("SET_LANGUAGEINDEX");
4-
export const setDrawerOpen = createAction("SET_DRAWEROPEN");
54
export const setActiveListItem = createAction("SET_ACTIVE_LISTITEM");
65
export const setThemeIndex = createAction("SET_THEME_INDEX");
76
export const setAutoUpdate = createAction("SET_AUTO_UPDATE");

src/reducers/MainReducer/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import en_US from "../../languages/en_US";
33
import {
44
setLanguageIndex,
55
setActiveListItem,
6-
setDrawerOpen,
76
setThemeIndex,
87
setAutoUpdate,
98
setUpdateChecked,
@@ -88,12 +87,6 @@ const MainReducer = handleActions({
8887
selectedListItem: action.index
8988
}
9089
},
91-
[setDrawerOpen](state, action) {
92-
return {
93-
...state,
94-
drawerOpen: action.drawerOpen
95-
}
96-
},
9790
[setThemeIndex](state, action) {
9891
localStorage['themeIndex'] = action.payload;
9992
return {

src/routes/About/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const About = () => {
4040

4141
ipcRenderer.on('get-version-reply', (e, version) => {
4242
setAppVersion(version);
43-
console.log(version);
4443
});
4544
ipcRenderer.send('get-version');
4645

0 commit comments

Comments
 (0)