π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Resolve merge conflicts and merge main
ashilkn6662edfe6a79
diff --cc mobile/apps/locker/lib/services/favorites_service.dartindex 1585c9c659,87068f5da1..d9312aa3cb--- a/mobile/apps/locker/lib/services/favorites_service.dart+++ b/mobile/apps/locker/lib/services/favorites_service.dart@@@ -247,13 -247,10 +247,10 @@@ class FavoritesService}// If no other collection found, move to uncategorized- if (targetCollection == null) {- targetCollection =- await _collectionService.getOrCreateUncategorizedCollection();- }+ targetCollection ??= await _collectionService.getOrCreateUncategorizedCollection();await _collectionService.move(- file,+ [file],favCollection,targetCollection,);diff --cc mobile/apps/locker/lib/utils/file_actions.dartindex 925ed55248,50640d8ae1..21d7ddbf9c--- a/mobile/apps/locker/lib/utils/file_actions.dart+++ b/mobile/apps/locker/lib/utils/file_actions.dart@@@ -11,7 -12,7 +12,6 @@@ import "package:locker/services/trash/timport "package:locker/ui/components/delete_confirmation_dialog.dart";import "package:locker/ui/components/file_edit_dialog.dart";import "package:locker/ui/components/share_link_dialog.dart";- import "package:locker/utils/snack_bar_utils.dart";-import "package:locker/utils/collection_list_util.dart";import "package:logging/logging.dart";/// Utility class for common file actions like edit, share, and delete@@@ -44,118 -31,95 +44,110 @@@ class FileActionsfinal result = await showFileEditDialog(context,file: file,- collections: dedupedCollections,- snackBarContext: context,+ collections: editableCollections,);- if (result != null && context.mounted) {- List<Collection> currentCollections;- try {- currentCollections =- await CollectionService.instance.getCollectionsForFile(file);- } catch (e) {- currentCollections = <Collection>[];- }+ if (result == null || !context.mounted) {+ return;+ }- final currentCollectionsSet = currentCollections.toSet();- final selectedCollectionsSet = result.selectedCollections.toSet();- final collectionsToAdd =- selectedCollectionsSet.difference(currentCollectionsSet).toList();- final hasCollectionAdds = collectionsToAdd.isNotEmpty;+ final dialog = createProgressDialog(+ context,+ context.l10n.pleaseWait,+ isDismissible: false,+ );+ await dialog.show();- final currentTitle = file.displayName;- final currentCaption = file.caption ?? '';- final hasMetadataChanged =- result.title != currentTitle || result.caption != currentCaption;+ try {+ final selectedCollectionIds =+ result.selectedCollections.map((c) => c.id).toSet();- if (hasMetadataChanged || hasCollectionAdds) {- final dialog = createProgressDialog(- context,- context.l10n.pleaseWait,- isDismissible: false,- );- await dialog.show();-- try {- final addFutures = <Future<void>>[];- for (final collection in collectionsToAdd) {- addFutures.add(- CollectionService.instance.addToCollection(- collection,- file,- runSync: false,- ),- );- }- if (addFutures.isNotEmpty) {- await Future.wait(addFutures);- }+ final wasFavorite = currentCollectionIds.contains(favoriteCollection.id);+ final isFavoriteNow =+ selectedCollectionIds.contains(favoriteCollection.id);- final List<Future<void>> apiCalls = [];+ if (wasFavorite && !isFavoriteNow) {+ await FavoritesService.instance.removeFromFavorites(context, file);+ } else if (!wasFavorite && isFavoriteNow) {+ await FavoritesService.instance.addToFavorites(context, file);+ }- if (hasMetadataChanged) {- apiCalls.add(- MetadataUpdaterService.instance- .editFileNameAndCaption(file, result.title, result.caption),+ final regularCurrentIds = currentCollectionIds+ .where((id) => id != favoriteCollection.id)+ .toSet();+ final regularSelectedIds = selectedCollectionIds+ .where((id) => id != favoriteCollection.id)+ .toSet();++ final collectionsToRemove =+ regularCurrentIds.difference(regularSelectedIds);++ final collectionsToAdd = regularSelectedIds.difference(regularCurrentIds);++ if (regularSelectedIds.isEmpty && collectionsToRemove.isNotEmpty) {+ _logger.info('All collections deselected, moving to uncategorized');++ for (final collectionId in collectionsToRemove) {+ try {+ final collection =+ allCollections.firstWhere((c) => c.id == collectionId);+ await CollectionService.instance.moveFilesFromCurrentCollection(+ context,+ collection,+ [file],+ );+ } catch (e) {+ final collection =+ allCollections.firstWhere((c) => c.id == collectionId);+ _logger.severe(+ 'Failed to remove file from ${collection.name}: $e',+ );+ }+ }+ } else {+ for (final collectionId in collectionsToAdd) {+ final collection =+ allCollections.firstWhere((c) => c.id == collectionId);++ try {+ await CollectionService.instance.addToCollection(+ collection,+ file,+ runSync: false,+ );+ } catch (e) {+ _logger.severe(+ 'Failed to move file to collection ${collection.name}: $e',);}- await Future.wait(apiCalls);+ }- await dialog.hide();+ for (final collectionId in collectionsToRemove) {+ final collection =+ allCollections.firstWhere((c) => c.id == collectionId);+ await CollectionService.instance+ .moveFilesFromCurrentCollection(context, collection, [file]);+ }+ }- if (!context.mounted) {- return;- }+ await CollectionService.instance.sync();- showToast(- context,- context.l10n.fileUpdatedSuccessfully,- );+ await dialog.hide();- onSuccess?.call();- } catch (e) {- await dialog.hide();- if (!context.mounted) {- return;- }+ if (!context.mounted) {+ return;+ }-- SnackBarUtils.showInfoSnackBar(- context,- context.l10n.fileUpdatedSuccessfully,- );++ showToast(context, context.l10n.fileUpdatedSuccessfully);- showToast(- context,- context.l10n.failedToUpdateFile(e.toString()),- );- }- } else {- if (!context.mounted) {- return;- }- showToast(- context,- context.l10n.noChangesWereMade,- );+ onSuccess?.call();+ } catch (e) {+ await dialog.hide();+ _logger.severe('Failed to update file collections: $e');++ if (!context.mounted) {+ return;}-- SnackBarUtils.showWarningSnackBar(- context,- context.l10n.failedToUpdateFile(e.toString()),- );++ showToast(context, context.l10n.failedToUpdateFile(e.toString()));}}