Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: null check issue

Prateek Sunal882850e3d55c
diff --git a/mobile/lib/ui/tools/collage/collage_save_button.dart b/mobile/lib/ui/tools/collage/collage_save_button.dart
index 5a21d62827..cd2645403b 100644
--- a/mobile/lib/ui/tools/collage/collage_save_button.dart
+++ b/mobile/lib/ui/tools/collage/collage_save_button.dart
@@ -40,19 +40,18 @@ class SaveCollageButton extends StatelessWidget {
final fileName = "ente_collage_" +
DateTime.now().microsecondsSinceEpoch.toString() +
".jpeg";
- AssetEntity? newAsset = await (PhotoManager.editor.saveImage(
+ final newAsset = await (PhotoManager.editor
+ .saveImage(
compressedBytes,
filename: fileName,
relativePath: "ente Collages",
- ));
- newAsset ??= await (PhotoManager.editor.saveImage(
- compressedBytes,
- filename: fileName,
- ));
- if (newAsset == null) {
- showShortToast(context, S.of(context).fileFailedToSaveToGallery);
- return;
- }
+ )
+ .onError((err, st) async {
+ return await (PhotoManager.editor.saveImage(
+ compressedBytes,
+ filename: fileName,
+ ));
+ }));
final newFile = await EnteFile.fromAsset("ente Collages", newAsset);
SyncService.instance.sync().ignore();
showShortToast(context, S.of(context).collageSaved);
diff --git a/mobile/lib/utils/file_download_util.dart b/mobile/lib/utils/file_download_util.dart
index 3b6842a740..b998c22db3 100644
--- a/mobile/lib/utils/file_download_util.dart
+++ b/mobile/lib/utils/file_download_util.dart
@@ -251,10 +251,10 @@ Future<void> _saveLivePhotoOnDroid(
) async {
debugPrint("Downloading LivePhoto on Droid");
AssetEntity? savedAsset = await (PhotoManager.editor
- .saveImageWithPath(image.path, title: enteFile.title!));
- if (savedAsset == null) {
+ .saveImageWithPath(image.path, title: enteFile.title!))
+ .catchError((err) {
throw Exception("Failed to save image of live photo");
- }
+ });
IgnoredFile ignoreVideoFile = IgnoredFile(
savedAsset.id,
savedAsset.title ?? '',
@@ -267,10 +267,7 @@ Future<void> _saveLivePhotoOnDroid(
savedAsset = (await (PhotoManager.editor.saveVideo(
video,
title: videoTitle,
- )));
- if (savedAsset == null) {
- throw Exception("Failed to save video of live photo");
- }
+ )).catchError((_) => throw Exception("Failed to save video of live photo")));
ignoreVideoFile = IgnoredFile(
savedAsset.id,