mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 04:41:47 +00:00
Differentiate between refresh/toggle menu
+ visible now checks the actual state to fix PiP bugs
This commit is contained in:
@ -17,7 +17,7 @@ module.exports = (win) => {
|
|||||||
attachTitlebarToWindow(win);
|
attachTitlebarToWindow(win);
|
||||||
|
|
||||||
electronLocalshortcut.register(win, "`", () => {
|
electronLocalshortcut.register(win, "`", () => {
|
||||||
win.webContents.send("refreshMenu", true);
|
win.webContents.send("toggleMenu");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,13 +5,13 @@ const { isEnabled } = require("../../config/plugins");
|
|||||||
function $(selector) { return document.querySelector(selector); }
|
function $(selector) { return document.querySelector(selector); }
|
||||||
|
|
||||||
module.exports = (options) => {
|
module.exports = (options) => {
|
||||||
let visible = !config.get("options.hideMenu");
|
let visible = () => !!$('.cet-menubar').firstChild;
|
||||||
const bar = new Titlebar({
|
const bar = new Titlebar({
|
||||||
icon: "https://cdn-icons-png.flaticon.com/512/5358/5358672.png",
|
icon: "https://cdn-icons-png.flaticon.com/512/5358/5358672.png",
|
||||||
backgroundColor: Color.fromHex("#050505"),
|
backgroundColor: Color.fromHex("#050505"),
|
||||||
itemBackgroundColor: Color.fromHex("#1d1d1d"),
|
itemBackgroundColor: Color.fromHex("#1d1d1d"),
|
||||||
svgColor: Color.WHITE,
|
svgColor: Color.WHITE,
|
||||||
menu: visible ? undefined : null
|
menu: config.get("options.hideMenu") ? null : undefined
|
||||||
});
|
});
|
||||||
bar.updateTitle(" ");
|
bar.updateTitle(" ");
|
||||||
document.title = "Youtube Music";
|
document.title = "Youtube Music";
|
||||||
@ -23,21 +23,21 @@ module.exports = (options) => {
|
|||||||
icon.firstChild.style.webkitUserDrag = 'none';
|
icon.firstChild.style.webkitUserDrag = 'none';
|
||||||
icon.firstChild.style.filter = 'invert(50%)';
|
icon.firstChild.style.filter = 'invert(50%)';
|
||||||
|
|
||||||
const updateMenu = () => {
|
const toggleMenu = () => {
|
||||||
if (visible) {
|
if (visible()) {
|
||||||
bar.updateMenu(null);
|
bar.updateMenu(null);
|
||||||
visible = false;
|
|
||||||
} else {
|
} else {
|
||||||
bar.refreshMenu();
|
bar.refreshMenu();
|
||||||
visible = true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
icon.addEventListener('click', updateMenu);
|
icon.addEventListener('click', toggleMenu);
|
||||||
|
ipcRenderer.on("toggleMenu", toggleMenu);
|
||||||
|
|
||||||
ipcRenderer.on("refreshMenu", (_, fromBack) => {
|
ipcRenderer.on("refreshMenu", () => {
|
||||||
if (fromBack === undefined && !visible) return;
|
if (visible()) {
|
||||||
updateMenu();
|
bar.refreshMenu();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isEnabled("picture-in-picture")) {
|
if (isEnabled("picture-in-picture")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user