diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs index 0c268b3d..c6814fc3 100644 --- a/crates/notedeck_columns/src/nav.rs +++ b/crates/notedeck_columns/src/nav.rs @@ -406,6 +406,7 @@ fn process_render_nav_action( &mut app.view_state.pubkey_to_profile_state, 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 cb07a37d..94e63831 100644 --- a/crates/notedeck_columns/src/profile.rs +++ b/crates/notedeck_columns/src/profile.rs @@ -38,6 +38,8 @@ fn add_client_tag(builder: NoteBuilder<'_>) -> NoteBuilder<'_> { pub enum ProfileAction { Edit(FullKeypair), SaveChanges(SaveProfileChanges), + Follow(Pubkey), + Unfollow(Pubkey), } impl ProfileAction { @@ -46,6 +48,7 @@ impl ProfileAction { state_map: &mut HashMap, ndb: &Ndb, pool: &mut RelayPool, + accounts: &Accounts, ) -> Option { match self { ProfileAction::Edit(kp) => Some(RouterAction::route_to(Route::EditProfile(kp.pubkey))), @@ -63,6 +66,14 @@ impl ProfileAction { Some(RouterAction::GoBack) } + ProfileAction::Follow(target_key) => { + Self::send_follow_user_event(ndb, pool, accounts, target_key); + None + } + ProfileAction::Unfollow(target_key) => { + Self::send_unfollow_user_event(ndb, pool, accounts, target_key); + None + } } } diff --git a/crates/notedeck_columns/src/timeline/route.rs b/crates/notedeck_columns/src/timeline/route.rs index fc034d30..64d99a71 100644 --- a/crates/notedeck_columns/src/timeline/route.rs +++ b/crates/notedeck_columns/src/timeline/route.rs @@ -116,7 +116,7 @@ pub fn render_profile_route( note_context: &mut NoteContext, jobs: &mut JobsCache, ) -> Option { - let action = ProfileView::new( + let profile_view = ProfileView::new( pubkey, accounts, col, @@ -128,7 +128,7 @@ pub fn render_profile_route( ) .ui(ui); - if let Some(action) = action { + if let Some(action) = profile_view { match action { ui::profile::ProfileViewAction::EditProfile => accounts .get_full(pubkey) @@ -136,6 +136,12 @@ pub fn render_profile_route( ui::profile::ProfileViewAction::Note(note_action) => { Some(RenderNavAction::NoteAction(note_action)) } + ui::profile::ProfileViewAction::Follow(target_key) => Some( + RenderNavAction::ProfileAction(ProfileAction::Follow(target_key)), + ), + ui::profile::ProfileViewAction::Unfollow(target_key) => Some( + RenderNavAction::ProfileAction(ProfileAction::Unfollow(target_key)), + ), } } else { None diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs index a883e171..c8693965 100644 --- a/crates/notedeck_columns/src/ui/profile/mod.rs +++ b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -35,6 +35,8 @@ pub struct ProfileView<'a, 'd> { pub enum ProfileViewAction { EditProfile, Note(NoteAction), + Unfollow(Pubkey), + Follow(Pubkey), } impl<'a, 'd> ProfileView<'a, 'd> {