fix: Now caches message before update
This commit is contained in:
@@ -411,6 +411,8 @@ class Channel {
|
|||||||
/// Waits for a [_messageAttachmentsUploadCompleter] to complete
|
/// Waits for a [_messageAttachmentsUploadCompleter] to complete
|
||||||
/// before actually updating the message.
|
/// before actually updating the message.
|
||||||
Future<UpdateMessageResponse> updateMessage(Message message) async {
|
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
|
// Cancelling previous completer in case it's called again in the process
|
||||||
// Eg. Updating the message while the previous call is in progress.
|
// Eg. Updating the message while the previous call is in progress.
|
||||||
_messageAttachmentsUploadCompleter
|
_messageAttachmentsUploadCompleter
|
||||||
@@ -459,6 +461,10 @@ class Channel {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error is DioError && error.type != DioErrorType.response) {
|
if (error is DioError && error.type != DioErrorType.response) {
|
||||||
state?.retryQueue?.add([message]);
|
state?.retryQueue?.add([message]);
|
||||||
|
} else if (error is ApiError) {
|
||||||
|
if(currentMessage != null) {
|
||||||
|
state?.addMessage(currentMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user