import ChannelList from '@/components/Chat/ChannelList' import ChannelView from '@/components/Chat/ChannelView' import InboxContent from '@/components/Inbox/InboxContent' import PrimaryPageLayout from '@/layouts/PrimaryPageLayout' import { cn } from '@/lib/utils' import { useDM } from '@/providers/DMProvider' import { useNostr } from '@/providers/NostrProvider' import { TPageRef } from '@/types' import { Hash, LogIn, MessageCircle, MessageSquare } from 'lucide-react' import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { usePrimaryPage } from '@/PageManager' import { Button } from '@/components/ui/button' import { useChat } from '@/providers/ChatProvider' type ChatTab = 'dms' | 'channels' const ChatPage = forwardRef((_, ref) => { const { t } = useTranslation() const layoutRef = useRef(null) const { pubkey } = useNostr() const { navigate } = usePrimaryPage() const { markInboxAsSeen } = useDM() const [activeTab, setActiveTab] = useState('dms') useImperativeHandle(ref, () => layoutRef.current as TPageRef) useEffect(() => { if (pubkey && activeTab === 'dms') { markInboxAsSeen() } }, [pubkey, activeTab, markInboxAsSeen]) const { refreshChannels } = useChat() useEffect(() => { if (activeTab === 'channels') { refreshChannels() } }, [activeTab, refreshChannels]) return ( } > {pubkey ? ( activeTab === 'dms' ? ( ) : (
) ) : (

{t('Sign in to chat')}

{t('Direct messages and public channels')}

)}
) }) ChatPage.displayName = 'ChatPage' export default ChatPage function ChatTitlebar({ activeTab, onTabChange }: { activeTab: ChatTab onTabChange: (tab: ChatTab) => void }) { const { t } = useTranslation() const { hasNewMessages } = useDM() const { hasUnreadChannels } = useChat() return (
{t('Chat')}
) }