add the ability to add new keys to the keystore
This commit is contained in:
parent
3088a7a9da
commit
2f1ebee787
2 changed files with 24 additions and 2 deletions
|
@ -153,6 +153,9 @@ fn render_app(app: &mut Hoot, ctx: &egui::Context) {
|
|||
if ui.button("Settings").clicked() {
|
||||
app.page = Page::Settings;
|
||||
}
|
||||
if ui.button("Onboarding").clicked() {
|
||||
app.page = Page::Onboarding;
|
||||
}
|
||||
});
|
||||
|
||||
egui::TopBottomPanel::top("Search").show(ctx, |ui| {
|
||||
|
|
|
@ -19,7 +19,7 @@ impl OnboardingScreen {
|
|||
Page::OnboardingNew => Self::onboarding_new(app, ui),
|
||||
Page::OnboardingNewShowKey => Self::onboarding_new_keypair_generated(app, ui),
|
||||
Page::OnboardingReturning => Self::onboarding_returning(app, ui),
|
||||
_ => error!("OnboardingScreen should not be displayed when page is not Onboarding!"),
|
||||
_ => error!("OnboardingScreen should not be displayed when page is not Onboarding!"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,25 @@ impl OnboardingScreen {
|
|||
app.page = Page::Onboarding;
|
||||
}
|
||||
ui.label("Welcome Back!");
|
||||
ui.text_edit_singleline(&mut app.state.onboarding.secret_input);
|
||||
|
||||
|
||||
let parsed_secret_key = nostr::SecretKey::parse(&app.state.onboarding.secret_input);
|
||||
let valid_key = parsed_secret_key.is_ok();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Please enter your nsec here:");
|
||||
ui.text_edit_singleline(&mut app.state.onboarding.secret_input);
|
||||
match valid_key {
|
||||
true => ui.colored_label(egui::Color32::LIGHT_GREEN, "✔ Key Valid"),
|
||||
false => ui.colored_label(egui::Color32::RED, "⊗ Key Invalid"),
|
||||
}
|
||||
});
|
||||
|
||||
if ui.add_enabled(valid_key, egui::Button::new("Save")).clicked() {
|
||||
use crate::keystorage::KeyStorage;
|
||||
let keypair = nostr::Keys::new(parsed_secret_key.unwrap());
|
||||
let _ = app.account_manager.add_key(&keypair);
|
||||
let _ = app.account_manager.load_keys();
|
||||
app.page = Page::Inbox;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue