Skip to content

Commit

Permalink
Cleans up some logic
Browse files Browse the repository at this point in the history
  • Loading branch information
skycube19 committed Sep 10, 2024
1 parent 8d82aca commit 4a3ae02
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/components/DynamicRecommendations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,26 @@ class DynamicRecommendations extends React.Component<{}, {songQueue: Array<strin
});
};

setArtistQueue = () => {
shouldArtistQueueBeUpdated = (): boolean => {
if (!Spicetify.Player.data.item.artists) {
return;
return false;
}
if (!this.state.artistQueue) {
return true;
}

let cont = false;
if (this.state.artistQueue) {
for (const artist of Spicetify.Player.data.item.artists) {
let fromIndex = this.state.artistQueue.length >= Spicetify.Player.data.item.artists.length ? this.state.artistQueue.length - Spicetify.Player.data.item.artists.length : 0;
if (!this.state.artistQueue.includes(getID(artist.uri), fromIndex)) {
cont = true;
break;
};
}
for (const artist of Spicetify.Player.data.item.artists) {
let fromIndex = Math.max(0, this.state.artistQueue.length - Spicetify.Player.data.item.artists.length);
if (!this.state.artistQueue.includes(getID(artist.uri), fromIndex)) {
return true;
};
}
if (!cont) {

return false;
};

setArtistQueue = () => {
if (!Spicetify.Player.data.item.artists || !this.shouldArtistQueueBeUpdated()) {
return;
}

Expand Down

0 comments on commit 4a3ae02

Please sign in to comment.