Skip to content

Commit

Permalink
fix: adapt Cosmos and ConfirmDialog for 1.2.41 (#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri authored Jul 3, 2024
1 parent abe53f6 commit 3207240
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ window.Spicetify = {
};

(function addProxyCosmos() {
if (!Spicetify.Player.origin?._cosmos) {
if (!Spicetify.Player.origin?._cosmos && !Spicetify.Platform?.Registry) {
setTimeout(addProxyCosmos, 50);
return;
}

const _cosmos = Spicetify.Player.origin?._cosmos ?? Spicetify.Platform?.Registry._map.get(Symbol.for("Cosmos")).instance;

const corsProxyURL = "https://cors-proxy.spicetify.app";
const allowedMethodsMap = {
get: "get",
Expand Down Expand Up @@ -394,7 +396,7 @@ window.Spicetify = {
}
};

Spicetify.Player.origin._cosmos = new Proxy(Spicetify.Player.origin._cosmos, handler);
Spicetify.Player.origin._cosmos = new Proxy(_cosmos, handler);
Object.defineProperty(Spicetify, "CosmosAsync", {
get: () => {
return Spicetify.Player.origin?._cosmos;
Expand Down Expand Up @@ -697,6 +699,13 @@ window.Spicetify = {
}
});

const confirmDialogChunk = chunks.find(
([, value]) => value.toString().includes("confirmDialog") && value.toString().includes("shouldCloseOnEsc") && value.toString().includes("isOpen")
);
if (!Spicetify.ReactComponent?.ConfirmDialog && confirmDialogChunk) {
Spicetify.ReactComponent.ConfirmDialog = Object.values(require(confirmDialogChunk[0])).find(m => typeof m === "object");
}

const contextMenuChunk = chunks.find(([, value]) => value.toString().includes("toggleContextMenu"));
if (contextMenuChunk) {
Spicetify.ReactComponent.ContextMenu = Object.values(require(contextMenuChunk[0])).find(m => typeof m === "function");
Expand Down

3 comments on commit 3207240

@rxri
Copy link
Member Author

@rxri rxri commented on 3207240 Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @russellbanks, am not sure if it's something up on our end or komac's that's why I'm mentioning you here, why does komac throw invalid Zip archive: Could not find central directory end error? All of the passed URLs are valid zip archives as per 7-Zip and were repackaged, still resulting in the same error. https://github.com/spicetify/cli/actions/runs/9784586579/job/27017137603

@russellbanks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rxri I haven't been able to reproduce this locally on Windows. However, the zip library Komac uses appears to have some fixes related to the central directory coming in the next version.

@rxri
Copy link
Member Author

@rxri rxri commented on 3207240 Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@russellbanks, I haven't been able to reproduce it on windows as well, that's why I'm manually doing winget releases now, but thanks for letting me know. I will wait for the update with those fixes from zip2 :)

Please sign in to comment.