import { q } from "@thorium/context/AppContext"; import { useStation } from "@thorium/routes/station/useStation"; import Button from "@thorium/ui/Button"; import { InputField } from "@thorium/ui/Core"; import { Icon } from "@thorium/ui/Icon"; import Input from "@thorium/ui/Input"; import Select from "@thorium/ui/Select"; import { cn } from "@thorium/utils/cn"; import { useMemo, useState } from "react"; type Conversation = { sender: string; recipient: string; lastTimestamp: number; messages: { content: string; sender: string; timestamp: number }[]; }; export function MessagingCore() { const { shipId } = useStation(); const [messageGroups] = q.messaging.messageGroups.useNetRequest({ shipId }); const [ship] = q.ship.get.useNetRequest({ shipId }); const [selectedConversationDestination, setSelectedConversationDestination] = useState< string | null >(null); const [sender, setSender] = useState(""); const [alertSender, setAlertSender] = useState(false); const stations = ship?.stations.map((s) => s.name) || []; const conversations = useConversations(); const selectedConversation = conversations.find( (c) => c.recipient === selectedConversationDestination, ); return (