From baff14bbf0f3db9647e986b12e95be5e171941c0 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 15 Jul 2025 10:51:02 -0700 Subject: [PATCH] ui/column: include pfp in back response We were missing the pfp in the back response Fixes: https://github.com/damus-io/notedeck/issues/923 Signed-off-by: William Casarin --- crates/notedeck_columns/src/nav.rs | 28 +++++++++++++++---- .../notedeck_columns/src/ui/column/header.rs | 9 ++++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs index 5bfb9b7..0bdf9f7 100644 --- a/crates/notedeck_columns/src/nav.rs +++ b/crates/notedeck_columns/src/nav.rs @@ -323,6 +323,14 @@ pub enum RouterType { Stack, } +fn go_back(stack: &mut Router, sheet: &mut SingletonRouter) { + if sheet.route().is_some() { + sheet.go_back(); + } else { + stack.go_back(); + } +} + impl RouterAction { pub fn process( self, @@ -331,16 +339,24 @@ impl RouterAction { ) -> Option { match self { RouterAction::GoBack => { - if sheet_router.route().is_some() { - sheet_router.go_back(); - } else { - stack_router.go_back(); - } + go_back(stack_router, sheet_router); None } - RouterAction::PfpClicked => Some(ProcessNavResult::PfpClicked), + RouterAction::PfpClicked => { + if stack_router.routes().len() == 1 { + // if we're at the top level and we click a profile pic, + // bubble it up so that it can be handled by the chrome + // to open the sidebar + Some(ProcessNavResult::PfpClicked) + } else { + // Otherwise just execute a back action + go_back(stack_router, sheet_router); + + None + } + } RouterAction::RouteTo(route, router_type) => match router_type { RouterType::Sheet => { diff --git a/crates/notedeck_columns/src/ui/column/header.rs b/crates/notedeck_columns/src/ui/column/header.rs index d3019a1..b7382c7 100644 --- a/crates/notedeck_columns/src/ui/column/header.rs +++ b/crates/notedeck_columns/src/ui/column/header.rs @@ -129,8 +129,7 @@ impl<'a> NavTitle<'a> { // NOTE(jb55): include graphic in back label as well because why // not it looks cool - self.title_pfp(ui, prev, 32.0); - + let pfp_resp = self.title_pfp(ui, prev, 32.0); let column_title = prev.title(); let back_resp = match &column_title { @@ -143,7 +142,11 @@ impl<'a> NavTitle<'a> { } }; - back_resp.union(chev_resp) + if let Some(pfp_resp) = pfp_resp { + back_resp.union(chev_resp).union(pfp_resp) + } else { + back_resp.union(chev_resp) + } } fn back_label(title: &str, color: egui::Color32) -> egui::Label {