fix: Now caches message before update

This commit is contained in:
Deven Joshi
2021-05-27 16:41:04 +05:30
parent 259f717ec8
commit 23fbfbeff9
@@ -411,6 +411,8 @@ class Channel {
/// Waits for a [_messageAttachmentsUploadCompleter] to complete
/// before actually updating the message.
Future<UpdateMessageResponse> 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;
}