import { Message } from "@/components/Chat/Message";
import { Loading } from "@/components/primitives/Loading";
import { Text } from "@/components/primitives/Text";
import { useFacet } from "@/lib/facet";
import { useChannel } from "@/lib/hooks/useChannel";
import type { AtUri } from "@/lib/types/atproto";
import { useChannelRecordByAtUriObject } from "@/providers/authed/ChannelsProvider";
import { useProfile } from "@/providers/authed/ProfileProvider";
import { useCurrentPalette } from "@/providers/ThemeProvider";
import { ArrowUp, Dot, Hash } from "lucide-react-native";
import { useState } from "react";
import { View, TextInput, FlatList, Pressable } from "react-native";
export const Chat = ({ channelAtUri }: { channelAtUri: AtUri }) => {
const [inputText, setInputText] = useState("");
const record = useChannelRecordByAtUriObject(channelAtUri);
const { semantic } = useCurrentPalette();
const { typography, atoms } = useFacet();
const channel = useChannel(channelAtUri);
const { isLoading } = useProfile();
if (!channel) return <>>;
const { messages, sendMessageToChannel, isConnected } = channel;
const handleSend = () => {
if (inputText.trim()) {
sendMessageToChannel(inputText);
setInputText("");
}
};
if (!record)
return (
Something has gone wrong.Could not resolve channel record
from given at:// URI.
);
return isLoading ? (
) : (
{record.channel.name}
{record.channel.topic}
}
keyExtractor={(_, index) => index.toString()}
contentContainerStyle={{
paddingLeft: 20,
flex: 1,
gap: 2,
}}
showsVerticalScrollIndicator={false}
/>
);
};