mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 08:21:47 +00:00
Offer to unlock keys directly in posting area
This commit is contained in:
parent
d45885ee2b
commit
45a14138f0
@ -2,7 +2,7 @@ use super::FeedNoteParams;
|
||||
use crate::comms::ToOverlordMessage;
|
||||
use crate::db::DbRelay;
|
||||
use crate::globals::GLOBALS;
|
||||
use crate::ui::{GossipUi, HighlightType, Page, Theme};
|
||||
use crate::ui::{GossipUi, HighlightType, Page, Theme, you};
|
||||
use eframe::egui;
|
||||
use eframe::epaint::text::LayoutJob;
|
||||
use egui::{Align, Context, Key, Layout, Modifiers, RichText, ScrollArea, Ui, Vec2};
|
||||
@ -70,11 +70,15 @@ pub(in crate::ui) fn posting_area(
|
||||
ui.vertical(|ui| {
|
||||
if !GLOBALS.signer.is_ready() {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
if GLOBALS.signer.encrypted_private_key().is_some() {
|
||||
you::offer_unlock_priv_key(app, ui);
|
||||
} else {
|
||||
ui.label("You need to ");
|
||||
if ui.link("setup your identity").clicked() {
|
||||
app.set_page(Page::YourKeys);
|
||||
}
|
||||
ui.label(" to post.");
|
||||
}
|
||||
});
|
||||
} else if !GLOBALS
|
||||
.all_relays
|
||||
|
@ -825,11 +825,14 @@ impl eframe::App for GossipUi {
|
||||
.show(
|
||||
ui,
|
||||
|ui| {
|
||||
if GLOBALS.signer.is_ready() {
|
||||
let text = if GLOBALS.signer.is_ready() {
|
||||
RichText::new("+").size(22.5)
|
||||
} else {
|
||||
RichText::new("\u{1f513}").size(20.0)
|
||||
};
|
||||
let response = ui.add_sized(
|
||||
[ crate::AVATAR_SIZE_F32 , crate::AVATAR_SIZE_F32 ],
|
||||
egui::Button::new( RichText::new("+")
|
||||
.size(22.5)
|
||||
egui::Button::new( text
|
||||
.color(self.settings.theme.navigation_text_color()))
|
||||
.stroke(egui::Stroke::NONE)
|
||||
.rounding(egui::Rounding::same(90.0))
|
||||
@ -838,20 +841,6 @@ impl eframe::App for GossipUi {
|
||||
self.show_post_area = true;
|
||||
}
|
||||
response.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
} else {
|
||||
let response = ui.add_sized(
|
||||
[ crate::AVATAR_SIZE_F32, crate::AVATAR_SIZE_F32 ],
|
||||
egui::Button::new( RichText::new("\u{1f513}")
|
||||
.size(20.0)
|
||||
.color(self.settings.theme.navigation_text_color()))
|
||||
.stroke(egui::Stroke::NONE)
|
||||
.rounding(egui::Rounding::same(90.0))
|
||||
.fill(self.settings.theme.navigation_bg_fill()) );
|
||||
if response.clicked() {
|
||||
self.set_page(Page::YourKeys);
|
||||
}
|
||||
response.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
@ -120,6 +120,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
bottom: 10.0,
|
||||
})
|
||||
.show(ui, |ui| {
|
||||
ui.heading("Passphrase Needed");
|
||||
offer_unlock_priv_key(app, ui);
|
||||
});
|
||||
|
||||
@ -216,9 +217,7 @@ fn show_pub_key_detail(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
fn offer_unlock_priv_key(app: &mut GossipUi, ui: &mut Ui) {
|
||||
ui.heading("Passphrase Needed");
|
||||
|
||||
pub(super) fn offer_unlock_priv_key(app: &mut GossipUi, ui: &mut Ui) {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Passphrase: ");
|
||||
let response = ui.add(text_edit_line!(app, app.password).password(true));
|
||||
@ -229,8 +228,6 @@ fn offer_unlock_priv_key(app: &mut GossipUi, ui: &mut Ui) {
|
||||
app.password.zeroize();
|
||||
app.password = "".to_owned();
|
||||
}
|
||||
});
|
||||
|
||||
if ui.button("Unlock Private Key").clicked() {
|
||||
let _ = GLOBALS
|
||||
.to_overlord
|
||||
@ -238,6 +235,7 @@ fn offer_unlock_priv_key(app: &mut GossipUi, ui: &mut Ui) {
|
||||
app.password.zeroize();
|
||||
app.password = "".to_owned();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn show_priv_key_detail(_app: &mut GossipUi, ui: &mut Ui) {
|
||||
|
Loading…
Reference in New Issue
Block a user