Skip to content

Commit 8c00f62

Browse files
authored
fix: remove message from local state when the status is failed (#2214)
* fix: remove message from local state when the status is failed * fix: remove message from local state when the status is failed * fix: remove message from local state when the status is failed * chore: remove SonarCloud checks from CI (#2215)
1 parent 5ea9a76 commit 8c00f62

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,9 @@ const ChannelWithContext = <
16051605
const clearQuotedMessageState: InputMessageInputContextValue<StreamChatGenerics>['clearQuotedMessageState'] =
16061606
() => setQuotedMessage(false);
16071607

1608+
/**
1609+
* Removes the message from local state
1610+
*/
16081611
const removeMessage: MessagesContextValue<StreamChatGenerics>['removeMessage'] = (message) => {
16091612
if (channel) {
16101613
channel.state.removeMessage(message);
@@ -1668,6 +1671,10 @@ const ChannelWithContext = <
16681671
}
16691672

16701673
if (!enableOfflineSupport) {
1674+
if (message.status === MessageStatusTypes.FAILED) {
1675+
removeMessage(message);
1676+
return;
1677+
}
16711678
await client.deleteMessage(message.id);
16721679
return;
16731680
}

0 commit comments

Comments
 (0)