Commit 5a5972c
authored
fix: add flag to avoid thread cleanup when updating channel state (#1702)
## CLA
- [ ] I have signed the [Stream
CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform)
(required).
- [ ] Code changes are tested
## Description of the changes, What, Why and How?
https://getstream.zendesk.com/agent/tickets/77916
Bug report:
- In RN, sometimes existing messages from the thread are wiped out after
the app is moved from the background <-> foreground
- The customer says it happens for React, too, but there is no
additional information there
- What I found (couldn't reproduce, but there is a possible code path):
- RN fires a `queryChannels` and `reloadThread` calls independently from
each other on state recovery. If `queryChannels` finishes after
`reloadThread`, the thread clean up wipes out thread messages.
- Since SDKs don't rely on threads being cleaned up (they always call
`getReplies` when a thread is opened), we could remove the thread
cleanup code. The reason I didn't want to do that because I think it's
possible that integrators using client directly may do something like:
```
if (!channel.state.threads[message.id]) {
// get replies only if the thread is not initialized
}
```
- So I introduced a flag in the client as a somewhat hacky workaround ->
since we're planning a state rewrite anyway, I didn't want to spend any
more time in this rabbithole
- For React: I couldn't reproduce, nor could I see a viable code path
for this: as far as I can tell in the React thread reload happens in
response to parent message reference changing, which ensures that thread
reload can happen only after `queryChannels` finishes. We can ask the
customer to open a separate ticket for React, if they still the issue
there.
## Changelog
-1 parent fd86795 commit 5a5972c
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
247 | 252 | | |
248 | 253 | | |
249 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
324 | 329 | | |
325 | 330 | | |
326 | 331 | | |
| |||
0 commit comments