diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/dm/+page.svelte | 14 |
1 files changed, 14 insertions, 0 deletions
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); |
