Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit 1f94d40

Browse files
committed
Fix bug where duplicate request for playlist color broke the extension
1 parent bc7d384 commit 1f94d40

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

dist/spicetify-playlist-labels.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/playlist.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
import {getContents, getPlaylistItems, getPlaylistColor} from "./api";
22

3+
const cachedPlaylistColors = {};
4+
35
export async function getTrackUriToPlaylistData() {
46
const contents = await getContents();
57
const playlists = contents.items.filter((item) => item.type === 'playlist');
68
const playlistItems = await Promise.all(playlists.map((playlist) => getPlaylistItems(playlist.uri)));
7-
const playlistColors = await Promise.all(playlists.map((playlist) => getPlaylistColor(playlist.uri)));
9+
const playlistColors = await Promise.all(playlists.map((playlist) => {
10+
if (cachedPlaylistColors[playlist.uri]) {
11+
return cachedPlaylistColors[playlist.uri];
12+
}
13+
return getPlaylistColor(playlist.uri);
14+
}));
15+
playlistColors.forEach((color, index) => {
16+
if (color)
17+
cachedPlaylistColors[playlists[index].uri] = color;
18+
});
819
const trackUritoPlaylistData = {};
920
playlistItems.forEach((playlistItems, index) => {
1021
playlistItems.forEach((playlistItem) => {

0 commit comments

Comments
 (0)