click on thread pfp

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-10-11 17:58:29 -04:00
parent 8e6a982843
commit 34aef30fed
2 changed files with 20 additions and 9 deletions

View File

@@ -72,18 +72,20 @@ pub fn render_timeline_route(
} }
TimelineRoute::Thread(id) => { TimelineRoute::Thread(id) => {
if let Some(bar_action) = let timeline_response =
ui::ThreadView::new(threads, ndb, note_cache, img_cache, id.bytes(), textmode) ui::ThreadView::new(threads, ndb, note_cache, img_cache, id.bytes(), textmode)
.id_source(egui::Id::new(("threadscroll", col))) .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 txn = Transaction::new(ndb).expect("txn");
let mut cur_column = columns.columns_mut(); let mut cur_column = columns.columns_mut();
let router = cur_column[col].router_mut(); let router = cur_column[col].router_mut();
bar_action.execute_and_process_result(ndb, router, threads, note_cache, pool, &txn); bar_action.execute_and_process_result(ndb, router, threads, note_cache, pool, &txn);
} }
None timeline_response
.open_profile
.map(AfterRouteExecution::OpenProfile)
} }
TimelineRoute::Reply(id) => { TimelineRoute::Reply(id) => {
@@ -164,7 +166,8 @@ pub fn render_profile_route(
col: usize, col: usize,
ui: &mut egui::Ui, ui: &mut egui::Ui,
) -> Option<AfterRouteExecution> { ) -> Option<AfterRouteExecution> {
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 { if let Some(bar_action) = timeline_response.bar_action {
let txn = nostrdb::Transaction::new(ndb).expect("txn"); let txn = nostrdb::Transaction::new(ndb).expect("txn");
let mut cur_column = columns.columns_mut(); let mut cur_column = columns.columns_mut();

View File

@@ -1,6 +1,7 @@
use crate::{ 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 nostrdb::{Ndb, NoteKey, Transaction};
use tracing::{error, warn}; use tracing::{error, warn};
@@ -41,9 +42,10 @@ impl<'a> ThreadView<'a> {
self self
} }
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<BarAction> { pub fn ui(&mut self, ui: &mut egui::Ui) -> TimelineResponse {
let txn = Transaction::new(self.ndb).expect("txn"); let txn = Transaction::new(self.ndb).expect("txn");
let mut action: Option<BarAction> = None; let mut action: Option<BarAction> = None;
let mut open_profile = None;
let selected_note_key = if let Ok(key) = self let selected_note_key = if let Ok(key) = self
.ndb .ndb
@@ -53,7 +55,7 @@ impl<'a> ThreadView<'a> {
key key
} else { } else {
// TODO: render 404 ? // TODO: render 404 ?
return None; return TimelineResponse::default();
}; };
ui.label( ui.label(
@@ -124,6 +126,9 @@ impl<'a> ThreadView<'a> {
if let Some(bar_action) = note_response.action { if let Some(bar_action) = note_response.action {
action = Some(bar_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 { if let Some(selection) = note_response.context_selection {
selection.process(ui, &note); selection.process(ui, &note);
@@ -138,6 +143,9 @@ impl<'a> ThreadView<'a> {
); );
}); });
action TimelineResponse {
bar_action: action,
open_profile,
}
} }
} }