'Show More' on long notes

This commit is contained in:
Mike Dilger 2023-09-20 08:03:47 +12:00
parent 9b8820142a
commit f6720f647d
2 changed files with 26 additions and 0 deletions

View File

@ -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()),

View File

@ -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(&note.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, &note, textspan, as_deleted),
}
}
if show_less_button {
ui.end_row();
if ui.button("show less...").clicked() {
GLOBALS.opened.write().remove(&note.event.id);
}
}
}
ui.reset_style();