import ChannelView from '@/components/Chat/ChannelView' import { Button } from '@/components/ui/button' import { Titlebar } from '@/components/Titlebar' import { useSecondaryPage } from '@/PageManager' import { useChat } from '@/providers/ChatProvider' import { TPageRef } from '@/types' import { ChevronLeft } from 'lucide-react' import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react' interface ChatChannelPageProps { channelId?: string } const ChatChannelPage = forwardRef( ({ channelId }, ref) => { const layoutRef = useRef(null) const { selectChannelById } = useChat() const { pop } = useSecondaryPage() useImperativeHandle(ref, () => layoutRef.current as TPageRef) // Select the channel when this page mounts useEffect(() => { if (channelId) { selectChannelById(channelId) } }, [channelId, selectChannelById]) // Clear channel selection when page unmounts useEffect(() => { return () => { selectChannelById(null) } }, []) const handleBack = () => { selectChannelById(null) pop() } return (
) } ) ChatChannelPage.displayName = 'ChatChannelPage' export default ChatChannelPage