mirror of
https://github.com/immich-app/immich.git
synced 2026-01-27 07:14:46 -08:00
clear up stale album id
This commit is contained in:
@@ -123,6 +123,16 @@ class CleanupNotifier extends StateNotifier<CleanupState> {
|
||||
_appSettingsService.setSetting(AppSettingsEnum.cleanupKeepAlbumIds, albumIds.join(','));
|
||||
}
|
||||
|
||||
/// Remove album IDs that no longer exist on the device
|
||||
void cleanupStaleAlbumIds(Set<String> existingAlbumIds) {
|
||||
final staleIds = state.keepAlbumIds.difference(existingAlbumIds);
|
||||
if (staleIds.isNotEmpty) {
|
||||
final cleanedIds = state.keepAlbumIds.intersection(existingAlbumIds);
|
||||
state = state.copyWith(keepAlbumIds: cleanedIds);
|
||||
_persistExcludedAlbumIds(cleanedIds);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> scanAssets() async {
|
||||
if (_userId == null || state.selectedDate == null) {
|
||||
return;
|
||||
|
||||
@@ -779,6 +779,15 @@ class _KeepAlbumsSection extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final albumsAsync = ref.watch(localAlbumProvider);
|
||||
|
||||
// Clean up stale album IDs when albums are loaded
|
||||
albumsAsync.whenData((albums) {
|
||||
final existingAlbumIds = albums.map((a) => a.id).toSet();
|
||||
// Use Future.microtask to avoid modifying state during build
|
||||
Future.microtask(() {
|
||||
ref.read(cleanupProvider.notifier).cleanupStaleAlbumIds(existingAlbumIds);
|
||||
});
|
||||
});
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user