From a0d76e2cf43731b741d679acb9a01f1434da4019 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Fri, 5 Jun 2026 08:34:34 +0700 Subject: [PATCH] add nip4e settings --- crates/settings/src/lib.rs | 4 ++-- desktop/src/dialogs/settings.rs | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/crates/settings/src/lib.rs b/crates/settings/src/lib.rs index 9ad22e8..e107994 100644 --- a/crates/settings/src/lib.rs +++ b/crates/settings/src/lib.rs @@ -68,9 +68,9 @@ impl Display for AuthMode { #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub enum SignerKind { Auto, + Encryption, #[default] User, - Encryption, } impl SignerKind { @@ -98,7 +98,7 @@ impl RoomConfig { pub fn new() -> Self { Self { backup: true, - signer_kind: SignerKind::Auto, + signer_kind: SignerKind::default(), } } diff --git a/desktop/src/dialogs/settings.rs b/desktop/src/dialogs/settings.rs index f6e67dc..408f0c6 100644 --- a/desktop/src/dialogs/settings.rs +++ b/desktop/src/dialogs/settings.rs @@ -56,17 +56,16 @@ impl Preferences { impl Render for Preferences { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - const SCREENING: &str = - "When opening a request, a popup will appear to help you identify the sender."; - const AVATAR: &str = - "Hide all avatar pictures to improve performance and protect your privacy."; - const MODE: &str = - "Choose whether to use the selected light or dark theme, or to follow the OS."; + const SCREENING: &str = "Show an screening dialog to verify the unknown sender."; + const AVATAR: &str = "Hide all avatar pictures to improve performance."; + const MODE: &str = "Use the selected light or dark theme, or to follow the OS."; + const NIP4E: &str = "Use a dedicated key to encrypt and decrypt messages."; const AUTH: &str = "Choose the authentication behavior for relays."; const RESET: &str = "Reset the theme to the default one."; let screening = AppSettings::get_screening(cx); let hide_avatar = AppSettings::get_hide_avatar(cx); + let nip4e = AppSettings::get_encryption_key(cx); let auth_mode = AppSettings::get_auth_mode(cx); let theme_mode = AppSettings::get_theme_mode(cx); @@ -207,6 +206,21 @@ impl Render for Preferences { ), ), ) + .child( + GroupBox::new() + .id("experiments") + .title("Experiments") + .fill() + .child( + Switch::new("nip4e") + .label("Decoupling Encryption Key") + .description(NIP4E) + .checked(nip4e) + .on_click(move |_, _window, cx| { + AppSettings::update_encryption_key(!nip4e, cx); + }), + ), + ) .child( GroupBox::new() .id("media")