diff --git a/crates/chat_ui/src/lib.rs b/crates/chat_ui/src/lib.rs index 310e75f..c2d2a6d 100644 --- a/crates/chat_ui/src/lib.rs +++ b/crates/chat_ui/src/lib.rs @@ -620,13 +620,19 @@ impl ChatPanel { }) .is_err() { - window.push_notification( - Notification::error("Failed to change subject").autohide(false), - cx, - ); + window.push_notification(Notification::error("Failed to change subject"), cx); } } Command::ChangeSigner(kind) => { + let is_nip4e_enabled = AppSettings::get_encryption_key(cx); + + if !is_nip4e_enabled + && (*kind == SignerKind::Encryption || *kind == SignerKind::Auto) + { + window.push_notification("Decoupling Encryption Key is not enabled", cx); + return; + } + if self .room .update(cx, |this, cx| { @@ -634,10 +640,7 @@ impl ChatPanel { }) .is_err() { - window.push_notification( - Notification::error("Failed to change signer").autohide(false), - cx, - ); + window.push_notification(Notification::error("Failed to change signer"), cx); } } Command::ToggleBackup => { @@ -648,10 +651,7 @@ impl ChatPanel { }) .is_err() { - window.push_notification( - Notification::error("Failed to toggle backup").autohide(false), - cx, - ); + window.push_notification(Notification::error("Failed to toggle backup"), cx); } } Command::Copy(public_key) => { diff --git a/crates/settings/src/lib.rs b/crates/settings/src/lib.rs index cd7f56f..9ad22e8 100644 --- a/crates/settings/src/lib.rs +++ b/crates/settings/src/lib.rs @@ -67,8 +67,8 @@ impl Display for AuthMode { /// Signer kind #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub enum SignerKind { - #[default] Auto, + #[default] User, Encryption, } diff --git a/crates/ui/src/input/input.rs b/crates/ui/src/input/input.rs index 68d4e1f..8187819 100644 --- a/crates/ui/src/input/input.rs +++ b/crates/ui/src/input/input.rs @@ -18,7 +18,7 @@ pub(crate) fn input_style(disabled: bool, cx: &App) -> (Hsla, Hsla) { if disabled { (cx.theme().surface_background, cx.theme().text_muted) } else { - (cx.theme().surface_background, cx.theme().text) + (cx.theme().elevated_surface_background, cx.theme().text) } } diff --git a/desktop/src/workspace.rs b/desktop/src/workspace.rs index 64f17f4..fce9d06 100644 --- a/desktop/src/workspace.rs +++ b/desktop/src/workspace.rs @@ -641,6 +641,7 @@ impl Workspace { let chat = ChatRegistry::global(cx); let initializing = chat.read(cx).initializing; let trash_messages = chat.read(cx).count_trash_messages(cx); + let is_nip4e_enabled = AppSettings::get_encryption_key(cx); let device = DeviceRegistry::global(cx); let device_initializing = device.read(cx).initializing; @@ -691,72 +692,76 @@ impl Workspace { }), ) }) - .child( - Button::new("key") - .icon(IconName::UserKey) - .tooltip("Decoupled encryption key") - .small() - .ghost() - .loading(device_initializing) - .when(device_initializing, |this| { - this.label("Dekey") - .xsmall() - .tooltip("Loading decoupled encryption key...") - }) - .dropdown_menu(move |this, _window, _cx| { - this.min_w(px(260.)) - .label("Encryption Key") - .when_some(announcement.as_ref(), |this, announcement| { - let name = announcement.client_name(); - let pkey = shorten_pubkey(announcement.public_key(), 8); + .when(is_nip4e_enabled, |this| { + this.child( + Button::new("key") + .icon(IconName::UserKey) + .tooltip("Decoupled encryption key") + .small() + .ghost() + .loading(device_initializing) + .when(device_initializing, |this| { + this.label("Dekey") + .xsmall() + .tooltip("Loading decoupled encryption key...") + }) + .dropdown_menu(move |this, _window, _cx| { + this.min_w(px(260.)) + .label("Encryption Key") + .when_some(announcement.as_ref(), |this, announcement| { + let name = announcement.client_name(); + let pkey = shorten_pubkey(announcement.public_key(), 8); - this.item(PopupMenuItem::element(move |_window, cx| { - h_flex() - .gap_1() - .text_sm() - .child( - Icon::new(IconName::Device) - .small() - .text_color(cx.theme().icon_muted), - ) - .child(name.clone()) - })) - .item(PopupMenuItem::element(move |_window, cx| { - h_flex() - .gap_1() - .text_sm() - .child( - Icon::new(IconName::UserKey) - .small() - .text_color(cx.theme().icon_muted), - ) - .child(SharedString::from(pkey.clone())) - })) - }) - .separator() - .menu_with_icon( - "Backup", - IconName::Shield, - Box::new(Command::BackupEncryption), - ) - .menu_with_icon( - "Restore from secret key", - IconName::Usb, - Box::new(Command::ImportEncryption), - ) - .separator() - .menu_with_icon( - "Reload", - IconName::Refresh, - Box::new(Command::RefreshEncryption), - ) - .menu_with_icon( - "Reset", - IconName::Warning, - Box::new(Command::ResetEncryption), - ) - }), - ) + this.item(PopupMenuItem::element(move |_window, cx| { + h_flex() + .gap_1() + .text_sm() + .child( + Icon::new(IconName::Device) + .small() + .text_color(cx.theme().icon_muted), + ) + .child(name.clone()) + })) + .item( + PopupMenuItem::element(move |_window, cx| { + h_flex() + .gap_1() + .text_sm() + .child( + Icon::new(IconName::UserKey) + .small() + .text_color(cx.theme().icon_muted), + ) + .child(SharedString::from(pkey.clone())) + }), + ) + }) + .separator() + .menu_with_icon( + "Backup", + IconName::Shield, + Box::new(Command::BackupEncryption), + ) + .menu_with_icon( + "Restore from secret key", + IconName::Usb, + Box::new(Command::ImportEncryption), + ) + .separator() + .menu_with_icon( + "Reload", + IconName::Refresh, + Box::new(Command::RefreshEncryption), + ) + .menu_with_icon( + "Reset", + IconName::Warning, + Box::new(Command::ResetEncryption), + ) + }), + ) + }) .child( Button::new("inbox") .icon(IconName::Inbox)