Skip to content

Commit 8ac6ad3

Browse files
authored
fix(wrapper/platform): assign product state to old prop (#3011)
1 parent bf98eb4 commit 8ac6ad3

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

jsHelper/spicetifyWrapper.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,20 @@ window.Spicetify = {
273273
{
274274
objectToCheck: Spicetify.ReactComponent.Cards,
275275
name: "Spicetify.ReactComponent.Cards",
276-
methods: new Set(["Default", "Hero", "CardImage", "Album", "Artist", "Audiobook", "Episode", "Playlist", "Profile", "Show", "Track"])
276+
methods: new Set([
277+
"Default",
278+
"Hero",
279+
"CardImage",
280+
"Album",
281+
"Artist",
282+
"Audiobook",
283+
"Episode",
284+
"Playlist",
285+
"Profile",
286+
"Show",
287+
"Track",
288+
"FeatureCard"
289+
])
277290
},
278291
{
279292
objectToCheck: Spicetify.ReactHook,
@@ -921,6 +934,23 @@ Spicetify.Events = (() => {
921934
playerState.cache = playerState.current;
922935
});
923936

937+
(function waitProductStateAPI() {
938+
if (!Spicetify.Platform?.UserAPI) {
939+
setTimeout(waitProductStateAPI, 100);
940+
return;
941+
}
942+
943+
const productState = Spicetify.Platform.UserAPI._product_state || Spicetify.Platform.UserAPI._product_state_service;
944+
if (productState) return;
945+
if (!Spicetify.Platform?.ProductStateAPI) {
946+
setTimeout(waitProductStateAPI, 100);
947+
return;
948+
}
949+
950+
const productStateApi = Spicetify.Platform.ProductStateAPI.productStateApi;
951+
Spicetify.Platform.UserAPI._product_state_service = productStateApi;
952+
})();
953+
924954
setInterval(() => {
925955
if (playerState.cache?.isPaused === false) {
926956
const event = new Event("onprogress");
@@ -1370,7 +1400,10 @@ Spicetify.SVGIcons = {
13701400
let subRequest;
13711401

13721402
// product_state was renamed to product_state_service in Spotify 1.2.21
1373-
const productState = Spicetify.Platform.UserAPI?._product_state || Spicetify.Platform.UserAPI?._product_state_service;
1403+
const productState =
1404+
Spicetify.Platform.UserAPI?._product_state ||
1405+
Spicetify.Platform.UserAPI?._product_state_service ||
1406+
Spicetify.Platform?.ProductStateAPI.productStateApi;
13741407

13751408
Spicetify.AppTitle = {
13761409
set: async name => {

0 commit comments

Comments
 (0)