notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit f722a58d66ebf921293da4a51cd9f0215834d885
parent ffcd38ef968a1110c83806586d9af8c75c21d5c4
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 23 Jul 2025 09:12:23 -0700

Merge new Accounts button to chrome sidebar by kernel #994

kernelkind (3):
      use saturating sub
      add new Accounts button to chrome sidebar
      add ChromePanelAction::Profile & use for pfp

Diffstat:
Aassets/icons/accounts.png | 0
Mcrates/notedeck_chrome/src/chrome.rs | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/notedeck_columns/src/multi_subscriber.rs | 10++++------
Mcrates/notedeck_ui/src/app_images.rs | 4++++
4 files changed, 79 insertions(+), 6 deletions(-)

diff --git a/assets/icons/accounts.png b/assets/icons/accounts.png Binary files differ. diff --git a/crates/notedeck_chrome/src/chrome.rs b/crates/notedeck_chrome/src/chrome.rs @@ -58,6 +58,7 @@ pub enum ChromePanelAction { Wallet, Toolbar(ToolbarAction), SaveTheme(ThemePreference), + Profile(notedeck::enostr::Pubkey), } impl ChromePanelAction { @@ -160,6 +161,9 @@ impl ChromePanelAction { notedeck_columns::Route::Wallet(WalletType::Auto), ); } + Self::Profile(pk) => { + columns_route_to_profile(pk, chrome, ctx, ui); + } } } } @@ -571,6 +575,16 @@ fn columns_button(ui: &mut egui::Ui) -> egui::Response { ) } +fn accounts_button(ui: &mut egui::Ui) -> egui::Response { + expanding_button( + "accounts-button", + 24.0, + app_images::accounts_image().tint(ui.visuals().text_color()), + app_images::accounts_image(), + ui, + ) +} + fn dave_sidebar_rect(ui: &mut egui::Ui) -> Rect { let size = vec2(60.0, 60.0); let available = ui.available_rect_before_wrap(); @@ -693,6 +707,59 @@ fn chrome_handle_app_action( } } +fn columns_route_to_profile( + pk: &notedeck::enostr::Pubkey, + chrome: &mut Chrome, + ctx: &mut AppContext, + ui: &mut egui::Ui, +) { + chrome.switch_to_columns(); + let Some(columns) = chrome.get_columns_app() else { + return; + }; + + let cols = columns + .decks_cache + .active_columns_mut(ctx.i18n, ctx.accounts) + .unwrap(); + + let router = cols.get_first_router(); + if router.routes().iter().any(|r| { + matches!( + r, + notedeck_columns::Route::Timeline(TimelineKind::Profile(_)) + ) + }) { + router.go_back(); + return; + } + + let txn = Transaction::new(ctx.ndb).unwrap(); + let m_action = notedeck_columns::actionbar::execute_and_process_note_action( + notedeck::NoteAction::Profile(*pk), + ctx.ndb, + cols, + 0, + &mut columns.timeline_cache, + &mut columns.threads, + ctx.note_cache, + ctx.pool, + &txn, + ctx.unknown_ids, + ctx.accounts, + ctx.global_wallet, + ctx.zaps, + ctx.img_cache, + ui, + ); + + if let Some(action) = m_action { + let col = cols.column_mut(0); + + action.process(&mut col.router, &mut col.sheet_router); + } +} + fn pfp_button(ctx: &mut AppContext, ui: &mut egui::Ui) -> egui::Response { let max_size = ICON_WIDTH * ICON_EXPANSION_MULTIPLE; // max size of the widget let helper = AnimationHelper::new(ui, "pfp-button", egui::vec2(max_size, max_size)); @@ -720,6 +787,7 @@ fn bottomup_sidebar( ui.add_space(8.0); let pfp_resp = pfp_button(ctx, ui).on_hover_cursor(egui::CursorIcon::PointingHand); + let accounts_resp = accounts_button(ui).on_hover_cursor(egui::CursorIcon::PointingHand); let settings_resp = settings_button(ui).on_hover_cursor(egui::CursorIcon::PointingHand); let theme_action = match ui.ctx().theme() { @@ -791,6 +859,9 @@ fn bottomup_sidebar( } if pfp_resp.clicked() { + let pk = ctx.accounts.get_selected_account().key.pubkey; + Some(ChromePanelAction::Profile(pk)) + } else if accounts_resp.clicked() { Some(ChromePanelAction::Account) } else if settings_resp.clicked() { Some(ChromePanelAction::Settings) diff --git a/crates/notedeck_columns/src/multi_subscriber.rs b/crates/notedeck_columns/src/multi_subscriber.rs @@ -474,12 +474,10 @@ impl TimelineSub { let before = self.state.clone(); 's: { match &mut self.state { - SubState::NoSub { dependers } => { - *dependers -= 1; - } + SubState::NoSub { dependers } => *dependers = dependers.saturating_sub(1), SubState::LocalOnly { local, dependers } => { if *dependers > 1 { - *dependers -= 1; + *dependers = dependers.saturating_sub(1); break 's; } @@ -492,7 +490,7 @@ impl TimelineSub { } SubState::RemoteOnly { remote, dependers } => { if *dependers > 1 { - *dependers -= 1; + *dependers = dependers.saturating_sub(1); break 's; } @@ -502,7 +500,7 @@ impl TimelineSub { } SubState::Unified { unified, dependers } => { if *dependers > 1 { - *dependers -= 1; + *dependers = dependers.saturating_sub(1); break 's; } diff --git a/crates/notedeck_ui/src/app_images.rs b/crates/notedeck_ui/src/app_images.rs @@ -11,6 +11,10 @@ pub fn add_account_image() -> Image<'static> { )) } +pub fn accounts_image() -> Image<'static> { + Image::new(include_image!("../../../assets/icons/accounts.png")) +} + pub fn add_column_dark_image() -> Image<'static> { Image::new(include_image!( "../../../assets/icons/add_column_dark_4x.png"