Commit 7de5b8b
Guilherme Souza
feat(realtime): add presence-enabled flag to join push (#736)
* feat(realtime): add presence-enabled flag to join push
- Add presenceEnabled property to RealtimeJoinConfig
- Update CallbackManager to handle presence-enabled joins
- Modify RealtimeChannelV2 to support presence-enabled configuration
- Add tests for presence-enabled functionality
- Update .gitignore for new test artifacts
This change allows developers to explicitly enable/disable presence
functionality when joining realtime channels, providing better control
over presence behavior in realtime subscriptions.
* test(realtime): add test for presence enabled flag during subscribe
- Add comprehensive test that verifies presence.enabled is set to true when presence callback exists
- Test uses FakeWebSocket to simulate real subscription flow
- Verifies that presence enabled flag is correctly set in phx_join payload
- Ensures proper cleanup of subscriptions and connections
This test validates the core functionality where presence enabled is automatically set based on presence callback existence.
* fix(realtime): resubscribe channel when presence callback added to subscribed channel
When a presence callback is added to an already subscribed channel, the channel now automatically resubscribes to ensure the presence functionality works correctly. This fixes an issue where presence callbacks added after subscription would not receive presence updates.
- Add resubscription logic in onPresenceChange method
- Log debug message when resubscribing
- Maintain existing callback registration behavior1 parent 09f047b commit 7de5b8b
File tree
6 files changed
+96
-2
lines changed- Sources/Realtime
- Tests/RealtimeTests
6 files changed
+96
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
207 | 215 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| 102 | + | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
| |||
168 | 172 | | |
169 | 173 | | |
170 | 174 | | |
| 175 | + | |
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
| |||
374 | 379 | | |
375 | 380 | | |
376 | 381 | | |
377 | | - | |
| 382 | + | |
378 | 383 | | |
379 | 384 | | |
380 | 385 | | |
| |||
396 | 401 | | |
397 | 402 | | |
398 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
399 | 414 | | |
| 415 | + | |
400 | 416 | | |
401 | 417 | | |
402 | 418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
131 | 195 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| |||
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| 245 | + | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
| |||
264 | 266 | | |
265 | 267 | | |
266 | 268 | | |
| 269 | + | |
267 | 270 | | |
268 | 271 | | |
269 | 272 | | |
| |||
0 commit comments