Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] Handle received Favorites visibility

laurenspriem62830314031a
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
index b9cb2202bf..a6ffbe3a95 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
@@ -375,12 +375,15 @@ class _AlbumSelectionActionWidgetState
Future<void> _onHideOrUnHideClick() async {
final userID = Configuration.instance.getUserID()!;
+ final hasOwnedFavorites = widget.selectedAlbums.albums.any(
+ (collection) => _isOwnedFavorite(collection, userID),
+ );
final collections = widget.selectedAlbums.albums
- .where((c) => c.type != CollectionType.favorites)
+ .where((collection) => !_isOwnedFavorite(collection, userID))
.toList();
if (collections.isEmpty) {
- if (hasFavorites) {
+ if (hasOwnedFavorites) {
_showFavToast();
}
widget.selectedAlbums.clearAll();
@@ -440,19 +443,23 @@ class _AlbumSelectionActionWidgetState
await dialog.hide();
}
- if (hasFavorites) {
+ if (hasOwnedFavorites) {
_showFavToast();
}
widget.selectedAlbums.clearAll();
}
Future<void> _archiveClick() async {
+ final userID = Configuration.instance.getUserID()!;
+ final hasOwnedFavorites = widget.selectedAlbums.albums.any(
+ (collection) => _isOwnedFavorite(collection, userID),
+ );
final collections = widget.selectedAlbums.albums
- .where((c) => c.type != CollectionType.favorites)
+ .where((collection) => !_isOwnedFavorite(collection, userID))
.toList();
if (collections.isEmpty) {
- if (hasFavorites) {
+ if (hasOwnedFavorites) {
_showFavToast();
}
widget.selectedAlbums.clearAll();
@@ -522,7 +529,7 @@ class _AlbumSelectionActionWidgetState
await dialog.hide();
}
- if (hasFavorites) {
+ if (hasOwnedFavorites) {
_showFavToast();
}
if (mounted) {
@@ -531,6 +538,11 @@ class _AlbumSelectionActionWidgetState
widget.selectedAlbums.clearAll();
}
+ bool _isOwnedFavorite(Collection collection, int userID) {
+ return collection.type == CollectionType.favorites &&
+ collection.isOwner(userID);
+ }
+
bool _usesShareeMetadata(Collection collection) {
return widget.sectionType == UISectionType.incomingCollections ||
widget.sectionType == UISectionType.homeCollections &&