notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 5811a5f4e64a54e3427bf797ba9c36e6c8ffdc72
parent a33aad1f62a246576fbc017d7e1c0458fc55ff72
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 20 Apr 2025 09:05:02 -0700

dave: improve multi-note display

Diffstat:
Mcrates/notedeck_dave/src/lib.rs | 45+++++++++++++++++++++++++--------------------
Mcrates/notedeck_ui/src/note/contents.rs | 12++++++++++--
Mcrates/notedeck_ui/src/note/mod.rs | 9++++++++-
3 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/crates/notedeck_dave/src/lib.rs b/crates/notedeck_dave/src/lib.rs @@ -255,27 +255,32 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr let txn = Transaction::new(note_context.ndb).unwrap(); - egui::ScrollArea::horizontal().show(ui, |ui| { - ui.horizontal(|ui| { - for note_id in &call.note_ids { - let Ok(note) = - note_context.ndb.get_note_by_id(&txn, note_id.bytes()) - else { - continue; - }; - - // TODO: remove current account thing, just add to note context - notedeck_ui::NoteView::new( - &mut note_context, - &None, - &note, - NoteOptions::default(), - ) - .preview_style() - .show(ui); - } + egui::ScrollArea::horizontal() + .max_height(400.0) + .show(ui, |ui| { + ui.with_layout(Layout::left_to_right(Align::Min), |ui| { + ui.spacing_mut().item_spacing.x = 10.0; + + for note_id in &call.note_ids { + let Ok(note) = + note_context.ndb.get_note_by_id(&txn, note_id.bytes()) + else { + continue; + }; + + let mut note_view = notedeck_ui::NoteView::new( + &mut note_context, + &None, + &note, + NoteOptions::default(), + ) + .preview_style(); + + // TODO: remove current account thing, just add to note context + ui.add_sized([400.0, 400.0], &mut note_view); + } + }); }); - }); } ToolCalls::Query(search_call) => { diff --git a/crates/notedeck_ui/src/note/contents.rs b/crates/notedeck_ui/src/note/contents.rs @@ -211,9 +211,17 @@ pub fn render_note_contents( BlockType::Text => { if options.has_scramble_text() { - ui.add(egui::Label::new(rot13(block.as_str())).selectable(selectable)); + ui.add( + egui::Label::new(rot13(block.as_str())) + .wrap() + .selectable(selectable), + ); } else { - ui.add(egui::Label::new(block.as_str()).selectable(selectable)); + ui.add( + egui::Label::new(block.as_str()) + .wrap() + .selectable(selectable), + ); } } diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs @@ -60,6 +60,12 @@ impl View for NoteView<'_, '_> { } */ +impl egui::Widget for &mut NoteView<'_, '_> { + fn ui(self, ui: &mut egui::Ui) -> egui::Response { + self.show(ui).response + } +} + impl<'a, 'd> NoteView<'a, 'd> { pub fn new( note_context: &'a mut NoteContext<'d>, @@ -69,9 +75,10 @@ impl<'a, 'd> NoteView<'a, 'd> { ) -> Self { flags.set_actionbar(true); flags.set_note_previews(true); - let framed = false; + let framed = false; let parent: Option<NoteKey> = None; + Self { note_context, cur_acc,