From cb231c7770ab37f8fd31b6ce20c630d6b07e37bb Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 19 Oct 2025 13:57:15 +0700 Subject: [PATCH] put the split responsive messaging ui in a component of its own --- src/components/dm/MessagingInterface.tsx | 84 ++++++++++++++++++++++++ src/pages/Messages.tsx | 74 +-------------------- 2 files changed, 86 insertions(+), 72 deletions(-) create mode 100644 src/components/dm/MessagingInterface.tsx diff --git a/src/components/dm/MessagingInterface.tsx b/src/components/dm/MessagingInterface.tsx new file mode 100644 index 0000000..0f68994 --- /dev/null +++ b/src/components/dm/MessagingInterface.tsx @@ -0,0 +1,84 @@ +import { useState } from 'react'; +import { ConversationList } from '@/components/dm/ConversationList'; +import { ChatArea } from '@/components/dm/ChatArea'; +import { DMStatusInfo } from '@/components/dm/DMStatusInfo'; +import { useDMContext } from '@/contexts/DMContext'; +import { useIsMobile } from '@/hooks/useIsMobile'; +import { cn } from '@/lib/utils'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; + +interface MessagingInterfaceProps { + className?: string; +} + +export const MessagingInterface = ({ className }: MessagingInterfaceProps) => { + const [selectedPubkey, setSelectedPubkey] = useState(null); + const [statusModalOpen, setStatusModalOpen] = useState(false); + const isMobile = useIsMobile(); + const { clearCacheAndReload } = useDMContext(); + + // On mobile, show only one panel at a time + const showConversationList = !isMobile || !selectedPubkey; + const showChatArea = !isMobile || selectedPubkey; + + const handleSelectConversation = (pubkey: string) => { + setSelectedPubkey(pubkey); + }; + + const handleBack = () => { + setSelectedPubkey(null); + }; + + return ( + <> + {/* Status Modal */} + + + + Messaging Status + + View loading status, cache info, and connection details + + + + + + +
+ {/* Conversation List - Left Sidebar */} +
+ setStatusModalOpen(true)} + /> +
+ + {/* Chat Area - Right Panel */} +
+ +
+
+ + ); +}; + diff --git a/src/pages/Messages.tsx b/src/pages/Messages.tsx index d4c3f65..a691f37 100644 --- a/src/pages/Messages.tsx +++ b/src/pages/Messages.tsx @@ -1,86 +1,16 @@ -import { useState } from 'react'; import { useSeoMeta } from '@unhead/react'; -import { ConversationList } from '@/components/dm/ConversationList'; -import { ChatArea } from '@/components/dm/ChatArea'; -import { DMStatusInfo } from '@/components/dm/DMStatusInfo'; -import { useDMContext } from '@/contexts/DMContext'; -import { useIsMobile } from '@/hooks/useIsMobile'; -import { cn } from '@/lib/utils'; -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, -} from '@/components/ui/dialog'; +import { MessagingInterface } from '@/components/dm/MessagingInterface'; const Messages = () => { - const [selectedPubkey, setSelectedPubkey] = useState(null); - const [statusModalOpen, setStatusModalOpen] = useState(false); - const isMobile = useIsMobile(); - const { clearCacheAndReload } = useDMContext(); - useSeoMeta({ title: 'Messages', description: 'Private encrypted messaging on Nostr', }); - // On mobile, show only one panel at a time - const showConversationList = !isMobile || !selectedPubkey; - const showChatArea = !isMobile || selectedPubkey; - - const handleSelectConversation = (pubkey: string) => { - setSelectedPubkey(pubkey); - }; - - const handleBack = () => { - setSelectedPubkey(null); - }; - return (
- {/* Status Modal */} - - - - Messaging Status - - View loading status, cache info, and connection details - - - - - - -
- {/* Conversation List - Left Sidebar */} -
- setStatusModalOpen(true)} - /> -
- - {/* Chat Area - Right Panel */} -
- -
-
+
);