From 34aef30fed0882ce4dae22318bdc0128527c77e5 Mon Sep 17 00:00:00 2001 From: kernelkind Date: Fri, 11 Oct 2024 17:58:29 -0400 Subject: [PATCH] click on thread pfp Signed-off-by: kernelkind --- src/timeline/route.rs | 13 ++++++++----- src/ui/thread.rs | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/timeline/route.rs b/src/timeline/route.rs index 85fae01..f83aa08 100644 --- a/src/timeline/route.rs +++ b/src/timeline/route.rs @@ -72,18 +72,20 @@ pub fn render_timeline_route( } TimelineRoute::Thread(id) => { - if let Some(bar_action) = + let timeline_response = ui::ThreadView::new(threads, ndb, note_cache, img_cache, id.bytes(), textmode) .id_source(egui::Id::new(("threadscroll", col))) - .ui(ui) - { + .ui(ui); + if let Some(bar_action) = timeline_response.bar_action { let txn = Transaction::new(ndb).expect("txn"); let mut cur_column = columns.columns_mut(); let router = cur_column[col].router_mut(); bar_action.execute_and_process_result(ndb, router, threads, note_cache, pool, &txn); } - None + timeline_response + .open_profile + .map(AfterRouteExecution::OpenProfile) } TimelineRoute::Reply(id) => { @@ -164,7 +166,8 @@ pub fn render_profile_route( col: usize, ui: &mut egui::Ui, ) -> Option { - let timeline_response = ProfileView::new(pubkey, id, columns, ndb, note_cache, img_cache).ui(ui); + let timeline_response = + ProfileView::new(pubkey, id, columns, ndb, note_cache, img_cache).ui(ui); if let Some(bar_action) = timeline_response.bar_action { let txn = nostrdb::Transaction::new(ndb).expect("txn"); let mut cur_column = columns.columns_mut(); diff --git a/src/ui/thread.rs b/src/ui/thread.rs index 44ff6f8..a65881e 100644 --- a/src/ui/thread.rs +++ b/src/ui/thread.rs @@ -1,6 +1,7 @@ use crate::{ - actionbar::BarAction, imgcache::ImageCache, notecache::NoteCache, thread::Threads, ui, + actionbar::{BarAction, TimelineResponse}, imgcache::ImageCache, notecache::NoteCache, thread::Threads, ui, }; +use enostr::Pubkey; use nostrdb::{Ndb, NoteKey, Transaction}; use tracing::{error, warn}; @@ -41,9 +42,10 @@ impl<'a> ThreadView<'a> { self } - pub fn ui(&mut self, ui: &mut egui::Ui) -> Option { + pub fn ui(&mut self, ui: &mut egui::Ui) -> TimelineResponse { let txn = Transaction::new(self.ndb).expect("txn"); let mut action: Option = None; + let mut open_profile = None; let selected_note_key = if let Ok(key) = self .ndb @@ -53,7 +55,7 @@ impl<'a> ThreadView<'a> { key } else { // TODO: render 404 ? - return None; + return TimelineResponse::default(); }; ui.label( @@ -124,6 +126,9 @@ impl<'a> ThreadView<'a> { if let Some(bar_action) = note_response.action { action = Some(bar_action); } + if note_response.clicked_profile { + open_profile = Some(Pubkey::new(*note.pubkey())) + } if let Some(selection) = note_response.context_selection { selection.process(ui, ¬e); @@ -138,6 +143,9 @@ impl<'a> ThreadView<'a> { ); }); - action + TimelineResponse { + bar_action: action, + open_profile, + } } }