From f6753bae975cd0453eeb5426dbcefab37ac82008 Mon Sep 17 00:00:00 2001 From: kernelkind Date: Tue, 17 Jun 2025 12:45:39 -0400 Subject: [PATCH] add `NotesOpenResult` Signed-off-by: kernelkind --- crates/notedeck_columns/src/actionbar.rs | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/notedeck_columns/src/actionbar.rs b/crates/notedeck_columns/src/actionbar.rs index b165309d..cab15991 100644 --- a/crates/notedeck_columns/src/actionbar.rs +++ b/crates/notedeck_columns/src/actionbar.rs @@ -23,12 +23,17 @@ pub struct NewNotes { pub notes: Vec, } +pub enum NotesOpenResult { + Timeline(TimelineOpenResult), + Thread(NewThreadNotes), +} + pub enum TimelineOpenResult { NewNotes(NewNotes), } struct NoteActionResponse { - timeline_res: Option, + timeline_res: Option, router_action: Option, } @@ -58,7 +63,9 @@ fn execute_note_action( NoteAction::Profile(pubkey) => { let kind = TimelineKind::Profile(pubkey); router_action = Some(RouterAction::route_to(Route::Timeline(kind.clone()))); - timeline_res = timeline_cache.open(ndb, note_cache, txn, pool, &kind); + timeline_res = timeline_cache + .open(ndb, note_cache, txn, pool, &kind) + .map(NotesOpenResult::Timeline); } NoteAction::Note { note_id, preview } => 'ex: { let Ok(thread_selection) = ThreadSelection::from_note_id(ndb, note_cache, txn, note_id) @@ -71,12 +78,16 @@ fn execute_note_action( router_action = Some(RouterAction::route_to(Route::Timeline(kind.clone()))); // NOTE!!: you need the note_id to timeline root id thing - timeline_res = timeline_cache.open(ndb, note_cache, txn, pool, &kind); + timeline_res = timeline_cache + .open(ndb, note_cache, txn, pool, &kind) + .map(NotesOpenResult::Timeline); } NoteAction::Hashtag(htag) => { let kind = TimelineKind::Hashtag(htag.clone()); router_action = Some(RouterAction::route_to(Route::Timeline(kind.clone()))); - timeline_res = timeline_cache.open(ndb, note_cache, txn, pool, &kind); + timeline_res = timeline_cache + .open(ndb, note_cache, txn, pool, &kind) + .map(NotesOpenResult::Timeline); } NoteAction::Quote(note_id) => { router_action = Some(RouterAction::route_to(Route::quote(note_id))); @@ -180,7 +191,12 @@ pub fn execute_and_process_note_action( ); if let Some(br) = resp.timeline_res { - br.process(ndb, note_cache, txn, timeline_cache, unknown_ids); + match br { + NotesOpenResult::Timeline(timeline_open_result) => { + timeline_open_result.process(ndb, note_cache, txn, timeline_cache, unknown_ids); + } + NotesOpenResult::Thread(new_thread_notes) => todo!(), + } } resp.router_action