Commit 61a0b3c
feat: wire follow/unfollow to SocialController using AuthenticationController profileId (#28843)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
**Wire follow/unfollow persistence via SocialController state**
- Bump @metamask/social-controllers to ^1.0.0 which writes
followingProfileIds to controller state on
follow/unfollow/updateFollowing
- Add AuthenticationController:getBearerToken delegation to
SocialService messenger (required by 1.0.0 for JWT auth on all API
requests)
- Hydrate following state once at Engine startup via
SocialController:updateFollowing
- Read isFollowing from Redux (SocialController.followingProfileIds)
instead of ephemeral local state
- toggleFollow calls SocialController:followTrader/unfollowTrader
directly — controller updates state, Redux syncs, UI re-renders
**Test plan**
1. Follow a trader on homepage carousel > navigate to leaderboard >
follow state persists
2. Unfollow a trader on leaderboard > navigate away and back > unfollow
state persists
3. Follow/unfollow on trader profile > navigate back to leaderboard >
state is consistent
4. Kill and reopen app > follow state survives (controller state is
persisted)
[TSA-389](https://consensyssoftware.atlassian.net/browse/TSA-389)
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Wired up follow/unfollow functionality
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
[TSA-389]:
https://consensyssoftware.atlassian.net/browse/TSA-389?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[TSA-401]:
https://consensyssoftware.atlassian.net/browse/TSA-401?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Introduces new follow/unfollow wiring that calls `SocialController`
via `Engine.controllerMessenger` and runs a new hydration request during
`EngineService.start()`, which could affect app startup behavior and
follow state consistency if messaging/auth fails.
>
> **Overview**
> Moves follow state from local component overrides to **persisted
`SocialController.followingProfileIds` in Redux**, via a new shared hook
`useFollowToggle`/`useFollowToggleMany` that performs **optimistic
follow/unfollow** and dispatches `SocialController:followTrader` /
`SocialController:unfollowTrader` using the session `profileId` from
`AuthenticationController`.
>
> Adds **engine-startup hydration** (`hydrateSocialFollowing`) to
refresh the server following list by calling
`SocialController:updateFollowing` (fire-and-forget, non-fatal on
failure), plus a new selector `selectFollowingProfileIds` and expanded
unit tests to cover seeding from controller state, optimistic updates,
rejection reverts, and in-flight call de-duping.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4637abc. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Xavier Brochard <xavier.brochard@consensys.net>
Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>1 parent 208c27b commit 61a0b3c
13 files changed
Lines changed: 744 additions & 74 deletions
File tree
- app
- components
- Views
- Homepage/Sections/TopTraders/hooks
- SocialLeaderboard/TraderProfileView
- hooks
- hooks
- core
- EngineService
- Engine/controllers
- selectors
Lines changed: 116 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
6 | 16 | | |
7 | 17 | | |
8 | 18 | | |
9 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
10 | 35 | | |
11 | 36 | | |
12 | 37 | | |
| |||
43 | 68 | | |
44 | 69 | | |
45 | 70 | | |
| 71 | + | |
46 | 72 | | |
47 | 73 | | |
48 | 74 | | |
| |||
59 | 85 | | |
60 | 86 | | |
61 | 87 | | |
| 88 | + | |
62 | 89 | | |
63 | 90 | | |
64 | 91 | | |
| |||
158 | 185 | | |
159 | 186 | | |
160 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
161 | 200 | | |
162 | 201 | | |
163 | 202 | | |
164 | 203 | | |
165 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
166 | 209 | | |
167 | 210 | | |
168 | | - | |
| 211 | + | |
169 | 212 | | |
170 | | - | |
171 | 213 | | |
172 | | - | |
173 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
174 | 258 | | |
175 | 259 | | |
176 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
177 | 266 | | |
178 | 267 | | |
179 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
180 | 272 | | |
181 | | - | |
182 | 273 | | |
183 | | - | |
184 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
185 | 277 | | |
186 | 278 | | |
187 | 279 | | |
188 | 280 | | |
189 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
190 | 289 | | |
191 | 290 | | |
192 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
193 | 295 | | |
194 | 296 | | |
195 | 297 | | |
196 | | - | |
197 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
198 | 302 | | |
199 | 303 | | |
200 | 304 | | |
| |||
Lines changed: 6 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 24 | | |
38 | 25 | | |
39 | 26 | | |
| |||
51 | 38 | | |
52 | 39 | | |
53 | 40 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 41 | + | |
57 | 42 | | |
58 | 43 | | |
59 | 44 | | |
| |||
68 | 53 | | |
69 | 54 | | |
70 | 55 | | |
71 | | - | |
| 56 | + | |
72 | 57 | | |
73 | | - | |
| 58 | + | |
74 | 59 | | |
75 | 60 | | |
76 | 61 | | |
| |||
81 | 66 | | |
82 | 67 | | |
83 | 68 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | 69 | | |
92 | 70 | | |
93 | 71 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
1 | 6 | | |
2 | | - | |
| 7 | + | |
3 | 8 | | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments