Commit 8c65058
authored
fix: properly delete drafts with quoted messages (#1573)
## 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?
This PR fixes an issue where `draft`s containing a `quotedMessage` were
never cleared from the `messageComposer` state unless manually deleted.
The easiest way to reproduce this is to:
- Create a `draft` that contains a quoted message
- Make sure the draft is there on the server (reload or whatever suits
best)
- Send the draft message from whichever SDK is being used
- Reload the app again
- The draft will still be there and no matter how many times we send it
it is never going to be removed
The reason this happens is [this
check](https://github.com/GetStream/stream-chat-js/blob/7dcf10dd4f5234fbc228409222d003e90f6a020d/src/messageComposer/messageComposer.ts#L298),
which is used to determine whether a draft should be deleted on pretty
much all `state` listeners in the `messageComposer`, [like
so](https://github.com/GetStream/stream-chat-js/blob/7dcf10dd4f5234fbc228409222d003e90f6a020d/src/messageComposer/messageComposer.ts#L512).
However, since we're doing `messageComposer.clear()` every time we send
a message the composite invocation never clears the quoted message state
whenever that happens (as seen
[here](https://github.com/GetStream/stream-chat-js/blob/7dcf10dd4f5234fbc228409222d003e90f6a020d/src/messageComposer/messageComposer.ts#L624)
and then
[here](https://github.com/GetStream/stream-chat-js/blob/7dcf10dd4f5234fbc228409222d003e90f6a020d/src/messageComposer/messageComposer.ts#L328)).
This in turn causes `channel.deleteDraft` to never be invoked hence the
bug.
## Changelog
-1 parent 7dcf10d commit 8c65058
File tree
2 files changed
+2
-0
lines changed- src/messageComposer
- test/unit/MessageComposer
2 files changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
| 624 | + | |
624 | 625 | | |
625 | 626 | | |
626 | 627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
| 704 | + | |
704 | 705 | | |
705 | 706 | | |
706 | 707 | | |
| |||
0 commit comments