From e45bf1927eaf82f817c3333a20d0b55f2c307535 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:36:50 +0100 Subject: [PATCH] feat(mobile): add MobileChatScreen with back nav and member list access --- .../components/layout/MobileChatScreen.tsx | 86 +++++++++++++++++++ .../web/src/components/layout/MobileShell.tsx | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 packages/web/src/components/layout/MobileChatScreen.tsx diff --git a/packages/web/src/components/layout/MobileChatScreen.tsx b/packages/web/src/components/layout/MobileChatScreen.tsx new file mode 100644 index 00000000..69267cd3 --- /dev/null +++ b/packages/web/src/components/layout/MobileChatScreen.tsx @@ -0,0 +1,86 @@ +import React, { useEffect } from 'react'; +import { useUIStore } from '../../stores/uiStore'; +import { useChatStore } from '../../stores/chatStore'; +import { useSpaceStore } from '../../stores/spaceStore'; +import { useAuthStore } from '../../stores/authStore'; +import { MessageList } from '../chat/MessageList'; +import { MessageInput } from '../chat/MessageInput'; +import { TypingIndicator } from '../chat/TypingIndicator'; + +interface MobileChatScreenProps { + params?: Record; +} + +export function MobileChatScreen({ params }: MobileChatScreenProps) { + const popMobileScreen = useUIStore((s) => s.popMobileScreen); + const pushMobileScreen = useUIStore((s) => s.pushMobileScreen); + + const channelId = params?.channelId; + const spaceId = params?.spaceId; + const isDm = spaceId === '@me'; + + const loadMessages = useChatStore((s) => s.loadMessages); + const setCurrentChannel = useChatStore((s) => s.setCurrentChannel); + const channels = useSpaceStore((s) => s.channels); + const dmChannels = useSpaceStore((s) => s.dmChannels); + const authUser = useAuthStore((s) => s.user); + + useEffect(() => { + if (!channelId) return; + setCurrentChannel(channelId); + loadMessages(channelId); + }, [channelId, setCurrentChannel, loadMessages]); + + // Resolve channel/DM name + let channelName = 'Channel'; + if (isDm && channelId) { + const dm = dmChannels.find(d => d.id === channelId); + if (dm) { + const otherMembers = dm.members.filter(m => m.id !== authUser?.id); + const isGroup = dm.members.length > 2; + channelName = isGroup + ? otherMembers.map(m => m.displayName ?? m.username).join(', ') + : otherMembers[0]?.displayName ?? otherMembers[0]?.username ?? 'Direct Message'; + } + } else if (!isDm && channelId) { + const ch = channels.find(c => c.id === channelId); + channelName = ch?.name || 'channel'; + } + + return ( +
+ {/* Header */} +
+ +
+

+ {isDm ? channelName : `# ${channelName}`} +

+
+ {!isDm && ( + + )} +
+ + {/* Messages */} +
+ +
+ + {/* Typing indicator + Input */} + + +
+ ); +} diff --git a/packages/web/src/components/layout/MobileShell.tsx b/packages/web/src/components/layout/MobileShell.tsx index 010d5627..cd4a1e77 100644 --- a/packages/web/src/components/layout/MobileShell.tsx +++ b/packages/web/src/components/layout/MobileShell.tsx @@ -17,7 +17,7 @@ import { MobileSpacesScreen } from './MobileSpacesScreen'; // These will be replaced with real imports as each task is completed: const MobileDmsScreen = () => ; const MobileYouScreen = () => ; -const MobileChatScreen = ({ params: _params }: { params?: Record }) => ; +import { MobileChatScreen } from './MobileChatScreen'; const MobileSettingsScreen = ({ initialPanel: _p }: { initialPanel?: string }) => ; const MobileVoiceMiniBar = () => null; const MobileVoiceFullScreen = () => ;