chore: simplify codebase and prepare for multi-platforms #28
@@ -131,14 +131,14 @@ impl ChatRegistry {
|
|||||||
if event == &StateEvent::SignerSet {
|
if event == &StateEvent::SignerSet {
|
||||||
this.reset(cx);
|
this.reset(cx);
|
||||||
this.get_rooms(cx);
|
this.get_rooms(cx);
|
||||||
|
this.get_contact_list(cx);
|
||||||
|
this.get_messages(cx);
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Run at the end of the current cycle
|
// Run at the end of the current cycle
|
||||||
cx.defer_in(window, |this, _window, cx| {
|
cx.defer_in(window, |this, _window, cx| {
|
||||||
this.get_contact_list(cx);
|
|
||||||
this.get_messages(cx);
|
|
||||||
this.get_rooms(cx);
|
this.get_rooms(cx);
|
||||||
this.handle_notifications(cx);
|
this.handle_notifications(cx);
|
||||||
this.tracking(cx);
|
this.tracking(cx);
|
||||||
|
|||||||
@@ -127,6 +127,9 @@ impl Workspace {
|
|||||||
// Clear the signer notification
|
// Clear the signer notification
|
||||||
window.clear_notification::<SignerNotifcation>(cx);
|
window.clear_notification::<SignerNotifcation>(cx);
|
||||||
}
|
}
|
||||||
|
StateEvent::Show => {
|
||||||
|
this.account_selector(window, cx);
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ pub enum StateEvent {
|
|||||||
Connected,
|
Connected,
|
||||||
/// Creating the signer
|
/// Creating the signer
|
||||||
Creating,
|
Creating,
|
||||||
|
/// Show the identity dialog
|
||||||
|
Show,
|
||||||
/// A new signer has been set
|
/// A new signer has been set
|
||||||
SignerSet,
|
SignerSet,
|
||||||
/// An error occurred
|
/// An error occurred
|
||||||
@@ -151,6 +153,9 @@ impl NostrRegistry {
|
|||||||
// Create an identity if none exists
|
// Create an identity if none exists
|
||||||
if this.npubs.read(cx).is_empty() {
|
if this.npubs.read(cx).is_empty() {
|
||||||
this.create_identity(cx);
|
this.create_identity(cx);
|
||||||
|
} else {
|
||||||
|
// Show the identity dialog
|
||||||
|
cx.emit(StateEvent::Show);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -275,6 +280,7 @@ impl NostrRegistry {
|
|||||||
let app_keys = self.app_keys.clone();
|
let app_keys = self.app_keys.clone();
|
||||||
|
|
||||||
if let Ok(payload) = std::fs::read_to_string(key_path) {
|
if let Ok(payload) = std::fs::read_to_string(key_path) {
|
||||||
|
if payload.starts_with("nsec1") || payload.starts_with("bunker://") {
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let decrypted = app_keys.nip44_decrypt(&public_key, &payload).await?;
|
let decrypted = app_keys.nip44_decrypt(&public_key, &payload).await?;
|
||||||
let secret = SecretKey::parse(&decrypted)?;
|
let secret = SecretKey::parse(&decrypted)?;
|
||||||
@@ -285,6 +291,9 @@ impl NostrRegistry {
|
|||||||
} else {
|
} else {
|
||||||
self.get_secret_keyring(&npub, cx)
|
self.get_secret_keyring(&npub, cx)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
self.get_secret_keyring(&npub, cx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the secret for a given npub in the OS credentials store.
|
/// Get the secret for a given npub in the OS credentials store.
|
||||||
|
|||||||
Reference in New Issue
Block a user