fix: auto-refresh relative time on profiles page

This commit is contained in:
Memory 2026-03-01 22:50:47 +08:00 committed by GitHub
parent 9bbb495dae
commit 31bec33064
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,6 +59,7 @@ const Profiles: React.FC = () => {
const [updating, setUpdating] = useState(false)
const [fileOver, setFileOver] = useState(false)
const [url, setUrl] = useState('')
const [, setNow] = useState(new Date())
const isUrlEmpty = url.trim() === ''
const sensors = useSensors(useSensor(PointerSensor))
const { data: subs = [], mutate: mutateSubs } = useSWR(
@ -218,6 +219,11 @@ const Profiles: React.FC = () => {
}
}, [])
useEffect(() => {
const timer = setInterval(() => setNow(new Date()), 30000)
return () => clearInterval(timer)
}, [])
useEffect(() => {
setSortedItems(items)
}, [items])