allow deleting chat

This commit is contained in:
marlon-erler
2024-07-09 17:32:51 +02:00
parent a2a135af0c
commit 1202789a43
4 changed files with 40 additions and 15 deletions
+11 -11
View File
@@ -86,11 +86,20 @@ export class Chat {
);
this.cannotUndoChannel = React.createProxyState(
[this.primaryChannelInput, this.primaryChannel],
() =>
this.primaryChannelInput.value == this.primaryChannel.value
() => this.primaryChannelInput.value == this.primaryChannel.value
);
}
// general
deleteSelf = () => {
Object.values(storageKeys).forEach((storageKey) => {
localStorage.removeItem(storageKey(this.id));
});
chats.remove(this);
chatIds.remove(this.id);
}
// handlers
onmessage = async (data: Message): Promise<void> => {
if (data.messageChannel && data.messageChannel != this.primaryChannel.value)
@@ -201,12 +210,3 @@ export function createChatWithName(name: string): void {
UDN.subscribe(name);
}
export function removeChat(chat: Chat): void {
Object.values(storageKeys).forEach((cb) => {
localStorage.removeItem(cb(chat.id));
});
chats.remove(chat);
chatIds.remove(chat.id);
}