From 031cfb0ad3193f3667d6d039f3563ab94af3e2e6 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Tue, 9 Jul 2024 03:32:22 +0200 Subject: [PATCH] fix mailbox update --- dist/index.js | 6 ++++++ src/model.ts | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6c5eb29b..004985d8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -617,6 +617,11 @@ function deleteMailbox() { UDN.deleteMailbox(mailboxId.value); } + function updateMailbox() { + if (!isMailboxConnected || mailboxId.value == "") return; + deleteMailbox(); + requestMailbox(); + } async function sendMessage() { if (cannotSendMessage.value == true) return; const secondaryChannelNames = [ @@ -651,6 +656,7 @@ UDN.unsubscribe(currentPrimaryChannel.value); } UDN.subscribe(primaryChannel.value); + updateMailbox(); } function leaveChannel() { if (cannotLeaveChannel.value == true) return; diff --git a/src/model.ts b/src/model.ts index 2caa72a8..fdd5e253 100644 --- a/src/model.ts +++ b/src/model.ts @@ -146,7 +146,8 @@ export function deleteMailbox(): void { } export function updateMailbox(): void { - if (!isMailboxConnected) return; + if (!isMailboxConnected || mailboxId.value == "") return; + deleteMailbox(); requestMailbox(); } @@ -201,7 +202,7 @@ export function setChannel(): void { UDN.unsubscribe(currentPrimaryChannel.value); } UDN.subscribe(primaryChannel.value); - + updateMailbox(); } @@ -239,7 +240,7 @@ UDN.onconnect = () => { } }; -UDN.onmailboxcreate = (id) => { +UDN.onmailboxcreate = (id) => { mailboxId.value = id; UDN.connectMailbox(id); };