This commit is contained in:
Ren Amamiya
2023-05-26 09:28:49 +07:00
parent 225179dd6d
commit 5c7b18bf29
41 changed files with 404 additions and 461 deletions

View File

@@ -2,16 +2,17 @@ import ChatsListItem from "@app/chat/components/item";
import ChatsListSelfItem from "@app/chat/components/self";
import { useActiveAccount } from "@utils/hooks/useActiveAccount";
import { getChats } from "@utils/storage";
import { getChatsByPubkey } from "@utils/storage";
import useSWR from "swr";
const fetcher = ([, account]) => getChats(account);
const fetcher = ([, pubkey]) => getChatsByPubkey(pubkey);
export default function ChatsList() {
const { account, isLoading, isError } = useActiveAccount();
const { data: chats, error }: any = useSWR(
!isLoading && !isError && account ? ["chats", account] : null,
!isLoading && !isError && account ? ["chats", account.pubkey] : null,
fetcher,
);
@@ -30,8 +31,8 @@ export default function ChatsList() {
</div>
</>
) : (
chats.map((item: { pubkey: string }) => (
<ChatsListItem key={item.pubkey} pubkey={item.pubkey} />
chats.map((item) => (
<ChatsListItem key={item.sender_pubkey} pubkey={item.sender_pubkey} />
))
)}
</div>