mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:17:11 -05:00 
			
		
		
		
	fix: skip albums selected or excluded from backups from deletions (#21116)
* skip albums selected or excluded from backups from deletions * filter empty local albums from library page --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									fb59fa343d
								
							
						
					
					
						commit
						ed3997d844
					
				@ -56,8 +56,9 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
 | 
			
		||||
    final assetsToDelete = _platform.isIOS ? await _getUniqueAssetsInAlbum(albumId) : await getAssetIds(albumId);
 | 
			
		||||
    await _deleteAssets(assetsToDelete);
 | 
			
		||||
 | 
			
		||||
    // All the other assets that are still associated will be unlinked automatically on-cascade
 | 
			
		||||
    await _db.managers.localAlbumEntity.filter((a) => a.id.equals(albumId)).delete();
 | 
			
		||||
    await _db.managers.localAlbumEntity
 | 
			
		||||
        .filter((a) => a.id.equals(albumId) & a.backupSelection.equals(BackupSelection.none))
 | 
			
		||||
        .delete();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  Future<void> syncDeletes(String albumId, Iterable<String> assetIdsToKeep) async {
 | 
			
		||||
@ -152,7 +153,10 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
 | 
			
		||||
        await deleteSmt.go();
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await _db.localAlbumEntity.deleteWhere((f) => f.marker_.isNotNull());
 | 
			
		||||
      // Only remove albums that are not explicitly selected or excluded from backups
 | 
			
		||||
      await _db.localAlbumEntity.deleteWhere(
 | 
			
		||||
        (f) => f.marker_.isNotNull() & f.backupSelection.equalsValue(BackupSelection.none),
 | 
			
		||||
      );
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -134,6 +134,10 @@ void _onNavigationSelected(TabsRouter router, int index, WidgetRef ref) {
 | 
			
		||||
    ref.read(remoteAlbumProvider.notifier).refresh();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (index == 3) {
 | 
			
		||||
    ref.invalidate(localAlbumProvider);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ref.read(hapticFeedbackProvider.notifier).selectionClick();
 | 
			
		||||
  router.setActiveIndex(index);
 | 
			
		||||
  ref.read(tabProvider.notifier).state = TabEnum.values[index];
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,9 @@ final localAlbumServiceProvider = Provider<LocalAlbumService>(
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
final localAlbumProvider = FutureProvider<List<LocalAlbum>>(
 | 
			
		||||
  (ref) => LocalAlbumService(ref.watch(localAlbumRepository)).getAll(sortBy: {SortLocalAlbumsBy.newestAsset}),
 | 
			
		||||
  (ref) => LocalAlbumService(ref.watch(localAlbumRepository))
 | 
			
		||||
      .getAll(sortBy: {SortLocalAlbumsBy.newestAsset})
 | 
			
		||||
      .then((albums) => albums.where((album) => album.assetCount > 0).toList()),
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
final localAlbumThumbnailProvider = FutureProvider.family<LocalAsset?, String>(
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user