refactor nip4e

This commit is contained in:
2026-06-05 15:10:28 +07:00
parent c791309659
commit 57a129fa93
2 changed files with 75 additions and 77 deletions

View File

@@ -146,7 +146,7 @@ impl Workspace {
match event {
DeviceEvent::Requesting => {
const MSG: &str =
"Coop has sent a request for an encryption key. Please open the other client then approve the request.";
"Please open other client and approve the request for encryption key.";
let note = Notification::new()
.id::<DeviceNotifcation>()
@@ -157,12 +157,25 @@ impl Workspace {
window.push_notification(note, cx);
}
DeviceEvent::Creating => {
DeviceEvent::NotSet => {
const MSG: &str =
"User're not setup encryption key yet. Do you want to create one?";
let note = Notification::new()
.id::<DeviceNotifcation>()
.autohide(false)
.message("Creating encryption key")
.with_kind(NotificationKind::Info);
.message(MSG)
.with_kind(NotificationKind::Info)
.action(|_this, _window, _cx| {
Button::new("retry").label("Retry").on_click(
move |_this, window, cx| {
let device = DeviceRegistry::global(cx);
device.update(cx, |this, cx| {
this.set_announcement(Keys::generate(), cx);
});
window.clear_notification::<DeviceNotifcation>(cx);
},
)
});
window.push_notification(note, cx);
}
@@ -664,9 +677,6 @@ impl Workspace {
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;
let nostr = NostrRegistry::global(cx);
let signer = nostr.read(cx).signer();
@@ -720,12 +730,6 @@ impl Workspace {
.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")