Skip to content

Commit

Permalink
fix: remove message from local state when the status is failed (#2214)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
khushal87 committed Aug 28, 2023
1 parent 5ea9a76 commit 8c00f62
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,9 @@ const ChannelWithContext = <
const clearQuotedMessageState: InputMessageInputContextValue<StreamChatGenerics>['clearQuotedMessageState'] =
() => setQuotedMessage(false);

/**
* Removes the message from local state
*/
const removeMessage: MessagesContextValue<StreamChatGenerics>['removeMessage'] = (message) => {
if (channel) {
channel.state.removeMessage(message);
Expand Down Expand Up @@ -1668,6 +1671,10 @@ const ChannelWithContext = <
}

if (!enableOfflineSupport) {
if (message.status === MessageStatusTypes.FAILED) {
removeMessage(message);
return;
}
await client.deleteMessage(message.id);
return;
}
Expand Down

0 comments on commit 8c00f62

Please sign in to comment.