From 819c8f4cacb0789ff63346dbd569c2395209145c Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Sat, 20 Jul 2024 20:48:13 +0200 Subject: [PATCH] add button to remove chat --- dist/index.js | 11 +++++++++-- dist/styles.css | 4 ++++ src/View/ChatPages/settingsPage.tsx | 7 +++++++ src/View/translations.ts | 2 ++ src/ViewModel/chatListViewModel.tsx | 1 + src/ViewModel/chatViewModel.tsx | 6 ++++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index dcae65ff..88be1576 100644 --- a/dist/index.js +++ b/dist/index.js @@ -665,6 +665,11 @@ this.color.value = newColor; this.chatModel.setColor(newColor); }; + remove = () => { + this.close(); + this.chatModel.delete(); + this.chatListViewModel.restoreChats(); + }; // restore restorePageSelection = () => { const path = storageKeys.chatLastUsedPage(this.chatModel.id); @@ -748,6 +753,7 @@ }; // restore restoreChats = () => { + this.chatViewModels.clear(); for (const chatModel of this.chatListModel.chatModels.values()) { const chatViewModel = this.createChatViewModel(chatModel); this.chatViewModels.add(chatViewModel); @@ -859,7 +865,8 @@ addSecondaryChannelButtonAudioLabel: "add secondary channel", encryptionKeyLabel: "Encryption key", setEncryptionKeyButtonAudioLabel: "set encryption key", - showEncryptionKey: "Show encryption key" + showEncryptionKey: "Show encryption key", + deleteChatButton: "Delete entire chat" } } }; @@ -971,7 +978,7 @@ "on:click": setColor } ); - })))); + })), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("button", { class: "danger width-input flex-no", "on:click": chatViewModel.remove }, translations.chatPage.settings.deleteChatButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete_forever")))); } // src/View/chatPage.tsx diff --git a/dist/styles.css b/dist/styles.css index 187f9ff6..70a696e2 100644 --- a/dist/styles.css +++ b/dist/styles.css @@ -798,6 +798,10 @@ header button { max-height: 100% !important; } +button:not(.tile):not(header *), +footer, +input:not([type="checkbox"]):not([type="radio"]), +select, .modal > div > :is(button, div.flex-row) { min-height: var(--control-height); } diff --git a/src/View/ChatPages/settingsPage.tsx b/src/View/ChatPages/settingsPage.tsx index 93f861fd..fd8accf9 100644 --- a/src/View/ChatPages/settingsPage.tsx +++ b/src/View/ChatPages/settingsPage.tsx @@ -135,6 +135,13 @@ export function SettingsPage(chatViewModel: ChatViewModel) { ); })} + +
+ + ); diff --git a/src/View/translations.ts b/src/View/translations.ts index 053161c8..fab0f977 100644 --- a/src/View/translations.ts +++ b/src/View/translations.ts @@ -95,6 +95,8 @@ const englishTranslations = { encryptionKeyLabel: "Encryption key", setEncryptionKeyButtonAudioLabel: "set encryption key", showEncryptionKey: "Show encryption key", + + deleteChatButton: "Delete entire chat", }, }, }; diff --git a/src/ViewModel/chatListViewModel.tsx b/src/ViewModel/chatListViewModel.tsx index 7dc9d642..25a745c4 100644 --- a/src/ViewModel/chatListViewModel.tsx +++ b/src/ViewModel/chatListViewModel.tsx @@ -63,6 +63,7 @@ export default class ChatListViewModel { // restore restoreChats = (): void => { + this.chatViewModels.clear(); for (const chatModel of this.chatListModel.chatModels.values()) { const chatViewModel = this.createChatViewModel(chatModel); this.chatViewModels.add(chatViewModel); diff --git a/src/ViewModel/chatViewModel.tsx b/src/ViewModel/chatViewModel.tsx index a05cb7d3..4a147797 100644 --- a/src/ViewModel/chatViewModel.tsx +++ b/src/ViewModel/chatViewModel.tsx @@ -96,6 +96,12 @@ export default class ChatViewModel { this.chatModel.setColor(newColor); }; + remove = (): void => { + this.close(); + this.chatModel.delete(); + this.chatListViewModel.restoreChats(); + } + // restore restorePageSelection = (): void => { const path: string[] = storageKeys.chatLastUsedPage(this.chatModel.id);