From 75bd363fc126c7644ba38cdbdbba8e52eb825cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Lo=CC=81pez=20Guevara?= Date: Mon, 1 Dec 2025 11:12:42 -0300 Subject: [PATCH] =?UTF-8?q?feat(profile=5Fview):=20add=20profile=20column?= =?UTF-8?q?=20from=20context=20options=20only=20when=20it=E2=80=99s=20miss?= =?UTF-8?q?ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/notedeck/src/profile/context.rs | 3 ++- crates/notedeck_columns/src/nav.rs | 12 ++++++--- crates/notedeck_columns/src/profile.rs | 30 +++++++++++++++++++++-- crates/notedeck_ui/src/profile/context.rs | 12 +++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/crates/notedeck/src/profile/context.rs b/crates/notedeck/src/profile/context.rs index 637ad9395..7787e3357 100644 --- a/crates/notedeck/src/profile/context.rs +++ b/crates/notedeck/src/profile/context.rs @@ -1,6 +1,7 @@ use enostr::Pubkey; pub enum ProfileContextSelection { + AddProfileColumn, CopyLink, ViewAs, } @@ -20,7 +21,7 @@ impl ProfileContextSelection { ctx.copy_text(format!("https://damus.io/{npub}")); } - ProfileContextSelection::ViewAs => { + ProfileContextSelection::ViewAs | ProfileContextSelection::AddProfileColumn => { // handled separately in profile.rs } } diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs index 998ba83d0..a7b695a63 100644 --- a/crates/notedeck_columns/src/nav.rs +++ b/crates/notedeck_columns/src/nav.rs @@ -567,9 +567,15 @@ fn process_render_nav_action( return None; } } - RenderNavAction::ProfileAction(profile_action) => { - profile_action.process_profile_action(ui.ctx(), ctx.ndb, ctx.pool, ctx.accounts) - } + RenderNavAction::ProfileAction(profile_action) => profile_action.process_profile_action( + app, + ctx.path, + ctx.i18n, + ui.ctx(), + ctx.ndb, + ctx.pool, + ctx.accounts, + ), RenderNavAction::WalletAction(wallet_action) => { wallet_action.process(ctx.accounts, ctx.global_wallet) } diff --git a/crates/notedeck_columns/src/profile.rs b/crates/notedeck_columns/src/profile.rs index 6a393f584..5af067369 100644 --- a/crates/notedeck_columns/src/profile.rs +++ b/crates/notedeck_columns/src/profile.rs @@ -1,10 +1,10 @@ use enostr::{FilledKeypair, FullKeypair, ProfileState, Pubkey, RelayPool}; use nostrdb::{Ndb, Note, NoteBuildOptions, NoteBuilder, Transaction}; -use notedeck::{Accounts, ContactState, ProfileContext}; +use notedeck::{Accounts, ContactState, DataPath, Localization, ProfileContext}; use tracing::info; -use crate::{nav::RouterAction, route::Route}; +use crate::{column::Column, nav::RouterAction, route::Route, storage, Damus}; pub struct SaveProfileChanges { pub kp: FullKeypair, @@ -44,6 +44,9 @@ pub enum ProfileAction { impl ProfileAction { pub fn process_profile_action( &self, + app: &mut Damus, + path: &DataPath, + i18n: &mut Localization, ctx: &egui::Context, ndb: &Ndb, pool: &mut RelayPool, @@ -85,6 +88,29 @@ impl ProfileAction { ProfileContextSelection::ViewAs => { Some(RouterAction::SwitchAccount(profile_context.profile)) } + ProfileContextSelection::AddProfileColumn => { + let timeline_route = Route::Timeline( + crate::timeline::TimelineKind::Profile(profile_context.profile), + ); + + let missing_column = { + let deck_columns = app.columns(accounts).columns(); + let router_head = &[timeline_route.clone()]; + !deck_columns + .iter() + .any(|column| column.router.routes().starts_with(router_head)) + }; + + if missing_column { + let column = Column::new(vec![timeline_route]); + + app.columns_mut(i18n, accounts).add_column(column); + + storage::save_decks_cache(path, &app.decks_cache); + } + + None + } _ => { profile_context .selection diff --git a/crates/notedeck_ui/src/profile/context.rs b/crates/notedeck_ui/src/profile/context.rs index 24ede8b2f..f41b5b832 100644 --- a/crates/notedeck_ui/src/profile/context.rs +++ b/crates/notedeck_ui/src/profile/context.rs @@ -34,6 +34,18 @@ impl ProfileContextWidget { stationary_arbitrary_menu_button(ui, button_response, |ui| { ui.set_max_width(100.0); + if ui + .button(tr!( + i18n, + "Add profile column", + "Add new column to current deck from profile context menu" + )) + .clicked() + { + context_selection = Some(ProfileContextSelection::AddProfileColumn); + ui.close_menu(); + } + if ui .button(tr!(i18n, "View as", "Switch active user to this profile")) .clicked()