Skip to content

Commit

Permalink
Merge pull request #4 from abecerrilsalas/Monday
Browse files Browse the repository at this point in the history
fixing the too long delay for Get Recommendations
  • Loading branch information
abecerrilsalas authored Aug 12, 2024
2 parents 3333282 + cdc08a9 commit 6a9d08c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ const Playlist = () => {
}
if (spotifyLink) {
setLoading(true);
setTimeout(() => {
setLoading(false);
setShowPlaylist(true);
}, 5000);
setShowPlaylist(true);
setLoading(false);
}
}, [fetchHistory, spotifyLink, initialHistory]);

Expand All @@ -90,11 +88,11 @@ const Playlist = () => {

if (response.data.spotify_link) {
setCurrentSpotifyLink(response.data.spotify_link);
fetchHistory(); // Immediately fetch updated history
setTimeout(() => {
setLoading(false);
setShowPlaylist(true);
}, 5000);
await fetchHistory(); // Fetch updated history after new recommendation
}, 1000); // Reduced to 1 second
} else {
setError(
"Failed to fetch recommendations. No Spotify link found in the response."
Expand Down

0 comments on commit 6a9d08c

Please sign in to comment.