Skip to content

Commit

Permalink
fix 277
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoMadera committed Mar 10, 2024
1 parent 0295839 commit 1d68a55
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,13 @@ export const getServerSideProps = (async (context) => {
const searchedPlaylistsPromises: Promise<
SpotifyApi.PlaylistObjectFull[] | null
>[] = [];
const artistNamesSearched = new Set<string>();

if (artistsOfTheWeekSettled) {
artistsOfTheWeekSettled.artists.artist.forEach((artist) => {
if (artistNamesSearched.has(artist.name)) return;
searchedArtistsPromises.push(searchArtist(artist.name, context));
artistNamesSearched.add(artist.name);
});
}

Expand Down Expand Up @@ -504,7 +507,12 @@ export const getServerSideProps = (async (context) => {
i <= searchedArtistsPromisesLenght &&
fullFilledItem[0]?.type === "artist"
) {
artistResult.push(fullFilledItem[0]);
const isDuplicate = artistResult.some(
(artist) => artist.id === fullFilledItem[0]?.id
);
if (!isDuplicate) {
artistResult.push(fullFilledItem[0]);
}
return;
}
const hasFulfilledItem = fullFilledItem?.[0];
Expand Down

0 comments on commit 1d68a55

Please sign in to comment.