From 8ac6ad3ea726e4d521cee619fc72156f9a6d9afd Mon Sep 17 00:00:00 2001 From: ririxi Date: Tue, 7 May 2024 21:00:20 +0200 Subject: [PATCH] fix(wrapper/platform): assign product state to old prop (#3011) --- jsHelper/spicetifyWrapper.js | 37 ++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index 7fef3c74e8..2a44c3a703 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -273,7 +273,20 @@ window.Spicetify = { { objectToCheck: Spicetify.ReactComponent.Cards, name: "Spicetify.ReactComponent.Cards", - methods: new Set(["Default", "Hero", "CardImage", "Album", "Artist", "Audiobook", "Episode", "Playlist", "Profile", "Show", "Track"]) + methods: new Set([ + "Default", + "Hero", + "CardImage", + "Album", + "Artist", + "Audiobook", + "Episode", + "Playlist", + "Profile", + "Show", + "Track", + "FeatureCard" + ]) }, { objectToCheck: Spicetify.ReactHook, @@ -921,6 +934,23 @@ Spicetify.Events = (() => { playerState.cache = playerState.current; }); + (function waitProductStateAPI() { + if (!Spicetify.Platform?.UserAPI) { + setTimeout(waitProductStateAPI, 100); + return; + } + + const productState = Spicetify.Platform.UserAPI._product_state || Spicetify.Platform.UserAPI._product_state_service; + if (productState) return; + if (!Spicetify.Platform?.ProductStateAPI) { + setTimeout(waitProductStateAPI, 100); + return; + } + + const productStateApi = Spicetify.Platform.ProductStateAPI.productStateApi; + Spicetify.Platform.UserAPI._product_state_service = productStateApi; + })(); + setInterval(() => { if (playerState.cache?.isPaused === false) { const event = new Event("onprogress"); @@ -1370,7 +1400,10 @@ Spicetify.SVGIcons = { let subRequest; // product_state was renamed to product_state_service in Spotify 1.2.21 - const productState = Spicetify.Platform.UserAPI?._product_state || Spicetify.Platform.UserAPI?._product_state_service; + const productState = + Spicetify.Platform.UserAPI?._product_state || + Spicetify.Platform.UserAPI?._product_state_service || + Spicetify.Platform?.ProductStateAPI.productStateApi; Spicetify.AppTitle = { set: async name => {