mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
ui: feed: restructure code
This commit is contained in:
parent
600b90159a
commit
fdd0e8ab01
@ -1,10 +1,10 @@
|
||||
use super::GossipUi;
|
||||
use eframe::egui;
|
||||
use egui::{Align, Color32, Context, Layout, RichText, ScrollArea, TextStyle, Ui, Vec2};
|
||||
use nostr_proto::PublicKey;
|
||||
use nostr_proto::{Id, PublicKey};
|
||||
use tracing::info;
|
||||
|
||||
pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||
pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||
let feed = crate::globals::blocking_get_feed(true);
|
||||
|
||||
//let screen_rect = ctx.input().screen_rect; // Rect
|
||||
@ -32,18 +32,33 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
|
||||
// break;
|
||||
//}
|
||||
|
||||
render_post(app, ctx, frame, ui, *id, 0);
|
||||
|
||||
ui.separator();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn render_post(
|
||||
app: &mut GossipUi,
|
||||
_ctx: &Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
ui: &mut Ui,
|
||||
id: Id,
|
||||
_indent: usize,
|
||||
) {
|
||||
let maybe_fevent = crate::globals::GLOBALS
|
||||
.feed_events
|
||||
.blocking_lock()
|
||||
.get(id)
|
||||
.get(&id)
|
||||
.cloned();
|
||||
if maybe_fevent.is_none() {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
let fevent = maybe_fevent.unwrap();
|
||||
|
||||
if fevent.event.is_none() {
|
||||
continue;
|
||||
return;
|
||||
} // don't render related info w/o nostr event.
|
||||
let event = fevent.event.as_ref().unwrap().to_owned();
|
||||
|
||||
@ -96,9 +111,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(person) = maybe_person {
|
||||
if let Some(name) = &person.name {
|
||||
ui.label(
|
||||
RichText::new(name).text_style(TextStyle::Name("Bold".into())),
|
||||
);
|
||||
ui.label(RichText::new(name).text_style(TextStyle::Name("Bold".into())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,10 +149,6 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
|
||||
ui.label(&event.content);
|
||||
});
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn pubkey_short(pubkey: &PublicKey) -> String {
|
||||
|
Loading…
Reference in New Issue
Block a user