allow deleting chat
This commit is contained in:
Vendored
+14
-2
@@ -403,6 +403,14 @@
|
|||||||
() => 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
|
// handlers
|
||||||
onmessage = async (data) => {
|
onmessage = async (data) => {
|
||||||
if (data.messageChannel && data.messageChannel != this.primaryChannel.value)
|
if (data.messageChannel && data.messageChannel != this.primaryChannel.value)
|
||||||
@@ -729,7 +737,6 @@
|
|||||||
newChatPrimaryChannel: "Primary channel",
|
newChatPrimaryChannel: "Primary channel",
|
||||||
newChatNamePlaceholder: "my-channel",
|
newChatNamePlaceholder: "my-channel",
|
||||||
addChat: "Add",
|
addChat: "Add",
|
||||||
removeChat: "Remove chat",
|
|
||||||
// messages
|
// messages
|
||||||
showChatOptions: "show chat options",
|
showChatOptions: "show chat options",
|
||||||
configureChatTitle: "Configure Chat",
|
configureChatTitle: "Configure Chat",
|
||||||
@@ -741,6 +748,7 @@
|
|||||||
removeSecondaryChannel: "Remove secondary channel",
|
removeSecondaryChannel: "Remove secondary channel",
|
||||||
encryptionKey: "Encryption key",
|
encryptionKey: "Encryption key",
|
||||||
encryptionKeyPlaceholder: "n10d2482dg283hg",
|
encryptionKeyPlaceholder: "n10d2482dg283hg",
|
||||||
|
removeChat: "Remove chat",
|
||||||
noChatSelected: "No chat selected",
|
noChatSelected: "No chat selected",
|
||||||
composerPlaceholder: "Type a message...",
|
composerPlaceholder: "Type a message...",
|
||||||
sendMessage: "Send",
|
sendMessage: "Send",
|
||||||
@@ -759,6 +767,10 @@
|
|||||||
function closeModal() {
|
function closeModal() {
|
||||||
isPresented.value = false;
|
isPresented.value = false;
|
||||||
}
|
}
|
||||||
|
function deleteChat() {
|
||||||
|
chat.deleteSelf();
|
||||||
|
closeModal();
|
||||||
|
}
|
||||||
const secondaryChannelConverter = (secondaryChannel) => {
|
const secondaryChannelConverter = (secondaryChannel) => {
|
||||||
function remove() {
|
function remove() {
|
||||||
chat.removeSecondaryChannel(secondaryChannel);
|
chat.removeSecondaryChannel(secondaryChannel);
|
||||||
@@ -830,7 +842,7 @@
|
|||||||
placeholder: translation.encryptionKeyPlaceholder,
|
placeholder: translation.encryptionKeyPlaceholder,
|
||||||
"bind:value": chat.encryptionKey
|
"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
|
// src/Views/messageComposer.tsx
|
||||||
|
|||||||
+11
-11
@@ -86,11 +86,20 @@ export class Chat {
|
|||||||
);
|
);
|
||||||
this.cannotUndoChannel = React.createProxyState(
|
this.cannotUndoChannel = React.createProxyState(
|
||||||
[this.primaryChannelInput, this.primaryChannel],
|
[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
|
// handlers
|
||||||
onmessage = async (data: Message): Promise<void> => {
|
onmessage = async (data: Message): Promise<void> => {
|
||||||
if (data.messageChannel && data.messageChannel != this.primaryChannel.value)
|
if (data.messageChannel && data.messageChannel != this.primaryChannel.value)
|
||||||
@@ -201,12 +210,3 @@ export function createChatWithName(name: string): void {
|
|||||||
|
|
||||||
UDN.subscribe(name);
|
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);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ export function ChatOptionModal(chat: Chat, isPresented: React.State<boolean>) {
|
|||||||
isPresented.value = false;
|
isPresented.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteChat() {
|
||||||
|
chat.deleteSelf()
|
||||||
|
closeModal();
|
||||||
|
}
|
||||||
|
|
||||||
const secondaryChannelConverter: React.ListItemConverter<string> = (
|
const secondaryChannelConverter: React.ListItemConverter<string> = (
|
||||||
secondaryChannel
|
secondaryChannel
|
||||||
) => {
|
) => {
|
||||||
@@ -108,8 +113,15 @@ export function ChatOptionModal(chat: Chat, isPresented: React.State<boolean>) {
|
|||||||
></input>
|
></input>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<hr></hr>
|
||||||
|
|
||||||
|
<button class="danger" on:click={deleteChat}>
|
||||||
|
{translation.removeChat}
|
||||||
|
<span class="icon">delete</span>
|
||||||
|
</button>
|
||||||
</main>
|
</main>
|
||||||
<button class="danger" on:click={closeModal}>
|
<button on:click={closeModal}>
|
||||||
{translation.close}
|
{translation.close}
|
||||||
<span class="icon">close</span>
|
<span class="icon">close</span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+2
-1
@@ -34,7 +34,6 @@ const englishTranslations = {
|
|||||||
newChatPrimaryChannel: "Primary channel",
|
newChatPrimaryChannel: "Primary channel",
|
||||||
newChatNamePlaceholder: "my-channel",
|
newChatNamePlaceholder: "my-channel",
|
||||||
addChat: "Add",
|
addChat: "Add",
|
||||||
removeChat: "Remove chat",
|
|
||||||
|
|
||||||
// messages
|
// messages
|
||||||
showChatOptions: "show chat options",
|
showChatOptions: "show chat options",
|
||||||
@@ -51,6 +50,8 @@ const englishTranslations = {
|
|||||||
encryptionKey: "Encryption key",
|
encryptionKey: "Encryption key",
|
||||||
encryptionKeyPlaceholder: "n10d2482dg283hg",
|
encryptionKeyPlaceholder: "n10d2482dg283hg",
|
||||||
|
|
||||||
|
removeChat: "Remove chat",
|
||||||
|
|
||||||
noChatSelected: "No chat selected",
|
noChatSelected: "No chat selected",
|
||||||
|
|
||||||
composerPlaceholder: "Type a message...",
|
composerPlaceholder: "Type a message...",
|
||||||
|
|||||||
Reference in New Issue
Block a user