From b613bb9450b98dc98376c5aec45732e0c19a0bfd Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Tue, 9 Jul 2024 04:00:59 +0200 Subject: [PATCH] fix bug with mailbox --- dist/index.js | 9 ++++++--- src/model.ts | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 86c4abda..25c17b26 100644 --- a/dist/index.js +++ b/dist/index.js @@ -650,13 +650,15 @@ function deleteMessage(message) { messages.remove(message); } - function setChannel() { + function setChannel(shouldUpdateMailbox = true) { if (cannotSetChannel.value == true) return; if (currentPrimaryChannel != void 0) { UDN.unsubscribe(currentPrimaryChannel.value); } UDN.subscribe(primaryChannel.value); - updateMailbox(); + if (shouldUpdateMailbox) { + updateMailbox(); + } } function leaveChannel() { if (cannotLeaveChannel.value == true) return; @@ -677,7 +679,7 @@ } UDN.onconnect = () => { isConnected.value = true; - setChannel(); + setChannel(false); if (mailboxId.value != "") { UDN.connectMailbox(mailboxId.value); } @@ -687,6 +689,7 @@ UDN.connectMailbox(id); }; UDN.onmailboxconnect = () => { + console.log("connected"); isMailboxConnected.value = true; }; UDN.onmailboxdelete = () => { diff --git a/src/model.ts b/src/model.ts index 1fc22596..54a2f243 100644 --- a/src/model.ts +++ b/src/model.ts @@ -195,7 +195,7 @@ export function deleteMessage(message: Message): void { } // channels -export function setChannel(): void { +export function setChannel(shouldUpdateMailbox: boolean = true): void { if (cannotSetChannel.value == true) return; if (currentPrimaryChannel != undefined) { @@ -203,7 +203,9 @@ export function setChannel(): void { } UDN.subscribe(primaryChannel.value); - updateMailbox(); + if (shouldUpdateMailbox) { + updateMailbox(); + } } export function leaveChannel(): void { @@ -233,7 +235,7 @@ export async function decryptReceivedMessage(message: Message): Promise { // LISTENERS UDN.onconnect = () => { isConnected.value = true; - setChannel(); + setChannel(false); if (mailboxId.value != "") { UDN.connectMailbox(mailboxId.value); @@ -246,6 +248,7 @@ UDN.onmailboxcreate = (id) => { }; UDN.onmailboxconnect = () => { + console.log("connected") isMailboxConnected.value = true; };