Skip to content

Commit 3207240

Browse files
authored
fix: adapt Cosmos and ConfirmDialog for 1.2.41 (#3089)
1 parent abe53f6 commit 3207240

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

jsHelper/spicetifyWrapper.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,13 @@ window.Spicetify = {
310310
};
311311

312312
(function addProxyCosmos() {
313-
if (!Spicetify.Player.origin?._cosmos) {
313+
if (!Spicetify.Player.origin?._cosmos && !Spicetify.Platform?.Registry) {
314314
setTimeout(addProxyCosmos, 50);
315315
return;
316316
}
317317

318+
const _cosmos = Spicetify.Player.origin?._cosmos ?? Spicetify.Platform?.Registry._map.get(Symbol.for("Cosmos")).instance;
319+
318320
const corsProxyURL = "https://cors-proxy.spicetify.app";
319321
const allowedMethodsMap = {
320322
get: "get",
@@ -394,7 +396,7 @@ window.Spicetify = {
394396
}
395397
};
396398

397-
Spicetify.Player.origin._cosmos = new Proxy(Spicetify.Player.origin._cosmos, handler);
399+
Spicetify.Player.origin._cosmos = new Proxy(_cosmos, handler);
398400
Object.defineProperty(Spicetify, "CosmosAsync", {
399401
get: () => {
400402
return Spicetify.Player.origin?._cosmos;
@@ -697,6 +699,13 @@ window.Spicetify = {
697699
}
698700
});
699701

702+
const confirmDialogChunk = chunks.find(
703+
([, value]) => value.toString().includes("confirmDialog") && value.toString().includes("shouldCloseOnEsc") && value.toString().includes("isOpen")
704+
);
705+
if (!Spicetify.ReactComponent?.ConfirmDialog && confirmDialogChunk) {
706+
Spicetify.ReactComponent.ConfirmDialog = Object.values(require(confirmDialogChunk[0])).find(m => typeof m === "object");
707+
}
708+
700709
const contextMenuChunk = chunks.find(([, value]) => value.toString().includes("toggleContextMenu"));
701710
if (contextMenuChunk) {
702711
Spicetify.ReactComponent.ContextMenu = Object.values(require(contextMenuChunk[0])).find(m => typeof m === "function");

0 commit comments

Comments
 (0)