jbilcke-hf's picture
jbilcke-hf HF staff
fix
71fac81
raw
history blame contribute delete
607 Bytes
"use client"
import { useEffect, useTransition } from "react"
import { usePathname } from "next/navigation"
import { refreshStudio } from "@/server/actions"
export function RefreshStudio() {
const pathname = usePathname()
const [isPending, startTransition] = useTransition()
useEffect(() => {
const slug = `${pathname.split("/").pop()}`
setInterval(() => {
startTransition(() => {
try {
refreshStudio(slug)
} catch (err) {
// ignoring
}
})
}, 2000)
}, [pathname])
// TODO we could display a spinner here
return <></>
}