Skip to content

Commit

Permalink
fix(wrapper/platform): assign product state to old prop (#3011)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri authored May 7, 2024
1 parent bf98eb4 commit 8ac6ad3
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 8ac6ad3

Please sign in to comment.