From 5f47cf604ad6719f70a0e98d34de85510d4758f3 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 22 Jun 2024 15:31:27 -0700 Subject: [PATCH] chore(mobile): remove exclude album mechanism for backup (#10552) * chore(mobile): remove exclude album selection mechanism * code generator * code generator --- mobile/lib/entities/backup_album.entity.dart | 1 - .../lib/entities/backup_album.entity.g.dart | Bin 18669 -> 18623 bytes .../lib/models/backup/backup_state.model.dart | 20 ++-- .../backup/backup_album_selection.page.dart | 80 -------------- .../pages/backup/backup_controller.page.dart | 30 +----- .../lib/providers/backup/backup.provider.dart | 102 +++--------------- .../backup/backup_verification.provider.dart | 2 +- .../backup_verification.provider.g.dart | Bin 979 -> 979 bytes mobile/lib/services/background.service.dart | 6 +- mobile/lib/services/backup.service.dart | 14 +-- .../lib/widgets/backup/album_info_card.dart | 45 +------- .../widgets/backup/album_info_list_tile.dart | 37 ------- 12 files changed, 31 insertions(+), 306 deletions(-) diff --git a/mobile/lib/entities/backup_album.entity.dart b/mobile/lib/entities/backup_album.entity.dart index 4d4d7b3aa3..5229d93782 100644 --- a/mobile/lib/entities/backup_album.entity.dart +++ b/mobile/lib/entities/backup_album.entity.dart @@ -18,5 +18,4 @@ class BackupAlbum { enum BackupSelection { none, select, - exclude; } diff --git a/mobile/lib/entities/backup_album.entity.g.dart b/mobile/lib/entities/backup_album.entity.g.dart index 7fb6c0e03b6b2c518aa9e3aaaa4c85b1df5fdde7..aad62aed742dd8a94ed5eedafd0ba9784ee55140 100644 GIT binary patch delta 18 acmaDmk#YY-#tnWvljC^OH$Ud#vH<{00|zGn delta 62 zcmdl#k@4+B#tnWvd availableAlbums; final Set selectedBackupAlbums; - final Set excludedBackupAlbums; /// Assets that are not overlapping in selected backup albums and excluded backup albums - final Set allUniqueAssets; + final Set backupCandidates; /// All assets from the selected albums that have been backup final Set selectedAlbumsBackupAssetsIds; @@ -68,8 +67,7 @@ class BackUpState { required this.backupTriggerDelay, required this.availableAlbums, required this.selectedBackupAlbums, - required this.excludedBackupAlbums, - required this.allUniqueAssets, + required this.backupCandidates, required this.selectedAlbumsBackupAssetsIds, required this.currentUploadAsset, }); @@ -93,8 +91,7 @@ class BackUpState { int? backupTriggerDelay, List? availableAlbums, Set? selectedBackupAlbums, - Set? excludedBackupAlbums, - Set? allUniqueAssets, + Set? backupCandidates, Set? selectedAlbumsBackupAssetsIds, CurrentUploadAsset? currentUploadAsset, }) { @@ -121,8 +118,7 @@ class BackUpState { backupTriggerDelay: backupTriggerDelay ?? this.backupTriggerDelay, availableAlbums: availableAlbums ?? this.availableAlbums, selectedBackupAlbums: selectedBackupAlbums ?? this.selectedBackupAlbums, - excludedBackupAlbums: excludedBackupAlbums ?? this.excludedBackupAlbums, - allUniqueAssets: allUniqueAssets ?? this.allUniqueAssets, + backupCandidates: backupCandidates ?? this.backupCandidates, selectedAlbumsBackupAssetsIds: selectedAlbumsBackupAssetsIds ?? this.selectedAlbumsBackupAssetsIds, currentUploadAsset: currentUploadAsset ?? this.currentUploadAsset, @@ -131,7 +127,7 @@ class BackUpState { @override String toString() { - return 'BackUpState(backupProgress: $backupProgress, allAssetsInDatabase: $allAssetsInDatabase, progressInPercentage: $progressInPercentage, progressInFileSize: $progressInFileSize, progressInFileSpeed: $progressInFileSpeed, progressInFileSpeeds: $progressInFileSpeeds, progressInFileSpeedUpdateTime: $progressInFileSpeedUpdateTime, progressInFileSpeedUpdateSentBytes: $progressInFileSpeedUpdateSentBytes, iCloudDownloadProgress: $iCloudDownloadProgress, cancelToken: $cancelToken, serverInfo: $serverInfo, autoBackup: $autoBackup, backgroundBackup: $backgroundBackup, backupRequireWifi: $backupRequireWifi, backupRequireCharging: $backupRequireCharging, backupTriggerDelay: $backupTriggerDelay, availableAlbums: $availableAlbums, selectedBackupAlbums: $selectedBackupAlbums, excludedBackupAlbums: $excludedBackupAlbums, allUniqueAssets: $allUniqueAssets, selectedAlbumsBackupAssetsIds: $selectedAlbumsBackupAssetsIds, currentUploadAsset: $currentUploadAsset)'; + return 'BackUpState(backupProgress: $backupProgress, allAssetsInDatabase: $allAssetsInDatabase, progressInPercentage: $progressInPercentage, progressInFileSize: $progressInFileSize, progressInFileSpeed: $progressInFileSpeed, progressInFileSpeeds: $progressInFileSpeeds, progressInFileSpeedUpdateTime: $progressInFileSpeedUpdateTime, progressInFileSpeedUpdateSentBytes: $progressInFileSpeedUpdateSentBytes, iCloudDownloadProgress: $iCloudDownloadProgress, cancelToken: $cancelToken, serverInfo: $serverInfo, autoBackup: $autoBackup, backgroundBackup: $backgroundBackup, backupRequireWifi: $backupRequireWifi, backupRequireCharging: $backupRequireCharging, backupTriggerDelay: $backupTriggerDelay, availableAlbums: $availableAlbums, selectedBackupAlbums: $selectedBackupAlbums, backupCandidates: $backupCandidates, selectedAlbumsBackupAssetsIds: $selectedAlbumsBackupAssetsIds, currentUploadAsset: $currentUploadAsset)'; } @override @@ -158,8 +154,7 @@ class BackUpState { other.backupTriggerDelay == backupTriggerDelay && collectionEquals(other.availableAlbums, availableAlbums) && collectionEquals(other.selectedBackupAlbums, selectedBackupAlbums) && - collectionEquals(other.excludedBackupAlbums, excludedBackupAlbums) && - collectionEquals(other.allUniqueAssets, allUniqueAssets) && + collectionEquals(other.backupCandidates, backupCandidates) && collectionEquals( other.selectedAlbumsBackupAssetsIds, selectedAlbumsBackupAssetsIds, @@ -187,8 +182,7 @@ class BackUpState { backupTriggerDelay.hashCode ^ availableAlbums.hashCode ^ selectedBackupAlbums.hashCode ^ - excludedBackupAlbums.hashCode ^ - allUniqueAssets.hashCode ^ + backupCandidates.hashCode ^ selectedAlbumsBackupAssetsIds.hashCode ^ currentUploadAsset.hashCode; } diff --git a/mobile/lib/pages/backup/backup_album_selection.page.dart b/mobile/lib/pages/backup/backup_album_selection.page.dart index ecfebd3cb7..70dc0dbf53 100644 --- a/mobile/lib/pages/backup/backup_album_selection.page.dart +++ b/mobile/lib/pages/backup/backup_album_selection.page.dart @@ -3,7 +3,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:immich_mobile/constants/immich_colors.dart'; import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/providers/backup/backup.provider.dart'; import 'package:immich_mobile/widgets/backup/album_info_card.dart'; @@ -17,7 +16,6 @@ class BackupAlbumSelectionPage extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { // final availableAlbums = ref.watch(backupProvider).availableAlbums; final selectedBackupAlbums = ref.watch(backupProvider).selectedBackupAlbums; - final excludedBackupAlbums = ref.watch(backupProvider).excludedBackupAlbums; final isDarkTheme = context.isDarkTheme; final albums = ref.watch(backupProvider).availableAlbums; @@ -111,83 +109,6 @@ class BackupAlbumSelectionPage extends HookConsumerWidget { }).toSet(); } - buildExcludedAlbumNameChip() { - return excludedBackupAlbums.map((album) { - void removeSelection() { - ref - .watch(backupProvider.notifier) - .removeExcludedAlbumForBackup(album); - } - - return GestureDetector( - onTap: removeSelection, - child: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Chip( - label: Text( - album.name, - style: TextStyle( - fontSize: 12, - color: isDarkTheme ? Colors.black : immichBackgroundColor, - fontWeight: FontWeight.bold, - ), - ), - backgroundColor: Colors.red[300], - deleteIconColor: - isDarkTheme ? Colors.black : immichBackgroundColor, - deleteIcon: const Icon( - Icons.cancel_rounded, - size: 15, - ), - onDeleted: removeSelection, - ), - ), - ); - }).toSet(); - } - - // buildSearchBar() { - // return Padding( - // padding: const EdgeInsets.only(left: 16.0, right: 16, bottom: 8.0), - // child: TextFormField( - // onChanged: (searchValue) { - // // if (searchValue.isEmpty) { - // // albums = availableAlbums; - // // } else { - // // albums.value = availableAlbums - // // .where( - // // (album) => album.name - // // .toLowerCase() - // // .contains(searchValue.toLowerCase()), - // // ) - // // .toList(); - // // } - // }, - // decoration: InputDecoration( - // contentPadding: const EdgeInsets.symmetric( - // horizontal: 8.0, - // vertical: 8.0, - // ), - // hintText: "Search", - // hintStyle: TextStyle( - // color: isDarkTheme ? Colors.white : Colors.grey, - // fontSize: 14.0, - // ), - // prefixIcon: const Icon( - // Icons.search, - // color: Colors.grey, - // ), - // border: OutlineInputBorder( - // borderRadius: BorderRadius.circular(10), - // borderSide: BorderSide.none, - // ), - // filled: true, - // fillColor: isDarkTheme ? Colors.white30 : Colors.grey[200], - // ), - // ), - // ); - // } - return Scaffold( appBar: AppBar( leading: IconButton( @@ -223,7 +144,6 @@ class BackupAlbumSelectionPage extends HookConsumerWidget { child: Wrap( children: [ ...buildSelectedAlbumNameChip(), - ...buildExcludedAlbumNameChip(), ], ), ), diff --git a/mobile/lib/pages/backup/backup_controller.page.dart b/mobile/lib/pages/backup/backup_controller.page.dart index 89384cf97a..847b2518b6 100644 --- a/mobile/lib/pages/backup/backup_controller.page.dart +++ b/mobile/lib/pages/backup/backup_controller.page.dart @@ -29,7 +29,7 @@ class BackupControllerPage extends HookConsumerWidget { final didGetBackupInfo = useState(false); bool hasExclusiveAccess = backupState.backupProgress != BackUpProgressEnum.inBackground; - bool shouldBackup = backupState.allUniqueAssets.length - + bool shouldBackup = backupState.backupCandidates.length - backupState.selectedAlbumsBackupAssetsIds.length == 0 || !hasExclusiveAccess @@ -100,29 +100,6 @@ class BackupControllerPage extends HookConsumerWidget { } } - Widget buildExcludedAlbumName() { - var text = "backup_controller_page_excluded".tr(); - var albums = ref.watch(backupProvider).excludedBackupAlbums; - - if (albums.isNotEmpty) { - for (var album in albums) { - text += "${album.name}, "; - } - - return Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text( - text.trim().substring(0, text.length - 2), - style: context.textTheme.labelLarge?.copyWith( - color: Colors.red[300], - ), - ), - ); - } else { - return const SizedBox(); - } - } - buildFolderSelectionTile() { return Padding( padding: const EdgeInsets.only(top: 8.0), @@ -154,7 +131,6 @@ class BackupControllerPage extends HookConsumerWidget { style: context.textTheme.bodyMedium, ).tr(), buildSelectedAlbumName(), - buildExcludedAlbumName(), ], ), ), @@ -292,7 +268,7 @@ class BackupControllerPage extends HookConsumerWidget { subtitle: "backup_controller_page_total_sub".tr(), info: ref.watch(backupProvider).availableAlbums.isEmpty ? "..." - : "${backupState.allUniqueAssets.length}", + : "${backupState.backupCandidates.length}", ), BackupInfoCard( title: "backup_controller_page_backup".tr(), @@ -306,7 +282,7 @@ class BackupControllerPage extends HookConsumerWidget { subtitle: "backup_controller_page_remainder_sub".tr(), info: ref.watch(backupProvider).availableAlbums.isEmpty ? "..." - : "${max(0, backupState.allUniqueAssets.length - backupState.selectedAlbumsBackupAssetsIds.length)}", + : "${max(0, backupState.backupCandidates.length - backupState.selectedAlbumsBackupAssetsIds.length)}", ), const Divider(), const CurrentUploadingAssetInfoBox(), diff --git a/mobile/lib/providers/backup/backup.provider.dart b/mobile/lib/providers/backup/backup.provider.dart index 58027e3b94..301b50aef6 100644 --- a/mobile/lib/providers/backup/backup.provider.dart +++ b/mobile/lib/providers/backup/backup.provider.dart @@ -61,8 +61,7 @@ class BackupNotifier extends StateNotifier { ), availableAlbums: const [], selectedBackupAlbums: const {}, - excludedBackupAlbums: const {}, - allUniqueAssets: const {}, + backupCandidates: const {}, selectedAlbumsBackupAssetsIds: const {}, currentUploadAsset: CurrentUploadAsset( id: '...', @@ -94,22 +93,10 @@ class BackupNotifier extends StateNotifier { /// The total unique assets will be used for backing mechanism /// void addAlbumForBackup(AvailableAlbum album) { - if (state.excludedBackupAlbums.contains(album)) { - removeExcludedAlbumForBackup(album); - } - state = state .copyWith(selectedBackupAlbums: {...state.selectedBackupAlbums, album}); } - void addExcludedAlbumForBackup(AvailableAlbum album) { - if (state.selectedBackupAlbums.contains(album)) { - removeAlbumForBackup(album); - } - state = state - .copyWith(excludedBackupAlbums: {...state.excludedBackupAlbums, album}); - } - void removeAlbumForBackup(AvailableAlbum album) { Set currentSelectedAlbums = state.selectedBackupAlbums; @@ -118,14 +105,6 @@ class BackupNotifier extends StateNotifier { state = state.copyWith(selectedBackupAlbums: currentSelectedAlbums); } - void removeExcludedAlbumForBackup(AvailableAlbum album) { - Set currentExcludedAlbums = state.excludedBackupAlbums; - - currentExcludedAlbums.removeWhere((a) => a == album); - - state = state.copyWith(excludedBackupAlbums: currentExcludedAlbums); - } - Future backupAlbumSelectionDone() { if (state.selectedBackupAlbums.isEmpty) { // disable any backup @@ -240,8 +219,6 @@ class BackupNotifier extends StateNotifier { } state = state.copyWith(availableAlbums: availableAlbums); - final List excludedBackupAlbums = - await _backupService.excludedAlbumsQuery().findAll(); final List selectedBackupAlbums = await _backupService.selectedAlbumsQuery().findAll(); @@ -259,22 +236,8 @@ class BackupNotifier extends StateNotifier { } } - final Set excludedAlbums = {}; - for (final BackupAlbum ba in excludedBackupAlbums) { - final albumAsset = albumMap[ba.id]; - - if (albumAsset != null) { - excludedAlbums.add( - AvailableAlbum(albumEntity: albumAsset, lastBackup: ba.lastBackup), - ); - } else { - log.severe('Excluded album not found'); - } - } - state = state.copyWith( selectedBackupAlbums: selectedAlbums, - excludedBackupAlbums: excludedAlbums, ); log.info( @@ -290,8 +253,7 @@ class BackupNotifier extends StateNotifier { /// Future _updateBackupAssetCount() async { final duplicatedAssetIds = await _backupService.getDuplicatedAssetIds(); - final Set assetsFromSelectedAlbums = {}; - final Set assetsFromExcludedAlbums = {}; + final Set backupCandidates = {}; for (final album in state.selectedBackupAlbums) { final assetCount = await album.albumEntity.assetCountAsync; @@ -304,25 +266,9 @@ class BackupNotifier extends StateNotifier { start: 0, end: assetCount, ); - assetsFromSelectedAlbums.addAll(assets); + backupCandidates.addAll(assets); } - for (final album in state.excludedBackupAlbums) { - final assetCount = await album.albumEntity.assetCountAsync; - - if (assetCount == 0) { - continue; - } - - final assets = await album.albumEntity.getAssetListRange( - start: 0, - end: assetCount, - ); - assetsFromExcludedAlbums.addAll(assets); - } - - final Set allUniqueAssets = - assetsFromSelectedAlbums.difference(assetsFromExcludedAlbums); final allAssetsInDatabase = await _backupService.getDeviceBackupAsset(); if (allAssetsInDatabase == null) { @@ -331,28 +277,28 @@ class BackupNotifier extends StateNotifier { // Find asset that were backup from selected albums final Set selectedAlbumsBackupAssets = - Set.from(allUniqueAssets.map((e) => e.id)); + Set.from(backupCandidates.map((e) => e.id)); selectedAlbumsBackupAssets .removeWhere((assetId) => !allAssetsInDatabase.contains(assetId)); // Remove duplicated asset from all unique assets - allUniqueAssets.removeWhere( + backupCandidates.removeWhere( (asset) => duplicatedAssetIds.contains(asset.id), ); - if (allUniqueAssets.isEmpty) { + if (backupCandidates.isEmpty) { log.info("No assets are selected for back up"); state = state.copyWith( backupProgress: BackUpProgressEnum.idle, allAssetsInDatabase: allAssetsInDatabase, - allUniqueAssets: {}, + backupCandidates: {}, selectedAlbumsBackupAssetsIds: selectedAlbumsBackupAssets, ); } else { state = state.copyWith( allAssetsInDatabase: allAssetsInDatabase, - allUniqueAssets: allUniqueAssets, + backupCandidates: backupCandidates, selectedAlbumsBackupAssetsIds: selectedAlbumsBackupAssets, ); } @@ -387,10 +333,8 @@ class BackupNotifier extends StateNotifier { final selected = state.selectedBackupAlbums.map( (e) => BackupAlbum(e.id, e.lastBackup ?? epoch, BackupSelection.select), ); - final excluded = state.excludedBackupAlbums.map( - (e) => BackupAlbum(e.id, e.lastBackup ?? epoch, BackupSelection.exclude), - ); - final backupAlbums = selected.followedBy(excluded).toList(); + + final backupAlbums = selected.toList(); backupAlbums.sortBy((e) => e.id); return _db.writeTxn(() async { final dbAlbums = await _db.backupAlbums.where().sortById().findAll(); @@ -427,13 +371,13 @@ class BackupNotifier extends StateNotifier { if (hasPermission) { await PhotoManager.clearFileCache(); - if (state.allUniqueAssets.isEmpty) { + if (state.backupCandidates.isEmpty) { log.info("No Asset On Device - Abort Backup Process"); state = state.copyWith(backupProgress: BackUpProgressEnum.idle); return; } - Set assetsWillBeBackup = Set.from(state.allUniqueAssets); + Set assetsWillBeBackup = Set.from(state.backupCandidates); // Remove item that has already been backed up for (final assetId in state.allAssetsInDatabase) { assetsWillBeBackup.removeWhere((e) => e.id == assetId); @@ -504,7 +448,7 @@ class BackupNotifier extends StateNotifier { ) { if (isDuplicated) { state = state.copyWith( - allUniqueAssets: state.allUniqueAssets + backupCandidates: state.backupCandidates .where((asset) => asset.id != deviceAssetId) .toSet(), ); @@ -518,20 +462,17 @@ class BackupNotifier extends StateNotifier { ); } - if (state.allUniqueAssets.length - + if (state.backupCandidates.length - state.selectedAlbumsBackupAssetsIds.length == 0) { final latestAssetBackup = - state.allUniqueAssets.map((e) => e.modifiedDateTime).reduce( + state.backupCandidates.map((e) => e.modifiedDateTime).reduce( (v, e) => e.isAfter(v) ? e : v, ); state = state.copyWith( selectedBackupAlbums: state.selectedBackupAlbums .map((e) => e.copyWith(lastBackup: latestAssetBackup)) .toSet(), - excludedBackupAlbums: state.excludedBackupAlbums - .map((e) => e.copyWith(lastBackup: latestAssetBackup)) - .toSet(), backupProgress: BackUpProgressEnum.done, progressInPercentage: 0.0, progressInFileSize: "0 B / 0 B", @@ -630,12 +571,8 @@ class BackupNotifier extends StateNotifier { .filter() .selectionEqualTo(BackupSelection.select) .findAll(); - final List excludedBackupAlbums = await _db.backupAlbums - .filter() - .selectionEqualTo(BackupSelection.exclude) - .findAll(); + Set selectedAlbums = state.selectedBackupAlbums; - Set excludedAlbums = state.excludedBackupAlbums; if (selectedAlbums.isNotEmpty) { selectedAlbums = _updateAlbumsBackupTime( selectedAlbums, @@ -643,17 +580,10 @@ class BackupNotifier extends StateNotifier { ); } - if (excludedAlbums.isNotEmpty) { - excludedAlbums = _updateAlbumsBackupTime( - excludedAlbums, - excludedBackupAlbums, - ); - } final BackUpProgressEnum previous = state.backupProgress; state = state.copyWith( backupProgress: BackUpProgressEnum.inBackground, selectedBackupAlbums: selectedAlbums, - excludedBackupAlbums: excludedAlbums, ); // assumes the background service is currently running // if true, waits until it has stopped to start the backup diff --git a/mobile/lib/providers/backup/backup_verification.provider.dart b/mobile/lib/providers/backup/backup_verification.provider.dart index 894b807ec8..bd2c5d5f9d 100644 --- a/mobile/lib/providers/backup/backup_verification.provider.dart +++ b/mobile/lib/providers/backup/backup_verification.provider.dart @@ -23,7 +23,7 @@ class BackupVerification extends _$BackupVerification { state = true; final backupState = ref.read(backupProvider); - if (backupState.allUniqueAssets.length > + if (backupState.backupCandidates.length > backupState.selectedAlbumsBackupAssetsIds.length) { if (context.mounted) { ImmichToast.show( diff --git a/mobile/lib/providers/backup/backup_verification.provider.g.dart b/mobile/lib/providers/backup/backup_verification.provider.g.dart index f222c9bd83e1253f4676aad094837594500b7277..aa00550d3aa6ddc72896a50fb358efc9b27950d4 100644 GIT binary patch delta 53 zcmcc2ewlrP8KZ_tnwg1-sbz|pMT(I@N~%esnW3SXL29x^s%28Dv59$VvZaY>T9Vo3 IIL1;Y0Hk*hQUCw| delta 53 zcmcc2ewlrP8KXv$nWbT>L2|N@xrM1&YHFIHg{6_HMT&8c6QKHG_ IIL1;Y0H%%)5C8xG diff --git a/mobile/lib/services/background.service.dart b/mobile/lib/services/background.service.dart index ba8f5c01ed..a2a2abae8d 100644 --- a/mobile/lib/services/background.service.dart +++ b/mobile/lib/services/background.service.dart @@ -349,7 +349,6 @@ class BackgroundService { AppSettingsService settingsService = AppSettingsService(); final selectedAlbums = backupService.selectedAlbumsQuery().findAllSync(); - final excludedAlbums = backupService.excludedAlbumsQuery().findAllSync(); if (selectedAlbums.isEmpty) { return true; } @@ -361,11 +360,10 @@ class BackgroundService { backupService, settingsService, selectedAlbums, - excludedAlbums, ); if (backupOk) { await Store.delete(StoreKey.backupFailedSince); - final backupAlbums = [...selectedAlbums, ...excludedAlbums]; + final backupAlbums = [...selectedAlbums]; backupAlbums.sortBy((e) => e.id); db.writeTxnSync(() { final dbAlbums = db.backupAlbums.where().sortById().findAllSync(); @@ -404,7 +402,6 @@ class BackgroundService { BackupService backupService, AppSettingsService settingsService, List selectedAlbums, - List excludedAlbums, ) async { _errorGracePeriodExceeded = _isErrorGracePeriodExceeded(settingsService); final bool notifyTotalProgress = settingsService @@ -418,7 +415,6 @@ class BackgroundService { List toUpload = await backupService.buildUploadCandidates( selectedAlbums, - excludedAlbums, ); try { diff --git a/mobile/lib/services/backup.service.dart b/mobile/lib/services/backup.service.dart index 31a87a7aaa..025e475474 100644 --- a/mobile/lib/services/backup.service.dart +++ b/mobile/lib/services/backup.service.dart @@ -65,14 +65,10 @@ class BackupService { QueryBuilder selectedAlbumsQuery() => _db.backupAlbums.filter().selectionEqualTo(BackupSelection.select); - QueryBuilder - excludedAlbumsQuery() => - _db.backupAlbums.filter().selectionEqualTo(BackupSelection.exclude); /// Returns all assets newer than the last successful backup per album Future> buildUploadCandidates( List selectedBackupAlbums, - List excludedBackupAlbums, ) async { final filter = FilterOptionGroup( containsPathModified: true, @@ -89,19 +85,13 @@ class BackupService { } final int allIdx = selectedAlbums.indexWhere((e) => e != null && e.isAll); if (allIdx != -1) { - final List excludedAlbums = - await _loadAlbumsWithTimeFilter(excludedBackupAlbums, filter, now); final List toAdd = await _fetchAssetsAndUpdateLastBackup( selectedAlbums.slice(allIdx, allIdx + 1), selectedBackupAlbums.slice(allIdx, allIdx + 1), now, ); - final List toRemove = await _fetchAssetsAndUpdateLastBackup( - excludedAlbums, - excludedBackupAlbums, - now, - ); - return toAdd.toSet().difference(toRemove.toSet()).toList(); + + return toAdd.toSet().toList(); } else { return await _fetchAssetsAndUpdateLastBackup( selectedAlbums, diff --git a/mobile/lib/widgets/backup/album_info_card.dart b/mobile/lib/widgets/backup/album_info_card.dart index e9349bd69e..c65f14e953 100644 --- a/mobile/lib/widgets/backup/album_info_card.dart +++ b/mobile/lib/widgets/backup/album_info_card.dart @@ -1,14 +1,12 @@ import 'package:auto_route/auto_route.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/models/backup/available_album.model.dart'; import 'package:immich_mobile/providers/backup/backup.provider.dart'; import 'package:immich_mobile/routing/router.dart'; import 'package:immich_mobile/providers/haptic_feedback.provider.dart'; -import 'package:immich_mobile/widgets/common/immich_toast.dart'; class AlbumInfoCard extends HookConsumerWidget { final AvailableAlbum album; @@ -19,8 +17,6 @@ class AlbumInfoCard extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final bool isSelected = ref.watch(backupProvider).selectedBackupAlbums.contains(album); - final bool isExcluded = - ref.watch(backupProvider).excludedBackupAlbums.contains(album); final isDarkTheme = context.isDarkTheme; @@ -28,8 +24,7 @@ class AlbumInfoCard extends HookConsumerWidget { context.primaryColor.withAlpha(100), BlendMode.darken, ); - ColorFilter excludedFilter = - ColorFilter.mode(Colors.red.withAlpha(75), BlendMode.darken); + ColorFilter unselectedFilter = const ColorFilter.mode(Colors.black, BlendMode.color); @@ -48,20 +43,6 @@ class AlbumInfoCard extends HookConsumerWidget { ).tr(), backgroundColor: context.primaryColor, ); - } else if (isExcluded) { - return Chip( - visualDensity: VisualDensity.compact, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), - label: Text( - "album_info_card_backup_album_excluded", - style: TextStyle( - fontSize: 10, - color: isDarkTheme ? Colors.black : Colors.white, - fontWeight: FontWeight.bold, - ), - ).tr(), - backgroundColor: Colors.red[300], - ); } return const SizedBox(); @@ -70,8 +51,6 @@ class AlbumInfoCard extends HookConsumerWidget { buildImageFilter() { if (isSelected) { return selectedFilter; - } else if (isExcluded) { - return excludedFilter; } else { return unselectedFilter; } @@ -87,28 +66,6 @@ class AlbumInfoCard extends HookConsumerWidget { ref.read(backupProvider.notifier).addAlbumForBackup(album); } }, - onDoubleTap: () { - ref.read(hapticFeedbackProvider.notifier).selectionClick(); - - if (isExcluded) { - // Remove from exclude album list - ref.read(backupProvider.notifier).removeExcludedAlbumForBackup(album); - } else { - // Add to exclude album list - - if (album.id == 'isAll' || album.name == 'Recents') { - ImmichToast.show( - context: context, - msg: 'Cannot exclude album contains all assets', - toastType: ToastType.error, - gravity: ToastGravity.BOTTOM, - ); - return; - } - - ref.read(backupProvider.notifier).addExcludedAlbumForBackup(album); - } - }, child: Card( clipBehavior: Clip.hardEdge, margin: const EdgeInsets.all(1), diff --git a/mobile/lib/widgets/backup/album_info_list_tile.dart b/mobile/lib/widgets/backup/album_info_list_tile.dart index 2e10fe0b75..69415ee126 100644 --- a/mobile/lib/widgets/backup/album_info_list_tile.dart +++ b/mobile/lib/widgets/backup/album_info_list_tile.dart @@ -1,14 +1,12 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:fluttertoast/fluttertoast.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/models/backup/available_album.model.dart'; import 'package:immich_mobile/providers/backup/backup.provider.dart'; import 'package:immich_mobile/routing/router.dart'; import 'package:immich_mobile/providers/haptic_feedback.provider.dart'; -import 'package:immich_mobile/widgets/common/immich_toast.dart'; class AlbumInfoListTile extends HookConsumerWidget { final AvailableAlbum album; @@ -19,8 +17,6 @@ class AlbumInfoListTile extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final bool isSelected = ref.watch(backupProvider).selectedBackupAlbums.contains(album); - final bool isExcluded = - ref.watch(backupProvider).excludedBackupAlbums.contains(album); var assetCount = useState(0); useEffect( @@ -36,10 +32,6 @@ class AlbumInfoListTile extends HookConsumerWidget { return context.isDarkTheme ? context.primaryColor.withAlpha(100) : context.primaryColor.withAlpha(25); - } else if (isExcluded) { - return context.isDarkTheme - ? Colors.red[300]?.withAlpha(150) - : Colors.red[100]?.withAlpha(150); } else { return Colors.transparent; } @@ -53,13 +45,6 @@ class AlbumInfoListTile extends HookConsumerWidget { ); } - if (isExcluded) { - return const Icon( - Icons.remove_circle_rounded, - color: Colors.red, - ); - } - return Icon( Icons.circle, color: context.isDarkTheme ? Colors.grey[400] : Colors.black45, @@ -67,28 +52,6 @@ class AlbumInfoListTile extends HookConsumerWidget { } return GestureDetector( - onDoubleTap: () { - ref.watch(hapticFeedbackProvider.notifier).selectionClick(); - - if (isExcluded) { - // Remove from exclude album list - ref.read(backupProvider.notifier).removeExcludedAlbumForBackup(album); - } else { - // Add to exclude album list - - if (album.id == 'isAll' || album.name == 'Recents') { - ImmichToast.show( - context: context, - msg: 'Cannot exclude album contains all assets', - toastType: ToastType.error, - gravity: ToastGravity.BOTTOM, - ); - return; - } - - ref.read(backupProvider.notifier).addExcludedAlbumForBackup(album); - } - }, child: ListTile( tileColor: buildTileColor(), contentPadding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),