import { ChatListItem } from '@components/chats/chatListItem'; import { ChatModal } from '@components/chats/chatModal'; import { ImageWithFallback } from '@components/imageWithFallback'; import { DEFAULT_AVATAR } from '@stores/constants'; import useLocalStorage from '@rehooks/local-storage'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; export default function ChatList() { const router = useRouter(); const [activeAccount]: any = useLocalStorage('activeAccount'); const accountProfile = JSON.parse(activeAccount.metadata); const [list, setList] = useState([]); const openSelfChat = () => { router.push({ pathname: '/chats/[pubkey]', query: { pubkey: activeAccount.pubkey }, }); }; useEffect(() => { const fetchChats = async () => { const { getChats } = await import('@utils/bindings'); return await getChats({ account_id: activeAccount.id }); }; fetchChats() .then((res) => setList(res)) .catch(console.error); }, [activeAccount.id]); return (
openSelfChat()} className="inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 hover:bg-zinc-900" >
{accountProfile.display_name || accountProfile.name} (you)
{list.map((item) => ( ))}
); }