High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
chore: skip dialog for single merged asset (#22958)
shenlong476bb1cacd60
diff --git a/mobile/lib/presentation/widgets/action_buttons/delete_local_action_button.widget.dart b/mobile/lib/presentation/widgets/action_buttons/delete_local_action_button.widget.dartindex 9445daa2ad..3cd939aeb6 100644--- a/mobile/lib/presentation/widgets/action_buttons/delete_local_action_button.widget.dart+++ b/mobile/lib/presentation/widgets/action_buttons/delete_local_action_button.widget.dart@@ -8,7 +8,6 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_buimport 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';import 'package:immich_mobile/providers/infrastructure/action.provider.dart';import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';-import 'package:immich_mobile/widgets/asset_grid/delete_dialog.dart';import 'package:immich_mobile/widgets/common/immich_toast.dart';/// This delete action has the following behavior:@@ -23,17 +22,11 @@ class DeleteLocalActionButton extends ConsumerWidget {return;}- bool? backedUpOnly = await showDialog<bool>(- context: context,- builder: (BuildContext context) => DeleteLocalOnlyDialog(onDeleteLocal: (_) {}),- );-- if (backedUpOnly == null) {- // User cancelled the dialog+ final result = await ref.read(actionProvider.notifier).deleteLocal(source, context);+ if (result == null) {return;}- final result = await ref.read(actionProvider.notifier).deleteLocal(source, backedUpOnly);ref.read(multiSelectProvider.notifier).reset();if (source == ActionSource.viewer) {diff --git a/mobile/lib/providers/infrastructure/action.provider.dart b/mobile/lib/providers/infrastructure/action.provider.dartindex 9f38f4b0ec..7542934426 100644--- a/mobile/lib/providers/infrastructure/action.provider.dart+++ b/mobile/lib/providers/infrastructure/action.provider.dart@@ -15,6 +15,7 @@ import 'package:immich_mobile/services/action.service.dart';import 'package:immich_mobile/services/download.service.dart';import 'package:immich_mobile/services/timeline.service.dart';import 'package:immich_mobile/services/upload.service.dart';+import 'package:immich_mobile/widgets/asset_grid/delete_dialog.dart';import 'package:logging/logging.dart';import 'package:riverpod_annotation/riverpod_annotation.dart';@@ -260,10 +261,23 @@ class ActionNotifier extends Notifier<void> {}}- Future<ActionResult> deleteLocal(ActionSource source, bool backedUpOnly) async {+ Future<ActionResult?> deleteLocal(ActionSource source, BuildContext context) async {+ // Always perform the operation if there is only one merged asset+ final assets = _getAssets(source);+ bool? backedUpOnly = assets.length == 1 && assets.first.storage == AssetState.merged+ ? true+ : await showDialog<bool>(+ context: context,+ builder: (BuildContext context) => DeleteLocalOnlyDialog(onDeleteLocal: (_) {}),+ );++ if (backedUpOnly == null) {+ // User cancelled the dialog+ return null;+ }+final List<String> ids;if (backedUpOnly) {- final assets = _getAssets(source);ids = assets.where((asset) => asset.storage == AssetState.merged).map((asset) => asset.localId!).toList();} else {ids = _getLocalIdsForSource(source);