refactor and stylecheck

This commit is contained in:
Araxeus
2021-04-03 22:04:40 +03:00
parent 317521bba6
commit 70b03b71e4
2 changed files with 10 additions and 6 deletions

View File

@ -147,7 +147,6 @@ const mainMenuTemplate = (win) => [
label: "Proxy",
type: "checkbox",
checked: !!config.get("options.proxy"),
//fixed: true, //skip in-app-menu click() override
click: (item) => {
setProxy(item, win);
}
@ -310,7 +309,6 @@ module.exports.setApplicationMenu = (win) => {
Menu.setApplicationMenu(menu);
};
//
const iconPath = path.join(__dirname, "assets", "youtube-music-tray.png");
function setProxy(item, win) {
prompt({
@ -326,7 +324,6 @@ function setProxy(item, win) {
})
.then((input) => {
if(input !== null) {
console.log(`setting proxy to ${input}`);
config.set("options.proxy", input);
if(input === "")
item.checked = false;

View File

@ -9,6 +9,8 @@ const { injectCSS } = require("../utils");
//check that menu doesn't get created twice
let done = false;
//tracks menu visibility
let visible = true;
// win hook for fixing menu
let win;
@ -41,17 +43,22 @@ module.exports = (winImport) => {
//register keyboard shortcut && hide menu if hideMenu is enabled
if (config.get("options.hideMenu")) {
switchMenuVisibility();
visible = false;
electronLocalshortcut.register(win, "Esc", () => {
switchMenuVisibility();
});
}
// fix bug with menu not applying on start
setMenuVisibility(visible);
});
};
let visible = false;
function switchMenuVisibility() {
visible = !visible;
setMenuVisibility(!visible);
}
function setMenuVisibility(value){
visible = value;
win.webContents.send("updateMenu", visible);
}