update mailbox when chat channel changes

This commit is contained in:
marlon-erler
2024-07-09 20:20:25 +02:00
parent 41efa5cbf6
commit 036ade9db4
3 changed files with 12 additions and 3 deletions
+6
View File
@@ -473,6 +473,7 @@
if (this.cannotSetChannel.value == true) return; if (this.cannotSetChannel.value == true) return;
this.primaryChannel.value = this.primaryChannelInput.value; this.primaryChannel.value = this.primaryChannelInput.value;
UDN.subscribe(this.primaryChannel.value); UDN.subscribe(this.primaryChannel.value);
updateMailbox();
}; };
undoChannelChange = () => { undoChannelChange = () => {
this.primaryChannelInput.value = this.primaryChannel.value; this.primaryChannelInput.value = this.primaryChannel.value;
@@ -493,6 +494,7 @@
newChat.primaryChannelInput.value = name; newChat.primaryChannelInput.value = name;
chatIds.add(newChat.id); chatIds.add(newChat.id);
UDN.subscribe(name); UDN.subscribe(name);
updateMailbox();
} }
// node_modules/udn-frontend/index.ts // node_modules/udn-frontend/index.ts
@@ -681,6 +683,10 @@
if (cannotDeleteMailbox.value == true) return; if (cannotDeleteMailbox.value == true) return;
UDN.deleteMailbox(mailboxId.value); UDN.deleteMailbox(mailboxId.value);
} }
function updateMailbox() {
deleteMailbox();
setTimeout(() => requestMailbox(), 10);
}
UDN.onmailboxcreate = (id) => { UDN.onmailboxcreate = (id) => {
mailboxId.value = id; mailboxId.value = id;
UDN.connectMailbox(id); UDN.connectMailbox(id);
+3 -1
View File
@@ -1,6 +1,6 @@
import * as React from "bloatless-react"; 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 { decryptString, encryptString } from "../cryptUtility";
import { Message } from "udn-frontend"; import { Message } from "udn-frontend";
@@ -185,6 +185,7 @@ export class Chat {
if (this.cannotSetChannel.value == true) return; if (this.cannotSetChannel.value == true) return;
this.primaryChannel.value = this.primaryChannelInput.value; this.primaryChannel.value = this.primaryChannelInput.value;
UDN.subscribe(this.primaryChannel.value); UDN.subscribe(this.primaryChannel.value);
updateMailbox();
}; };
undoChannelChange = (): void => { undoChannelChange = (): void => {
@@ -213,4 +214,5 @@ export function createChatWithName(name: string): void {
chatIds.add(newChat.id); chatIds.add(newChat.id);
UDN.subscribe(name); UDN.subscribe(name);
updateMailbox();
} }
+3 -2
View File
@@ -15,7 +15,8 @@ export const didRequestConnection = React.restoreState(
false false
); );
export const currentAddress = React.restoreState("current-address", ""); export const currentAddress = React.restoreState("current-address", "");
export const previousAddresses = React.restoreListState<string>("previous-addresses") export const previousAddresses =
React.restoreListState<string>("previous-addresses");
export const cannotDisonnect = React.createProxyState( export const cannotDisonnect = React.createProxyState(
[isConnected], [isConnected],
@@ -106,7 +107,7 @@ export function deleteMailbox(): void {
export function updateMailbox(): void { export function updateMailbox(): void {
deleteMailbox(); deleteMailbox();
updateMailbox(); setTimeout(() => requestMailbox(), 10);
} }
UDN.onmailboxcreate = (id) => { UDN.onmailboxcreate = (id) => {