Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/notedeck/src/profile/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use enostr::Pubkey;

pub enum ProfileContextSelection {
AddProfileColumn,
CopyLink,
ViewAs,
}
Expand All @@ -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
}
}
Expand Down
12 changes: 9 additions & 3 deletions crates/notedeck_columns/src/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
30 changes: 28 additions & 2 deletions crates/notedeck_columns/src/profile.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions crates/notedeck_ui/src/profile/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down