| 1 | import { Stack, useLocalSearchParams } from "expo-router"; |
| 2 | |
| 3 | import { Conversation } from "@/components/chat/conversation"; |
| 4 | import { Screen } from "@/components/ui"; |
| 5 | import { useChatSidebar } from "@/lib/chat"; |
| 6 | |
| 7 | /** A thread: the message it is under, its replies, and a box to reply in. */ |
| 8 | export default function ThreadScreen() { |
| 9 | const { channel, root } = useLocalSearchParams<{ channel: string; root: string }>(); |
| 10 | const sidebar = useChatSidebar(); |
| 11 | const entry = sidebar.data?.entries.find((one) => one.channel.id === channel); |
| 12 | const where = entry ? (entry.channel.kind === "dm" ? entry.title : `#${entry.channel.name}`) : ""; |
| 13 | return ( |
| 14 | <Screen> |
| 15 | <Stack.Screen options={{ title: where ? `Thread in ${where}` : "Thread" }} /> |
| 16 | <Conversation channelId={channel} thread={root} title={where} /> |
| 17 | </Screen> |
| 18 | ); |
| 19 | } |