Remove redundant logs and store tracks properly

This commit is contained in:
Lei Nelissen
2020-07-06 16:56:23 +02:00
parent 5e8fb1de9f
commit 4476ac8e54
5 changed files with 4 additions and 8 deletions

View File

@@ -45,16 +45,16 @@ const Album: React.FC = () => {
const playAlbum = usePlayAlbum();
// Setup callbacks
const selectAlbum = useCallback(() => { playAlbum(id); }, [playAlbum]);
const selectAlbum = useCallback(() => { playAlbum(id); }, [playAlbum, id]);
const selectTrack = usePlayTrack();
const refresh = useCallback(() => { dispatch(fetchTracksByAlbum(id)); }, [id]);
const refresh = useCallback(() => { dispatch(fetchTracksByAlbum(id)); }, [id, dispatch]);
// Retrieve album tracks on load
useEffect(() => {
if (!album?.lastRefreshed || differenceInDays(album?.lastRefreshed, new Date()) > ALBUM_CACHE_AMOUNT_OF_DAYS) {
refresh();
}
}, []);
}, [album?.lastRefreshed, refresh]);
// GUARD: If there is no album, we cannot render a thing
if (!album) {