add actions for follow/unfollow

Signed-off-by: kernelkind <kernelkind@gmail.com>
Co-authored-by: Jakub Gladysz <jakub.gladysz@protonmail.com>
Co-authored-by: William Casarin <jb55@jb55.com>
This commit is contained in:
kernelkind
2025-07-05 14:26:24 -04:00
parent 00d6651533
commit a883ac8c34
4 changed files with 22 additions and 2 deletions

View File

@@ -406,6 +406,7 @@ fn process_render_nav_action(
&mut app.view_state.pubkey_to_profile_state, &mut app.view_state.pubkey_to_profile_state,
ctx.ndb, ctx.ndb,
ctx.pool, ctx.pool,
ctx.accounts,
), ),
RenderNavAction::WalletAction(wallet_action) => { RenderNavAction::WalletAction(wallet_action) => {
wallet_action.process(ctx.accounts, ctx.global_wallet) wallet_action.process(ctx.accounts, ctx.global_wallet)

View File

@@ -38,6 +38,8 @@ fn add_client_tag(builder: NoteBuilder<'_>) -> NoteBuilder<'_> {
pub enum ProfileAction { pub enum ProfileAction {
Edit(FullKeypair), Edit(FullKeypair),
SaveChanges(SaveProfileChanges), SaveChanges(SaveProfileChanges),
Follow(Pubkey),
Unfollow(Pubkey),
} }
impl ProfileAction { impl ProfileAction {
@@ -46,6 +48,7 @@ impl ProfileAction {
state_map: &mut HashMap<Pubkey, ProfileState>, state_map: &mut HashMap<Pubkey, ProfileState>,
ndb: &Ndb, ndb: &Ndb,
pool: &mut RelayPool, pool: &mut RelayPool,
accounts: &Accounts,
) -> Option<RouterAction> { ) -> Option<RouterAction> {
match self { match self {
ProfileAction::Edit(kp) => Some(RouterAction::route_to(Route::EditProfile(kp.pubkey))), ProfileAction::Edit(kp) => Some(RouterAction::route_to(Route::EditProfile(kp.pubkey))),
@@ -63,6 +66,14 @@ impl ProfileAction {
Some(RouterAction::GoBack) 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
}
} }
} }

View File

@@ -116,7 +116,7 @@ pub fn render_profile_route(
note_context: &mut NoteContext, note_context: &mut NoteContext,
jobs: &mut JobsCache, jobs: &mut JobsCache,
) -> Option<RenderNavAction> { ) -> Option<RenderNavAction> {
let action = ProfileView::new( let profile_view = ProfileView::new(
pubkey, pubkey,
accounts, accounts,
col, col,
@@ -128,7 +128,7 @@ pub fn render_profile_route(
) )
.ui(ui); .ui(ui);
if let Some(action) = action { if let Some(action) = profile_view {
match action { match action {
ui::profile::ProfileViewAction::EditProfile => accounts ui::profile::ProfileViewAction::EditProfile => accounts
.get_full(pubkey) .get_full(pubkey)
@@ -136,6 +136,12 @@ pub fn render_profile_route(
ui::profile::ProfileViewAction::Note(note_action) => { ui::profile::ProfileViewAction::Note(note_action) => {
Some(RenderNavAction::NoteAction(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 { } else {
None None

View File

@@ -35,6 +35,8 @@ pub struct ProfileView<'a, 'd> {
pub enum ProfileViewAction { pub enum ProfileViewAction {
EditProfile, EditProfile,
Note(NoteAction), Note(NoteAction),
Unfollow(Pubkey),
Follow(Pubkey),
} }
impl<'a, 'd> ProfileView<'a, 'd> { impl<'a, 'd> ProfileView<'a, 'd> {