mirror of
				https://github.com/r-freeman/portfolio.git
				synced 2025-11-03 23:31:11 +00:00 
			
		
		
		
	Update SpotifyPlayer.tsx
This commit is contained in:
		
							parent
							
								
									b8ce785bcc
								
							
						
					
					
						commit
						220af5ffa8
					
				@ -110,7 +110,13 @@ type PlayerStateResponse = {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function usePlayerState(path: string) {
 | 
					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 {
 | 
					    return {
 | 
				
			||||||
        song: data,
 | 
					        song: data,
 | 
				
			||||||
@ -188,8 +194,6 @@ Song.Skeleton = function SongSkeleton() {
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const revalidate = 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export function SpotifyPlayer(): ReactElement | null {
 | 
					export function SpotifyPlayer(): ReactElement | null {
 | 
				
			||||||
    const currentlyPlaying = usePlayerState('currently-playing')
 | 
					    const currentlyPlaying = usePlayerState('currently-playing')
 | 
				
			||||||
    const lastPlayed = usePlayerState('last-played')
 | 
					    const lastPlayed = usePlayerState('last-played')
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user