Skip to content

Commit 366871f

Browse files
committed
fix: multi poll sending edge case
1 parent 7c0751d commit 366871f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import {
1616
// createDraftCommandInjectionMiddleware,
1717
LocalMessage,
1818
Message,
19+
MessageComposer,
1920
SendMessageOptions,
2021
StreamChat,
21-
Message as StreamMessage,
2222
// TextComposerMiddleware,
23+
Message as StreamMessage,
2324
UpdateMessageOptions,
2425
UploadRequestFn,
2526
UserResponse,
@@ -624,8 +625,16 @@ export const MessageInputProvider = ({
624625
}
625626
} else {
626627
try {
627-
// we will handle this specific case in the poll creation dialog
628-
if (!localMessage.poll_id) {
628+
// Since the message id does not get cleared, we have to handle this manually
629+
// and let the poll creation dialog handle clearing the rest of the state. Once
630+
// sending a message has been moved to the composer as an API, this will be
631+
// redundant and can be removed.
632+
if (localMessage.poll_id) {
633+
messageComposer.state.partialNext({
634+
id: MessageComposer.generateId(),
635+
pollId: null,
636+
});
637+
} else {
629638
messageComposer.clear();
630639
}
631640
await value.sendMessage({

0 commit comments

Comments
 (0)