'use client'

import { useSyncExternalStore } from 'react'
import {
    getUnreadBadgeSnapshot,
    subscribeUnreadBadge,
} from '@/lib/notifications/unreadBadge'

/** 與 WS / API 同步的未讀紅點狀態（不依賴 Context，確保 Header 即時重繪） */
export function useUnreadBadge(): boolean {
    return useSyncExternalStore(
        subscribeUnreadBadge,
        getUnreadBadgeSnapshot,
        () => false
    )
}
