Update SpotifyPlayer.tsx

This commit is contained in:
Ryan Freeman 2023-09-11 19:51:09 +01:00 committed by GitHub
parent b8ce785bcc
commit 220af5ffa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,7 +110,13 @@ type PlayerStateResponse = {
}
function usePlayerState(path: string) {
const {data, error, isLoading} = useSWR(`/api/spotify/${path}`, fetcher) as PlayerStateResponse
const {data, error, isLoading} = useSWR(`/api/spotify/${path}`, fetcher, {
refreshInterval: 3600,
revalidateIfStale: true,
revalidateOnMount: true,
revalidateOnFocus: true,
revalidateOnReconnect true
}) as PlayerStateResponse
return {
song: data,
@ -188,8 +194,6 @@ Song.Skeleton = function SongSkeleton() {
)
}
export const revalidate = 0
export function SpotifyPlayer(): ReactElement | null {
const currentlyPlaying = usePlayerState('currently-playing')
const lastPlayed = usePlayerState('last-played')