import { useState } from 'react'; import type { ChannelInfo, Share } from '@/core-bridge/types'; import { formatAgo, formatRemaining } from '@/lib/format'; import { useChannels } from '@/store/channels'; import { useShares } from '@/store/shares'; import { Button } from '@/ui/Button'; import { Icon } from '@/ui/Icon'; import styles from './ChannelList.module.css'; interface Props { kind: 'channel' | 'share'; title: string; onOpen: (c: ChannelInfo | Share) => void; /** 标题只给屏幕阅读器(所在分区已有标题) */ quietTitle?: boolean; } export function ChannelList({ kind, title, onOpen, quietTitle = false }: Props) { const channels = useChannels((s) => s.list); const forgetChannel = useChannels((s) => s.forget); const shares = useShares((s) => s.list); const forgetShare = useShares((s) => s.forget); const list = kind === 'share' ? shares : channels; const [confirmId, setConfirmId] = useState(); if (list.length === 0) return null; return (

{title}

); }