feat/fix: implement WebSockets for NowPlaying, better data fetching with addl. Last.fm fetch, docker build fix
This commit is contained in:
parent
4cec7406c3
commit
7121ec926f
11 changed files with 514 additions and 175 deletions
36
components/widgets/LiveIndicator.tsx
Normal file
36
components/widgets/LiveIndicator.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import { connectSocket } from "@/lib/socket"
|
||||
|
||||
const LiveIndicator = () => {
|
||||
const [connected, setConnected] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const socket = connectSocket()
|
||||
|
||||
socket.on('connect', () => {
|
||||
setConnected(true)
|
||||
})
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
setConnected(false)
|
||||
})
|
||||
|
||||
return () => {
|
||||
socket.off('connect')
|
||||
socket.off('disconnect')
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-1 bg-black bg-opacity-50 rounded-full px-2 py-1">
|
||||
<div className={`w-1 h-1 rounded-full ${connected ? "bg-red-400 animate-pulse" : "bg-gray-400"}`}></div>
|
||||
<div className="text-white text-xs">
|
||||
{connected ? "LIVE" : "Connecting..."}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default LiveIndicator
|
||||
Loading…
Add table
Add a link
Reference in a new issue