From 036ade9db4979068f3d327e5585e370dd570d5b0 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Tue, 9 Jul 2024 20:20:25 +0200 Subject: [PATCH] update mailbox when chat channel changes --- dist/index.js | 6 ++++++ src/Model/chatModel.ts | 4 +++- src/Model/model.ts | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4514b807..ecf84d58 100644 --- a/dist/index.js +++ b/dist/index.js @@ -473,6 +473,7 @@ if (this.cannotSetChannel.value == true) return; this.primaryChannel.value = this.primaryChannelInput.value; UDN.subscribe(this.primaryChannel.value); + updateMailbox(); }; undoChannelChange = () => { this.primaryChannelInput.value = this.primaryChannel.value; @@ -493,6 +494,7 @@ newChat.primaryChannelInput.value = name; chatIds.add(newChat.id); UDN.subscribe(name); + updateMailbox(); } // node_modules/udn-frontend/index.ts @@ -681,6 +683,10 @@ if (cannotDeleteMailbox.value == true) return; UDN.deleteMailbox(mailboxId.value); } + function updateMailbox() { + deleteMailbox(); + setTimeout(() => requestMailbox(), 10); + } UDN.onmailboxcreate = (id) => { mailboxId.value = id; UDN.connectMailbox(id); diff --git a/src/Model/chatModel.ts b/src/Model/chatModel.ts index 47095329..159d6a07 100644 --- a/src/Model/chatModel.ts +++ b/src/Model/chatModel.ts @@ -1,6 +1,6 @@ import * as React from "bloatless-react"; -import { UDN, chatIds, chats, isConnected, senderName } from "../Model/model"; +import { UDN, chatIds, chats, isConnected, senderName, updateMailbox } from "../Model/model"; import { decryptString, encryptString } from "../cryptUtility"; import { Message } from "udn-frontend"; @@ -185,6 +185,7 @@ export class Chat { if (this.cannotSetChannel.value == true) return; this.primaryChannel.value = this.primaryChannelInput.value; UDN.subscribe(this.primaryChannel.value); + updateMailbox(); }; undoChannelChange = (): void => { @@ -213,4 +214,5 @@ export function createChatWithName(name: string): void { chatIds.add(newChat.id); UDN.subscribe(name); + updateMailbox(); } diff --git a/src/Model/model.ts b/src/Model/model.ts index c8bf2d96..69721189 100644 --- a/src/Model/model.ts +++ b/src/Model/model.ts @@ -15,7 +15,8 @@ export const didRequestConnection = React.restoreState( false ); export const currentAddress = React.restoreState("current-address", ""); -export const previousAddresses = React.restoreListState("previous-addresses") +export const previousAddresses = + React.restoreListState("previous-addresses"); export const cannotDisonnect = React.createProxyState( [isConnected], @@ -106,7 +107,7 @@ export function deleteMailbox(): void { export function updateMailbox(): void { deleteMailbox(); - updateMailbox(); + setTimeout(() => requestMailbox(), 10); } UDN.onmailboxcreate = (id) => {