diff --git a/platforms/blabsy/src/components/chat/chat-window.tsx b/platforms/blabsy/src/components/chat/chat-window.tsx index 140cabee1..38dec5465 100644 --- a/platforms/blabsy/src/components/chat/chat-window.tsx +++ b/platforms/blabsy/src/components/chat/chat-window.tsx @@ -1,13 +1,15 @@ import { useEffect, useRef, useState } from 'react'; import { useChat } from '@lib/context/chat-context'; import { useAuth } from '@lib/context/auth-context'; +import { useWindow } from '@lib/context/window-context'; import { formatDistanceToNow, set } from 'date-fns'; import type { Message } from '@lib/types/message'; import { getChatType } from '@lib/types/chat'; import { UserIcon, PaperAirplaneIcon, - Cog6ToothIcon + Cog6ToothIcon, + ArrowLeftIcon } from '@heroicons/react/24/outline'; import Image from 'next/image'; import { doc, getDoc } from 'firebase/firestore'; @@ -140,9 +142,10 @@ function MessageItem({ } export function ChatWindow(): JSX.Element { - const { currentChat, messages, sendNewMessage, markAsRead, loading } = + const { currentChat, messages, sendNewMessage, markAsRead, loading, setCurrentChat } = useChat(); const { user } = useAuth(); + const { isMobile } = useWindow(); const [messageText, setMessageText] = useState(''); const messagesEndRef = useRef(null); const [otherUser, setOtherUser] = useState(null); @@ -269,6 +272,15 @@ export function ChatWindow(): JSX.Element { <>
+ {isMobile && ( + + )}
{currentChat.type === 'group' ? ( currentChat.photoURL ? ( diff --git a/platforms/blabsy/src/components/chat/chat.tsx b/platforms/blabsy/src/components/chat/chat.tsx index 1b7d24afb..bd4789b3d 100644 --- a/platforms/blabsy/src/components/chat/chat.tsx +++ b/platforms/blabsy/src/components/chat/chat.tsx @@ -1,11 +1,34 @@ +import { useWindow } from '@lib/context/window-context'; +import { useChat } from '@lib/context/chat-context'; import { ChatList } from './chat-list'; import { ChatWindow } from './chat-window'; export function Chat(): JSX.Element { + const { isMobile } = useWindow(); + const { currentChat } = useChat(); + + // On mobile, show only chat list or chat window based on selection + if (isMobile) { + return ( +
+ {currentChat ? ( +
+ +
+ ) : ( +
+ +
+ )} +
+ ); + } + + // On desktop, show both in grid layout return (
-
+