updateCallCover method
- NativeFile? file, {
- void onSendProgress()?,
override
Updates or resets the MyUser.callCover field with the provided image
file.
Implementation
@override
Future<void> updateCallCover(
NativeFile? file, {
void Function(int count, int total)? onSendProgress,
}) async {
Log.debug('updateCallCover($file, onSendProgress)', '$runtimeType');
dio.MultipartFile? upload;
if (file != null) {
await file.ensureCorrectMediaType();
upload = await file.toMultipartFile();
}
final UserCallCover? callCover = myUser.value?.callCover;
if (file == null) {
myUser.update((u) => u?.callCover = null);
}
try {
await Backoff.run(
() async {
await _graphQlProvider.updateUserCallCover(
upload,
null,
onSendProgress: onSendProgress,
);
},
retryIf: (e) => e.isNetworkRelated,
retries: 10,
);
} catch (_) {
if (file == null) {
myUser.update((u) => u?.callCover = callCover);
}
rethrow;
}
}