diff --git a/client-web/src/modules/chats/presentation/ChatPage.tsx b/client-web/src/modules/chats/presentation/ChatPage.tsx index 28205cb..1d1ce7b 100644 --- a/client-web/src/modules/chats/presentation/ChatPage.tsx +++ b/client-web/src/modules/chats/presentation/ChatPage.tsx @@ -65,6 +65,8 @@ export default function ChatPage() { const [activeTab, setActiveTab] = useState('chats'); const { t } = useLang(); + const activeChat = useChatStore((state) => state.activeChat); + useEffect(() => { groupCallOpenRef.current = groupCallOpen; groupCallChatIdRef.current = groupCallChatId; @@ -335,6 +337,16 @@ export default function ChatPage() { }; }, [user?.id]); + // Join chat group when activeChat changes + useEffect(() => { + if (activeChat) { + const socket = getSocket(); + if (socket) { + socket.emit('join_chat', activeChat); + } + } + }, [activeChat]); + const handleStartCall = (targetUser: UserBasic, type: 'voice' | 'video') => { setCallTarget(targetUser); setCallType(type); @@ -371,8 +383,6 @@ export default function ChatPage() { setGroupCallOpen(false); }; - const activeChat = useChatStore((state) => state.activeChat); - return (