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,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(); let txn = Transaction::new(note_context.ndb).unwrap();
egui::ScrollArea::horizontal().show(ui, |ui| { egui::ScrollArea::horizontal()
ui.horizontal(|ui| { .max_height(400.0)
for note_id in &call.note_ids { .show(ui, |ui| {
let Ok(note) = ui.with_layout(Layout::left_to_right(Align::Min), |ui| {
note_context.ndb.get_note_by_id(&txn, note_id.bytes()) ui.spacing_mut().item_spacing.x = 10.0;
else {
continue;
};
// TODO: remove current account thing, just add to note context for note_id in &call.note_ids {
notedeck_ui::NoteView::new( let Ok(note) =
&mut note_context, note_context.ndb.get_note_by_id(&txn, note_id.bytes())
&None, else {
&note, continue;
NoteOptions::default(), };
)
.preview_style() let mut note_view = notedeck_ui::NoteView::new(
.show(ui); &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) => { ToolCalls::Query(search_call) => {

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,