search: hook up nav actions

Fixes: https://linear.app/damus/issue/DECK-537/hook-up-search-query-view-responses
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-03-07 13:22:06 -08:00
parent c2545d17e7
commit 1953496019
2 changed files with 26 additions and 24 deletions

View File

@@ -403,9 +403,8 @@ fn render_nav_body(
app.note_options, app.note_options,
search_buffer, search_buffer,
) )
.show(ui); .show(ui)
.map(RenderNavAction::NoteAction)
None
} }
Route::NewDeck => { Route::NewDeck => {

View File

@@ -1,7 +1,10 @@
use egui::{vec2, Align, Color32, RichText, Rounding, Stroke, TextEdit}; use egui::{vec2, Align, Color32, RichText, Rounding, Stroke, TextEdit};
use super::padding; use super::padding;
use crate::ui::{note::NoteOptions, timeline::TimelineTabView}; use crate::{
actionbar::NoteAction,
ui::{note::NoteOptions, timeline::TimelineTabView},
};
use nostrdb::{Filter, Ndb, Transaction}; use nostrdb::{Filter, Ndb, Transaction};
use notedeck::{Images, MuteFun, NoteCache, NoteRef}; use notedeck::{Images, MuteFun, NoteCache, NoteRef};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@@ -42,13 +45,11 @@ impl<'a> SearchView<'a> {
} }
} }
pub fn show(&mut self, ui: &mut egui::Ui) { pub fn show(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
padding(8.0, ui, |ui| { padding(8.0, ui, |ui| self.show_impl(ui)).inner
self.show_impl(ui);
});
} }
pub fn show_impl(&mut self, ui: &mut egui::Ui) { pub fn show_impl(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
ui.spacing_mut().item_spacing = egui::vec2(0.0, 12.0); ui.spacing_mut().item_spacing = egui::vec2(0.0, 12.0);
if search_box(self.query, ui) { if search_box(self.query, ui) {
@@ -56,7 +57,7 @@ impl<'a> SearchView<'a> {
} }
match self.query.state { match self.query.state {
SearchState::New => {} SearchState::New => None,
SearchState::Searched | SearchState::Typing => { SearchState::Searched | SearchState::Typing => {
if self.query.state == SearchState::Typing { if self.query.state == SearchState::Typing {
@@ -69,20 +70,22 @@ impl<'a> SearchView<'a> {
)); ));
} }
egui::ScrollArea::vertical().show(ui, |ui| { egui::ScrollArea::vertical()
let reversed = false; .show(ui, |ui| {
TimelineTabView::new( let reversed = false;
&self.query.notes, TimelineTabView::new(
reversed, &self.query.notes,
self.note_options, reversed,
self.txn, self.note_options,
self.ndb, self.txn,
self.note_cache, self.ndb,
self.img_cache, self.note_cache,
self.is_muted, self.img_cache,
) self.is_muted,
.show(ui); )
}); .show(ui)
})
.inner
} }
} }
} }