fix NIP-4e state hygiene and UX issues

This commit is contained in:
2026-10-04 13:10:15 +07:00
parent bdf9249eab
commit 0bae051316
6 changed files with 101 additions and 63 deletions
+2 -1
View File
@@ -51,8 +51,9 @@ impl RestoreEncryption {
let device = DeviceRegistry::global(cx);
let content = self.key_input.read(cx).value();
if !content.is_empty() {
if content.is_empty() {
self.set_error("Secret Key cannot be empty.", cx);
return;
}
let Ok(secret) = SecretKey::parse(&content) else {
+5 -4
View File
@@ -5,11 +5,11 @@ use anyhow::Error;
use auto_update::AutoUpdater;
use chat::{ChatEvent, ChatRegistry};
use common::download_dir;
use nip4e::{DeviceEvent, DeviceRegistry};
use gpui::{
Action, App, AppContext, Context, Entity, InteractiveElement, IntoElement, ParentElement,
Render, SharedString, Styled, Subscription, Task, Window, div, px,
};
use nip4e::{DeviceEvent, DeviceRegistry};
use nip29::{GroupId, GroupKey};
use nostr_sdk::prelude::*;
use serde::Deserialize;
@@ -120,8 +120,9 @@ impl Workspace {
window.push_notification(note, cx);
}
DeviceEvent::NotSet => {
const MSG: &str =
"User're not setup encryption key yet. Do you want to create one?";
const MSG: &str = "No encryption key announcement was found. It may \
still be propagating, or you can restore one \
from the settings.";
let note = Notification::new()
.id::<DeviceNotifcation>()
@@ -132,7 +133,7 @@ impl Workspace {
move |_this, window, cx| {
let device = DeviceRegistry::global(cx);
device.update(cx, |this, cx| {
this.set_announcement(Keys::generate(), cx);
this.get_announcement(cx);
});
window.clear_notification::<DeviceNotifcation>(cx);
},