Commit 23804e2
Auto-follow contest when user downloads a stem (#14295)
## Summary
Downloading a stem is a strong engagement signal that the user wants to
participate in the contest, so this PR wires `ContestStemsCard` (mobile
+ web) to fire `useFollowEvent` for the parent contest the first time a
signed-in user kicks off a download.
## Implementation
Both surfaces use the same shape:
- Resolve the contest event from the card's existing `trackId` prop via
`useRemixContest` (same pattern `ContestScreen` / desktop `ContestPage`
already use).
- Pair with `useCurrentUserId` + `useEventFollowState`, then guard a
`followContestIfNeeded` helper on (signed-in + not already following).
- Call the helper inside both download handlers:
- **Mobile**
(`packages/mobile/src/screens/contest-screen/ContestStemsCard.tsx`):
inside `handleDownloadOne` and `handleDownloadAll` (both open
`WaitForDownloadModal`).
- **Web**
(`packages/web/src/pages/contest-page/components/ContestStemsCard.tsx`):
inside the two `useRequiresAccountCallback`-wrapped handlers —
`handleDownloadAll` (archive modal) and `handleDownloadOne`
(wait-for-download modal). Sitting inside the
`useRequiresAccountCallback` means the follow only fires after the
sign-in gate has resolved, so we never call `followEvent({ userId: null,
... })`.
The follow mutation is optimistic (see
`packages/common/src/api/tan-query/events/useFollowEvent.ts`), so the
contest's Follow button flips to \"Following\" instantly with automatic
rollback on error.
## 1 parent 74e248b commit 23804e2
2 files changed
Lines changed: 63 additions & 4 deletions
File tree
- packages
- mobile/src/screens/contest-screen
- web/src/pages/contest-page/components
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
4 | 13 | | |
5 | 14 | | |
6 | 15 | | |
| |||
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
108 | 135 | | |
| 136 | + | |
109 | 137 | | |
110 | 138 | | |
111 | 139 | | |
| |||
115 | 143 | | |
116 | 144 | | |
117 | 145 | | |
| 146 | + | |
118 | 147 | | |
119 | 148 | | |
120 | 149 | | |
| |||
Lines changed: 32 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
98 | 120 | | |
99 | 121 | | |
100 | 122 | | |
| |||
129 | 151 | | |
130 | 152 | | |
131 | 153 | | |
| 154 | + | |
132 | 155 | | |
133 | 156 | | |
134 | 157 | | |
135 | 158 | | |
136 | 159 | | |
137 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
138 | 167 | | |
139 | 168 | | |
140 | 169 | | |
| |||
153 | 182 | | |
154 | 183 | | |
155 | 184 | | |
| 185 | + | |
156 | 186 | | |
157 | 187 | | |
158 | 188 | | |
159 | 189 | | |
160 | 190 | | |
161 | 191 | | |
162 | | - | |
| 192 | + | |
163 | 193 | | |
164 | 194 | | |
165 | 195 | | |
| |||
0 commit comments