Update SpotifyPlayer
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m39s

This commit is contained in:
Ryan Freeman 2024-09-27 21:02:51 +01:00
parent 4bbe6a4ebf
commit 66951af066

View File

@ -1,11 +1,11 @@
'use client'
import useSWR from 'swr'
import useSWR, {useSWRConfig} from 'swr'
import fetcher from '@/lib/fetcher'
import Image from 'next/image'
import Link from 'next/link'
import clsx from 'clsx'
import {useEffect, ReactElement, ElementType} from 'react'
import {ElementType, ReactElement, useEffect} from 'react'
import {animate} from 'motion'
type Status = {
@ -110,8 +110,11 @@ type PlayerStateResponse = {
}
function usePlayerState(path: string) {
const {mutate} = useSWRConfig()
const {data, error, isLoading} = useSWR(`/api/spotify/${path}`, fetcher) as PlayerStateResponse
mutate(`/api/spotify/${path}`, data).then(r => r)
return {
song: data,
isLoading,