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
+14 -2
View File
@@ -403,6 +403,14 @@
() => 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) => {
if (data.messageChannel && data.messageChannel != this.primaryChannel.value)
@@ -729,7 +737,6 @@
newChatPrimaryChannel: "Primary channel",
newChatNamePlaceholder: "my-channel",
addChat: "Add",
removeChat: "Remove chat",
// messages
showChatOptions: "show chat options",
configureChatTitle: "Configure Chat",
@@ -741,6 +748,7 @@
removeSecondaryChannel: "Remove secondary channel",
encryptionKey: "Encryption key",
encryptionKeyPlaceholder: "n10d2482dg283hg",
removeChat: "Remove chat",
noChatSelected: "No chat selected",
composerPlaceholder: "Type a message...",
sendMessage: "Send",
@@ -759,6 +767,10 @@
function closeModal() {
isPresented.value = false;
}
function deleteChat() {
chat.deleteSelf();
closeModal();
}
const secondaryChannelConverter = (secondaryChannel) => {
function remove() {
chat.removeSecondaryChannel(secondaryChannel);
@@ -830,7 +842,7 @@
placeholder: translation.encryptionKeyPlaceholder,
"bind:value": chat.encryptionKey
}
)))), /* @__PURE__ */ createElement("button", { class: "danger", "on:click": closeModal }, translation.close, /* @__PURE__ */ createElement("span", { class: "icon" }, "close"))));
))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("button", { class: "danger", "on:click": deleteChat }, translation.removeChat, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete"))), /* @__PURE__ */ createElement("button", { class: "danger", "on:click": closeModal }, translation.close, /* @__PURE__ */ createElement("span", { class: "icon" }, "close"))));
}
// src/Views/messageComposer.tsx