mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 00:11:01 +00:00
'Show More' on long notes
This commit is contained in:
parent
9b8820142a
commit
f6720f647d
@ -65,6 +65,9 @@ pub struct Globals {
|
||||
/// Dismissed Events
|
||||
pub dismissed: RwLock<Vec<Id>>,
|
||||
|
||||
/// Fully opened Events
|
||||
pub opened: PRwLock<HashSet<Id>>,
|
||||
|
||||
/// Feed
|
||||
pub feed: Feed,
|
||||
|
||||
@ -153,6 +156,7 @@ lazy_static! {
|
||||
shutting_down: AtomicBool::new(false),
|
||||
signer: Signer::default(),
|
||||
dismissed: RwLock::new(Vec::new()),
|
||||
opened: PRwLock::new(HashSet::new()),
|
||||
feed: Feed::new(),
|
||||
fetcher: Fetcher::new(),
|
||||
failed_avatars: RwLock::new(HashSet::new()),
|
||||
|
@ -26,7 +26,22 @@ pub(super) fn render_content(
|
||||
ui.style_mut().spacing.item_spacing.x = 0.0;
|
||||
|
||||
if let Ok(note) = note_ref.try_borrow() {
|
||||
let content_start = ui.next_widget_position();
|
||||
let mut show_less_button = false;
|
||||
|
||||
for segment in note.shattered_content.segments.iter() {
|
||||
if ui.next_widget_position().y > content_start.y + 200.0 {
|
||||
if !GLOBALS.opened.read().contains(¬e.event.id) {
|
||||
ui.end_row();
|
||||
if ui.button("show more...").clicked() {
|
||||
GLOBALS.opened.write().insert(note.event.id);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
show_less_button = true;
|
||||
}
|
||||
}
|
||||
|
||||
match segment {
|
||||
ContentSegment::NostrUrl(nurl) => {
|
||||
match &nurl.0 {
|
||||
@ -159,6 +174,13 @@ pub(super) fn render_content(
|
||||
ContentSegment::Plain(textspan) => render_plain(ui, ¬e, textspan, as_deleted),
|
||||
}
|
||||
}
|
||||
|
||||
if show_less_button {
|
||||
ui.end_row();
|
||||
if ui.button("show less...").clicked() {
|
||||
GLOBALS.opened.write().remove(¬e.event.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui.reset_style();
|
||||
|
Loading…
Reference in New Issue
Block a user