Skip to content

Commit

Permalink
Resolve infinite loop when artists (indirectly) are related to themse…
Browse files Browse the repository at this point in the history
…lves

This is a stupid error, and I already knew about it but wanted to
address it later.
  • Loading branch information
asynts committed Oct 2, 2022
1 parent aac76f5 commit 202c272
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/providers/ArtistProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export function ArtistProvider(props) {

let relatedArtists = await server.fetchRelatedArtistsAsync(artist.id);

// Prevent infinite loop where artists are directly or indirectly related to themselves.
// We simply sort out artists that are already known to us.
relatedArtists = relatedArtists.filter(artist => !(artist.id in state.artists));

dispatch({
type: actions.LOAD_ARTISTS_IF_NOT_EXIST,
payload: relatedArtists,
Expand Down

0 comments on commit 202c272

Please sign in to comment.