Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix

AmanRajSinghMouryad3c28e2df17d
diff --git a/mobile/apps/locker/lib/utils/collection_actions.dart b/mobile/apps/locker/lib/utils/collection_actions.dart
index a6ab0a7b6c..a4609ddf6e 100644
--- a/mobile/apps/locker/lib/utils/collection_actions.dart
+++ b/mobile/apps/locker/lib/utils/collection_actions.dart
@@ -253,20 +253,24 @@ class CollectionActions {
await progressDialog.hide();
- showToast(
- context,
- l10n.collectionDeletedSuccessfully,
- );
+ if (context.mounted) {
+ showToast(
+ context,
+ l10n.collectionDeletedSuccessfully,
+ );
+ }
// Call success callback if provided
onSuccess?.call();
} catch (error) {
await progressDialog.hide();
- showToast(
- context,
- l10n.failedToDeleteCollection(error.toString()),
- );
+ if (context.mounted) {
+ showToast(
+ context,
+ l10n.failedToDeleteCollection(error.toString()),
+ );
+ }
}
return;
}
@@ -300,20 +304,24 @@ class CollectionActions {
await progressDialog.hide();
- showToast(
- context,
- l10n.collectionDeletedSuccessfully,
- );
+ if (context.mounted) {
+ showToast(
+ context,
+ l10n.collectionDeletedSuccessfully,
+ );
+ }
// Call success callback if provided
onSuccess?.call();
} catch (error) {
await progressDialog.hide();
- showToast(
- context,
- l10n.failedToDeleteCollection(error.toString()),
- );
+ if (context.mounted) {
+ showToast(
+ context,
+ l10n.failedToDeleteCollection(error.toString()),
+ );
+ }
}
}
diff --git a/mobile/apps/locker/lib/utils/file_actions.dart b/mobile/apps/locker/lib/utils/file_actions.dart
index 7bcfe770b0..f88480f0a2 100644
--- a/mobile/apps/locker/lib/utils/file_actions.dart
+++ b/mobile/apps/locker/lib/utils/file_actions.dart
@@ -52,6 +52,10 @@ class FileActions {
return;
}
+ // Fetch collections in case new ones were created during file edit dialog
+ final updatedCollections =
+ await CollectionService.instance.getCollections();
+
final dialog = createProgressDialog(
context,
context.l10n.pleaseWait,
@@ -111,7 +115,7 @@ class FileActions {
for (final collectionId in collectionsToRemove) {
try {
final collection =
- allCollections.firstWhere((c) => c.id == collectionId);
+ updatedCollections.firstWhere((c) => c.id == collectionId);
await CollectionService.instance.moveFilesFromCurrentCollection(
context,
collection,
@@ -119,7 +123,7 @@ class FileActions {
);
} catch (e) {
final collection =
- allCollections.firstWhere((c) => c.id == collectionId);
+ updatedCollections.firstWhere((c) => c.id == collectionId);
_logger.severe(
'Failed to remove file from ${collection.name}: $e',
);
@@ -128,7 +132,7 @@ class FileActions {
} else {
for (final collectionId in collectionsToAdd) {
final collection =
- allCollections.firstWhere((c) => c.id == collectionId);
+ updatedCollections.firstWhere((c) => c.id == collectionId);
try {
await CollectionService.instance.addToCollection(
@@ -145,7 +149,7 @@ class FileActions {
for (final collectionId in collectionsToRemove) {
final collection =
- allCollections.firstWhere((c) => c.id == collectionId);
+ updatedCollections.firstWhere((c) => c.id == collectionId);
await CollectionService.instance
.moveFilesFromCurrentCollection(context, collection, [file]);
}