From 7abf06727408de3c076eb018a73bd4e27455a558 Mon Sep 17 00:00:00 2001 From: Parikshith Mohite Date: Fri, 27 Sep 2024 14:38:04 -0400 Subject: [PATCH] Clean up DynamicRecommendations render() --- src/components/DynamicRecommendations.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/DynamicRecommendations.tsx b/src/components/DynamicRecommendations.tsx index 336f826..309fd67 100644 --- a/src/components/DynamicRecommendations.tsx +++ b/src/components/DynamicRecommendations.tsx @@ -154,12 +154,16 @@ class DynamicRecommendations extends React.Component<{recTargetProp : string}, {
{function(recommendations : GetRecommendationsResponse | {}) { + if (Object.keys(recommendations).length == 0) { + return; + } + let recs = (recommendations as GetRecommendationsResponse)["tracks"]; let recommendedTracksHTML = []; for (let i = 0; i < 6; i++) { - let recommendedSong = 0 ? (recommendations as GetRecommendationsResponse)["tracks"][i].album.images[0].url : ""} - songAlbum={Object.keys(recommendations).length > 0 ? (recommendations as GetRecommendationsResponse)["tracks"][i].album.name : ""} - songName={Object.keys(recommendations).length > 0 ? (recommendations as GetRecommendationsResponse)["tracks"][i].name : ""} - songArtists={Object.keys(recommendations).length > 0 ? (recommendations as GetRecommendationsResponse)["tracks"][i].artists.map((artist) => artist.name):[]} + let recommendedSong = artist.name)} key={i}> ; recommendedTracksHTML.push(recommendedSong);