dave: improve multi-note display

This commit is contained in:
William Casarin
2025-04-20 09:05:02 -07:00
parent a33aad1f62
commit 5811a5f4e6
3 changed files with 42 additions and 22 deletions

View File

@@ -255,8 +255,12 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
let txn = Transaction::new(note_context.ndb).unwrap(); let txn = Transaction::new(note_context.ndb).unwrap();
egui::ScrollArea::horizontal().show(ui, |ui| { egui::ScrollArea::horizontal()
ui.horizontal(|ui| { .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 { for note_id in &call.note_ids {
let Ok(note) = let Ok(note) =
note_context.ndb.get_note_by_id(&txn, note_id.bytes()) note_context.ndb.get_note_by_id(&txn, note_id.bytes())
@@ -264,15 +268,16 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
continue; continue;
}; };
// TODO: remove current account thing, just add to note context let mut note_view = notedeck_ui::NoteView::new(
notedeck_ui::NoteView::new(
&mut note_context, &mut note_context,
&None, &None,
&note, &note,
NoteOptions::default(), NoteOptions::default(),
) )
.preview_style() .preview_style();
.show(ui);
// TODO: remove current account thing, just add to note context
ui.add_sized([400.0, 400.0], &mut note_view);
} }
}); });
}); });

View File

@@ -211,9 +211,17 @@ pub fn render_note_contents(
BlockType::Text => { BlockType::Text => {
if options.has_scramble_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 { } else {
ui.add(egui::Label::new(block.as_str()).selectable(selectable)); ui.add(
egui::Label::new(block.as_str())
.wrap()
.selectable(selectable),
);
} }
} }

View File

@@ -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> { impl<'a, 'd> NoteView<'a, 'd> {
pub fn new( pub fn new(
note_context: &'a mut NoteContext<'d>, note_context: &'a mut NoteContext<'d>,
@@ -69,9 +75,10 @@ impl<'a, 'd> NoteView<'a, 'd> {
) -> Self { ) -> Self {
flags.set_actionbar(true); flags.set_actionbar(true);
flags.set_note_previews(true); flags.set_note_previews(true);
let framed = false;
let framed = false;
let parent: Option<NoteKey> = None; let parent: Option<NoteKey> = None;
Self { Self {
note_context, note_context,
cur_acc, cur_acc,