update chats

This commit is contained in:
Ren Amamiya
2023-06-26 12:12:43 +07:00
parent 7fb62a6afa
commit b2dd231f00
4 changed files with 51 additions and 22 deletions

View File

@@ -45,7 +45,7 @@ export function ChatsListItem({ data }: { data: any }) {
</h5>
</div>
<div className="flex items-center">
{data.new_messages && (
{data.new_messages > 0 && (
<span className="inline-flex items-center justify-center rounded bg-fuchsia-400/10 w-8 px-1 py-1 text-xs font-medium text-fuchsia-500 ring-1 ring-inset ring-fuchsia-400/20">
{data.new_messages}
</span>

View File

@@ -15,13 +15,14 @@ export function ChatsList() {
} = useQuery(
["chats"],
async () => {
return await getChatsByPubkey(account.pubkey);
const chats = await getChatsByPubkey(account.pubkey);
const sorted = chats.sort(
(a, b) => parseInt(a.new_messages) - parseInt(b.new_messages),
);
return sorted;
},
{
enabled: account ? true : false,
refetchOnWindowFocus: false,
refetchOnMount: false,
refetchOnReconnect: false,
},
);