mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-15 02:35:42 +00:00
Update SpotifyPlayer
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m39s
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m39s
This commit is contained in:
parent
4bbe6a4ebf
commit
66951af066
@ -1,11 +1,11 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import useSWR from 'swr'
|
import useSWR, {useSWRConfig} from 'swr'
|
||||||
import fetcher from '@/lib/fetcher'
|
import fetcher from '@/lib/fetcher'
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import {useEffect, ReactElement, ElementType} from 'react'
|
import {ElementType, ReactElement, useEffect} from 'react'
|
||||||
import {animate} from 'motion'
|
import {animate} from 'motion'
|
||||||
|
|
||||||
type Status = {
|
type Status = {
|
||||||
@ -110,8 +110,11 @@ type PlayerStateResponse = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function usePlayerState(path: string) {
|
function usePlayerState(path: string) {
|
||||||
|
const {mutate} = useSWRConfig()
|
||||||
const {data, error, isLoading} = useSWR(`/api/spotify/${path}`, fetcher) as PlayerStateResponse
|
const {data, error, isLoading} = useSWR(`/api/spotify/${path}`, fetcher) as PlayerStateResponse
|
||||||
|
|
||||||
|
mutate(`/api/spotify/${path}`, data).then(r => r)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
song: data,
|
song: data,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
Loading…
Reference in New Issue
Block a user