From 9175c76d7f03c0c62323202fdab3e4ab35854855 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Fri, 9 Jan 2026 09:00:32 -0500 Subject: Hide muted chats --- src/routes/(app)/dm/+page.svelte | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/routes') diff --git a/src/routes/(app)/dm/+page.svelte b/src/routes/(app)/dm/+page.svelte index 32b39def..336733e0 100644 --- a/src/routes/(app)/dm/+page.svelte +++ b/src/routes/(app)/dm/+page.svelte @@ -10,6 +10,7 @@ import { getMessageRumours } from '$lib/nip17'; import * as libnip17 from '$lib/nip17'; import { npubEncode, decode } from 'nostr-tools/nip19'; + import { mutedAccounts } from '$lib/nip51'; import { sign, getPrivateKey, pTagKeys } from '$lib/nostr'; import { t } from "$lib/translations"; import { theme } from "$lib/store"; @@ -17,6 +18,9 @@ let { data } = $props(); const { user } = data; + let muted = $state(new Set()); + mutedAccounts(user).then((m) => muted = m); + /// chat selection const usernameFromPubkey = async (pubkey: string): string => { const response = await fetch(`/api/users/${pubkey}`); @@ -129,9 +133,18 @@ let canSendExpiring = $state(false); let nostrUserInfo = $state({}); + const includesPubkey = (chats: object[], pubkey: string) => { + for (const c of chats) { + if (c.pubkey === pubkey) { + return true; + } + } + return false; + } + const selectChat = (c: object) => { selectedChat = c; - if (!chats.includes(c)) { + if (!includesPubkey(chats, c.pubkey)) { chats.unshift(c); } userInfo(selectedChat.pubkey).then(info => nostrUserInfo = info); @@ -394,9 +407,11 @@ {/if} {#if !creatingNewChat} {#each chats as c} - + {#if (selectedChat && selectedChat.pubkey === c.pubkey) || !(muted && muted.has(c.pubkey))} + + {/if} {/each} {:else if searchQuery !== ""}