Skip to content

Commit 0bbbec5

Browse files
committed
feat(sidebarConfig): disable functionality when Global navbar is used
1 parent ffa71c3 commit 0bbbec5

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

jsHelper/sidebarConfig.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(function SidebarConfig() {
22
const sidebar = document.querySelector(".Root__nav-bar");
33
if (!sidebar) return setTimeout(SidebarConfig, 100);
4+
let isGlobalNavbar = false;
45
// Status enum
56
const HIDDEN = 0;
67
const SHOW = 1;
@@ -164,19 +165,29 @@ color: var(--spice-button-disabled);
164165

165166
(async () => {
166167
await new Promise((res) => Spicetify.Events.webpackLoaded.on(res));
167-
new Spicetify.Menu.Item(
168-
"Sidebar config",
169-
false,
170-
(self) => {
171-
self.setState(!self.isEnabled);
172-
if (self.isEnabled) {
173-
injectInteraction();
174-
} else {
175-
removeInteraction();
176-
}
177-
},
178-
`<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>`
179-
).register();
168+
if (document.querySelector(".Root__globalNav")) {
169+
Spicetify.showNotification(
170+
"Sidebar config is not supported on global navbar. Please disable it with `spicetify config sidebar_config 0` command.",
171+
false,
172+
7000
173+
);
174+
isGlobalNavbar = true;
175+
}
176+
if (!isGlobalNavbar) {
177+
new Spicetify.Menu.Item(
178+
"Sidebar config",
179+
false,
180+
(self) => {
181+
self.setState(!self.isEnabled);
182+
if (self.isEnabled) {
183+
injectInteraction();
184+
} else {
185+
removeInteraction();
186+
}
187+
},
188+
`<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>`
189+
).register();
190+
}
180191
})();
181192

182193
function initConfig() {

0 commit comments

Comments
 (0)