Skip to content

Commit

Permalink
feat(sidebarConfig): disable functionality when Global navbar is used
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri committed Sep 8, 2024
1 parent ffa71c3 commit 0bbbec5
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions jsHelper/sidebarConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(function SidebarConfig() {
const sidebar = document.querySelector(".Root__nav-bar");
if (!sidebar) return setTimeout(SidebarConfig, 100);
let isGlobalNavbar = false;
// Status enum
const HIDDEN = 0;
const SHOW = 1;
Expand Down Expand Up @@ -164,19 +165,29 @@ color: var(--spice-button-disabled);

(async () => {
await new Promise((res) => Spicetify.Events.webpackLoaded.on(res));
new Spicetify.Menu.Item(
"Sidebar config",
false,
(self) => {
self.setState(!self.isEnabled);
if (self.isEnabled) {
injectInteraction();
} else {
removeInteraction();
}
},
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="16px" height="16px" fill="currentcolor"><path d="M44.7,11L36,19.6c0,0-2.6,0-5.2-2.6s-2.6-5.2-2.6-5.2l8.7-8.7c-4.9-1.2-10.8,0.4-14.4,4c-5.4,5.4-0.6,12.3-2,13.7C12.9,28.7,5.1,34.7,4.9,35c-2.3,2.3-2.4,6-0.2,8.2c2.2,2.2,5.9,2.1,8.2-0.2c0.3-0.3,6.7-8.4,14.2-15.9c1.4-1.4,8,3.7,13.6-1.8C44.2,21.7,45.9,15.9,44.7,11z M9.4,41.1c-1.4,0-2.5-1.1-2.5-2.5C6.9,37.1,8,36,9.4,36c1.4,0,2.5,1.1,2.5,2.5C11.9,39.9,10.8,41.1,9.4,41.1z"/></svg>`
).register();
if (document.querySelector(".Root__globalNav")) {
Spicetify.showNotification(
"Sidebar config is not supported on global navbar. Please disable it with `spicetify config sidebar_config 0` command.",
false,
7000
);
isGlobalNavbar = true;
}
if (!isGlobalNavbar) {
new Spicetify.Menu.Item(
"Sidebar config",
false,
(self) => {
self.setState(!self.isEnabled);
if (self.isEnabled) {
injectInteraction();
} else {
removeInteraction();
}
},
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="16px" height="16px" fill="currentcolor"><path d="M44.7,11L36,19.6c0,0-2.6,0-5.2-2.6s-2.6-5.2-2.6-5.2l8.7-8.7c-4.9-1.2-10.8,0.4-14.4,4c-5.4,5.4-0.6,12.3-2,13.7C12.9,28.7,5.1,34.7,4.9,35c-2.3,2.3-2.4,6-0.2,8.2c2.2,2.2,5.9,2.1,8.2-0.2c0.3-0.3,6.7-8.4,14.2-15.9c1.4-1.4,8,3.7,13.6-1.8C44.2,21.7,45.9,15.9,44.7,11z M9.4,41.1c-1.4,0-2.5-1.1-2.5-2.5C6.9,37.1,8,36,9.4,36c1.4,0,2.5,1.1,2.5,2.5C11.9,39.9,10.8,41.1,9.4,41.1z"/></svg>`
).register();
}
})();

function initConfig() {
Expand Down

0 comments on commit 0bbbec5

Please sign in to comment.