feat: in-app-menu hideIcon option

This commit is contained in:
Araxeus
2022-04-09 22:56:01 +03:00
parent 648d540ca9
commit b4b785d773
2 changed files with 21 additions and 1 deletions

View File

@ -3,7 +3,7 @@ const config = require("../../config");
const { Titlebar, Color } = require("custom-electron-titlebar");
function $(selector) { return document.querySelector(selector); }
module.exports = () => {
module.exports = (options) => {
let visible = !config.get("options.hideMenu");
const bar = new Titlebar({
backgroundColor: Color.fromHex("#050505"),
@ -14,6 +14,10 @@ module.exports = () => {
bar.updateTitle(" ");
document.title = "Youtube Music";
const hideIcon = hide => $('.cet-window-icon').style.display = hide ? 'none' : 'flex';
if (options.hideIcon) hideIcon(true);
ipcRenderer.on("refreshMenu", (_, showMenu) => {
if (showMenu === undefined && !visible) return;
if (showMenu === false) {
@ -25,6 +29,8 @@ module.exports = () => {
}
});
ipcRenderer.on("hideIcon", (_, hide) => hideIcon(hide));
// Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it)
document.addEventListener('apiLoaded', () => {
setNavbarMargin();

View File

@ -0,0 +1,14 @@
const { setOptions } = require("../../config/plugins");
module.exports = (win, options) => [
{
label: "Hide Icon",
type: "checkbox",
checked: options.hideIcon,
click: (item) => {
win.webContents.send("hideIcon", item.checked);
options.hideIcon = item.checked;
setOptions("in-app-menu", options);
},
}
];