diff --git a/assets/icons/accounts.png b/assets/icons/accounts.png new file mode 100644 index 00000000..2671f225 Binary files /dev/null and b/assets/icons/accounts.png differ diff --git a/crates/notedeck_chrome/src/chrome.rs b/crates/notedeck_chrome/src/chrome.rs index bca43a0a..d04771ae 100644 --- 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: ¬edeck::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 index cd0dc2f5..4433ed98 100644 --- 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 index 719fe92a..1306bd24 100644 --- 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"