From 202c2728639f33c714b68956de86242f228e634c Mon Sep 17 00:00:00 2001 From: Paul Scharnofske Date: Sun, 2 Oct 2022 17:03:27 +0200 Subject: [PATCH] Resolve infinite loop when artists (indirectly) are related to themselves This is a stupid error, and I already knew about it but wanted to address it later. --- src/providers/ArtistProvider.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/providers/ArtistProvider.js b/src/providers/ArtistProvider.js index ef6d258..5b20025 100644 --- a/src/providers/ArtistProvider.js +++ b/src/providers/ArtistProvider.js @@ -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,