add basic thread view

This commit is contained in:
marlon-erler
2024-07-21 01:12:35 +02:00
parent 611b876509
commit c97b38dcd6
13 changed files with 359 additions and 87 deletions
+17 -5
View File
@@ -23,6 +23,8 @@ export default class ConnectionModel {
connectionChangeHandler: () => void = () => {};
messageHandler: (data: Message) => void = () => {};
channelsToSubscribe: Set<string> = new Set();
// connection
connect = (address: string): void => {
this.udn.connect(address);
@@ -39,16 +41,26 @@ export default class ConnectionModel {
handleConnectionChange = (): void => {
console.log("connection status:", this.isConnected, this.address);
this.connectionChangeHandler();
if (this.isConnected == false) return;
if (!this.address) return;
if (this.address) {
this.storeAddress(this.address);
}
this.storeAddress(this.address);
this.sendSubscriptionRequest();
this.sendMessagesInOutbox();
};
// subscription
addChannel = (channel: string): void => {
this.channelsToSubscribe.add(channel);
this.sendSubscriptionRequest();
};
sendSubscriptionRequest = (): void => {
for (const channel of this.channelsToSubscribe) {
this.udn.subscribe(channel);
}
};
// outbox
getOutboxMessags = (): ChatMessage[] => {
const outboxPath: string[] = storageKeys.outbox;