add checkbox to show/hide key

This commit is contained in:
marlon-erler
2024-07-09 19:50:43 +02:00
parent d6c3af407e
commit eca5e75583
3 changed files with 25 additions and 2 deletions
+11 -2
View File
@@ -754,6 +754,7 @@
removeSecondaryChannel: "Remove secondary channel", removeSecondaryChannel: "Remove secondary channel",
encryptionKey: "Encryption key", encryptionKey: "Encryption key",
encryptionKeyPlaceholder: "n10d2482dg283hg", encryptionKeyPlaceholder: "n10d2482dg283hg",
showKey: "Show key",
removeChat: "Remove chat", removeChat: "Remove chat",
clearChatMessages: "Clear chat messages", clearChatMessages: "Clear chat messages",
noChatSelected: "No chat selected", noChatSelected: "No chat selected",
@@ -799,6 +800,7 @@
removeSecondaryChannel: "Eliminar canal segundario", removeSecondaryChannel: "Eliminar canal segundario",
encryptionKey: "Clave de cifrado", encryptionKey: "Clave de cifrado",
encryptionKeyPlaceholder: "n10d2482dg283hg", encryptionKeyPlaceholder: "n10d2482dg283hg",
showKey: "Mostrar clave",
removeChat: "Eliminar chat", removeChat: "Eliminar chat",
clearChatMessages: "Eliminar todos mensajes", clearChatMessages: "Eliminar todos mensajes",
noChatSelected: "Selecciona un chat", noChatSelected: "Selecciona un chat",
@@ -842,6 +844,7 @@
removeSecondaryChannel: "Zweitkanal entfernen", removeSecondaryChannel: "Zweitkanal entfernen",
encryptionKey: "Schl\xFCssel", encryptionKey: "Schl\xFCssel",
encryptionKeyPlaceholder: "n10d2482dg283hg", encryptionKeyPlaceholder: "n10d2482dg283hg",
showKey: "Schl\xFCssel anzeigen",
removeChat: "Chat l\xF6schen", removeChat: "Chat l\xF6schen",
clearChatMessages: "Nachrichtenverlauf leeren", clearChatMessages: "Nachrichtenverlauf leeren",
noChatSelected: "Kein Chat ausgew\xE4hlt", noChatSelected: "Kein Chat ausgew\xE4hlt",
@@ -864,6 +867,11 @@
chat.deleteSelf(); chat.deleteSelf();
closeModal(); closeModal();
} }
const shouldShowKey = new State(false);
const inputType = createProxyState(
[shouldShowKey],
() => shouldShowKey.value == true ? "text" : "password"
);
const secondaryChannelConverter = (secondaryChannel) => { const secondaryChannelConverter = (secondaryChannel) => {
function remove() { function remove() {
chat.removeSecondaryChannel(secondaryChannel); chat.removeSecondaryChannel(secondaryChannel);
@@ -933,9 +941,10 @@
"input", "input",
{ {
placeholder: translation.encryptionKeyPlaceholder, placeholder: translation.encryptionKeyPlaceholder,
"bind:value": chat.encryptionKey "bind:value": chat.encryptionKey,
"set:type": inputType
} }
)))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("button", { class: "danger", "on:click": chat.clearMessages }, translation.clearChatMessages, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete_sweep")), /* @__PURE__ */ createElement("button", { class: "danger", "on:click": deleteChat }, translation.removeChat, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete")))), /* @__PURE__ */ createElement("button", { "on:click": closeModal }, translation.close, /* @__PURE__ */ createElement("span", { class: "icon" }, "close")))); ))), /* @__PURE__ */ createElement("label", { class: "inline margin-0" }, /* @__PURE__ */ createElement("input", { type: "checkbox", "bind:checked": shouldShowKey }), translation.showKey)), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("button", { class: "danger", "on:click": chat.clearMessages }, translation.clearChatMessages, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete_sweep")), /* @__PURE__ */ createElement("button", { class: "danger", "on:click": deleteChat }, translation.removeChat, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete")))), /* @__PURE__ */ createElement("button", { "on:click": closeModal }, translation.close, /* @__PURE__ */ createElement("span", { class: "icon" }, "close"))));
} }
// src/Views/messageComposer.tsx // src/Views/messageComposer.tsx
+11
View File
@@ -13,6 +13,11 @@ export function ChatOptionModal(chat: Chat, isPresented: React.State<boolean>) {
closeModal(); closeModal();
} }
const shouldShowKey = new React.State(false);
const inputType = React.createProxyState([shouldShowKey], () =>
shouldShowKey.value == true ? "text" : "password"
);
const secondaryChannelConverter: React.ListItemConverter<string> = ( const secondaryChannelConverter: React.ListItemConverter<string> = (
secondaryChannel secondaryChannel
) => { ) => {
@@ -111,9 +116,15 @@ export function ChatOptionModal(chat: Chat, isPresented: React.State<boolean>) {
<input <input
placeholder={translation.encryptionKeyPlaceholder} placeholder={translation.encryptionKeyPlaceholder}
bind:value={chat.encryptionKey} bind:value={chat.encryptionKey}
set:type={inputType}
></input> ></input>
</div> </div>
</label> </label>
<label class="inline margin-0">
<input type="checkbox" bind:checked={shouldShowKey}></input>
{translation.showKey}
</label>
</div> </div>
<hr></hr> <hr></hr>
+3
View File
@@ -45,6 +45,7 @@ const englishTranslations = {
encryptionKey: "Encryption key", encryptionKey: "Encryption key",
encryptionKeyPlaceholder: "n10d2482dg283hg", encryptionKeyPlaceholder: "n10d2482dg283hg",
showKey: "Show key",
removeChat: "Remove chat", removeChat: "Remove chat",
clearChatMessages: "Clear chat messages", clearChatMessages: "Clear chat messages",
@@ -108,6 +109,7 @@ const allTranslations: { [key: string]: typeof englishTranslations } = {
encryptionKey: "Clave de cifrado", encryptionKey: "Clave de cifrado",
encryptionKeyPlaceholder: "n10d2482dg283hg", encryptionKeyPlaceholder: "n10d2482dg283hg",
showKey: "Mostrar clave",
removeChat: "Eliminar chat", removeChat: "Eliminar chat",
clearChatMessages: "Eliminar todos mensajes", clearChatMessages: "Eliminar todos mensajes",
@@ -168,6 +170,7 @@ const allTranslations: { [key: string]: typeof englishTranslations } = {
encryptionKey: "Schlüssel", encryptionKey: "Schlüssel",
encryptionKeyPlaceholder: "n10d2482dg283hg", encryptionKeyPlaceholder: "n10d2482dg283hg",
showKey: "Schlüssel anzeigen",
removeChat: "Chat löschen", removeChat: "Chat löschen",
clearChatMessages: "Nachrichtenverlauf leeren", clearChatMessages: "Nachrichtenverlauf leeren",