From 0bbbec5eda49390e088238fafd53442bbc663e41 Mon Sep 17 00:00:00 2001 From: ririxi Date: Sun, 8 Sep 2024 23:27:51 +0200 Subject: [PATCH] feat(sidebarConfig): disable functionality when Global navbar is used --- jsHelper/sidebarConfig.js | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/jsHelper/sidebarConfig.js b/jsHelper/sidebarConfig.js index 25f97dadae..a64eb7b2ca 100644 --- a/jsHelper/sidebarConfig.js +++ b/jsHelper/sidebarConfig.js @@ -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; @@ -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(); - } - }, - `` - ).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(); + } + }, + `` + ).register(); + } })(); function initConfig() {