From 1baa0612d5fe9779a205db34564c2a10453ddc07 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Sat, 14 Feb 2026 11:03:08 -0500 Subject: Hide empty chats when unselected The only way these chats appear is if you add them, so if you leave them without sending a message, they are removed from the list. You can always add them again using the same way you got them. --- src/routes/(app)/dm/+page.svelte | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/routes/(app)/dm/+page.svelte b/src/routes/(app)/dm/+page.svelte index edc067d6..a0ad4f27 100644 --- a/src/routes/(app)/dm/+page.svelte +++ b/src/routes/(app)/dm/+page.svelte @@ -139,6 +139,16 @@ let canSendExpiring = $state(false); let nostrUserInfo: any = $state({}); + const selectedChatEmpty = () => !messageRumours || messageRumours.size == 0; + + const removeChat = (pubkey: string) => { + for (let i = 0; i < chats.length; i++) { + if (chats[i].pubkey === pubkey) { + chats.splice(i, 1); + } + } + }; + const includesPubkey = (chats: any[], pubkey: string) => { for (const c of chats) { if (c.pubkey === pubkey) { @@ -149,6 +159,10 @@ }; const selectChat = (c: any) => { + if (selectedChat && selectedChatEmpty()) { + removeChat(selectedChat.pubkey); + } + selectedChat = c; if (!includesPubkey(chats, c.pubkey)) { chats.unshift(c); -- cgit v1.2.3