diff --git a/packages/stream_chat/lib/src/api/channel.dart b/packages/stream_chat/lib/src/api/channel.dart index 2b6bc0a9..2f95be78 100644 --- a/packages/stream_chat/lib/src/api/channel.dart +++ b/packages/stream_chat/lib/src/api/channel.dart @@ -411,6 +411,8 @@ class Channel { /// Waits for a [_messageAttachmentsUploadCompleter] to complete /// before actually updating the message. Future updateMessage(Message message) async { + var currentMessage = state?.messages.firstWhere((e) => e.id == message.id); + // Cancelling previous completer in case it's called again in the process // Eg. Updating the message while the previous call is in progress. _messageAttachmentsUploadCompleter @@ -459,6 +461,10 @@ class Channel { } catch (error) { if (error is DioError && error.type != DioErrorType.response) { state?.retryQueue?.add([message]); + } else if (error is ApiError) { + if(currentMessage != null) { + state?.addMessage(currentMessage); + } } rethrow; }