diff --git a/lib/models/collection.dart b/lib/models/collection.dart index ae9cf6ab6..3c2ef34a1 100644 --- a/lib/models/collection.dart +++ b/lib/models/collection.dart @@ -210,6 +210,11 @@ enum CollectionType { unknown, } +extension CollectionTypeExtn on CollectionType { + bool get canDelete => + this != CollectionType.favorites && this != CollectionType.uncategorized; +} + enum CollectionParticipantRole { unknown, viewer, diff --git a/lib/ui/viewer/actions/delete_empty_albums.dart b/lib/ui/viewer/actions/delete_empty_albums.dart index aee8a2fac..3e205d731 100644 --- a/lib/ui/viewer/actions/delete_empty_albums.dart +++ b/lib/ui/viewer/actions/delete_empty_albums.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:photos/core/event_bus.dart'; import 'package:photos/events/collection_updated_event.dart'; +import 'package:photos/models/collection.dart'; import 'package:photos/models/file.dart'; import 'package:photos/services/collections_service.dart'; import 'package:photos/ui/components/action_sheet_widget.dart'; @@ -86,7 +87,10 @@ class _DeleteEmptyAlbumsState extends State { Future _deleteEmptyAlbums() async { final collections = await CollectionsService.instance.getCollectionsWithThumbnails(); - collections.removeWhere((element) => element.thumbnail != null); + collections.removeWhere( + (element) => + element.thumbnail != null || element.collection.type.canDelete, + ); int failedCount = 0; for (int i = 0; i < collections.length; i++) { if (mounted && !_isCancelled) {