π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Get the right albums
laurenspriem4bcf7e823a1e
diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dartindex 43ada6c5e7..137e15c6a7 100644--- a/mobile/apps/photos/lib/services/collections_service.dart+++ b/mobile/apps/photos/lib/services/collections_service.dart@@ -604,6 +604,65 @@ class CollectionsService {return favorites + pinned + rest;}+ Future<List<Collection>> getCollectionsForRituals() async {+ final AlbumSortKey sortKey = localSettings.albumSortKey();+ final AlbumSortDirection sortDirection = localSettings.albumSortDirection();+ final List<Collection> collections =+ CollectionsService.instance.getCollectionsForUI();+ final bool hasFavorites = FavoritesService.instance.hasFavorites();+ late Map<int, int> collectionIDToNewestPhotoTime;+ if (sortKey == AlbumSortKey.newestPhoto) {+ collectionIDToNewestPhotoTime =+ await CollectionsService.instance.getCollectionIDToNewestFileTime();+ }+ collections.sort(+ (first, second) {+ int comparison;+ if (sortKey == AlbumSortKey.albumName) {+ comparison = compareAsciiLowerCaseNatural(+ first.displayName,+ second.displayName,+ );+ } else if (sortKey == AlbumSortKey.newestPhoto) {+ comparison =+ (collectionIDToNewestPhotoTime[second.id] ?? -1 * intMaxValue)+ .compareTo(+ collectionIDToNewestPhotoTime[first.id] ?? -1 * intMaxValue,+ );+ } else {+ comparison = second.updationTime.compareTo(first.updationTime);+ }+ return sortDirection == AlbumSortDirection.ascending+ ? comparison+ : -comparison;+ },+ );+ final List<Collection> favorites = [];+ final List<Collection> pinned = [];+ final List<Collection> rest = [];+ final int? userId = Configuration.instance.getUserID();+ for (final collection in collections) {+ if (collection.type == CollectionType.uncategorized ||+ collection.isQuickLinkCollection() ||+ (collection.isHidden()) ||+ ((userId == null || !collection.canAutoAdd(userId)))) {+ continue;+ }+ if (collection.type == CollectionType.favorites) {+ // Hide fav collection if it's empty+ if (hasFavorites) {+ favorites.add(collection);+ }+ } else if (collection.isPinned) {+ pinned.add(collection);+ } else {+ rest.add(collection);+ }+ }++ return favorites + pinned + rest;+ }+User getFileOwner(int userID, int? collectionID) {if (_cachedUserIdToUser.containsKey(userID)) {return _cachedUserIdToUser[userID]!;diff --git a/mobile/apps/photos/lib/ui/activity/rituals_section.dart b/mobile/apps/photos/lib/ui/activity/rituals_section.dartindex 0a145b20de..8a86fe22f4 100644--- a/mobile/apps/photos/lib/ui/activity/rituals_section.dart+++ b/mobile/apps/photos/lib/ui/activity/rituals_section.dart@@ -481,7 +481,7 @@ String _weekLabel(int index) {Future<Collection?> _pickAlbum(BuildContext context) async {final service = CollectionsService.instance;final albums =- List<Collection>.from(await service.getCollectionForWidgetSelection());+ List<Collection>.from(await CollectionsService.instance.getCollectionsForRituals());Collection? selected;await showModalBottomSheet(context: context,@@ -493,6 +493,16 @@ Future<Collection?> _pickAlbum(BuildContext context) async {final controller = TextEditingController();return StatefulBuilder(builder: (context, setState) {+ final bool canCreateAlbum = controller.text.trim().isNotEmpty;+ Future<void> createAlbum() async {+ final trimmed = controller.text.trim();+ if (trimmed.isEmpty) return;+ final created = await service.createAlbum(trimmed);+ if (!context.mounted) return;+ selected = created;+ Navigator.of(context).pop();+ }+return SafeArea(child: Padding(padding: EdgeInsets.only(@@ -534,35 +544,61 @@ Future<Collection?> _pickAlbum(BuildContext context) async {),Padding(padding: const EdgeInsets.fromLTRB(16, 4, 16, 12),- child: TextField(- controller: controller,- textInputAction: TextInputAction.done,- decoration: InputDecoration(- hintText: "Create new album",- prefixIcon: const Icon(Icons.add_rounded),- filled: true,- fillColor: colorScheme.fillFaint,- border: OutlineInputBorder(- borderRadius: BorderRadius.circular(14),- borderSide: BorderSide(- color: colorScheme.strokeFaint,+ child: Row(+ children: [+ Expanded(+ child: TextField(+ controller: controller,+ textInputAction: TextInputAction.done,+ decoration: InputDecoration(+ hintText: "Create new album",+ prefixIcon: const Icon(Icons.add_rounded),+ filled: true,+ fillColor: colorScheme.fillFaint,+ border: OutlineInputBorder(+ borderRadius: BorderRadius.circular(14),+ borderSide: BorderSide(+ color: colorScheme.strokeFaint,+ ),+ ),+ enabledBorder: OutlineInputBorder(+ borderRadius: BorderRadius.circular(14),+ borderSide: BorderSide(+ color: colorScheme.strokeFaint,+ ),+ ),+ ),+ onChanged: (_) => setState(() {}),+ onSubmitted: (_) async => createAlbum(),),),- enabledBorder: OutlineInputBorder(- borderRadius: BorderRadius.circular(14),- borderSide: BorderSide(- color: colorScheme.strokeFaint,+ const SizedBox(width: 8),+ ElevatedButton(+ style: ElevatedButton.styleFrom(+ backgroundColor: canCreateAlbum+ ? colorScheme.primary500+ : colorScheme.fillMuted,+ foregroundColor: colorScheme.backgroundBase,+ padding: const EdgeInsets.symmetric(+ horizontal: 14,+ vertical: 14,+ ),+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(12),+ ),+ elevation: 0,+ ),+ onPressed: canCreateAlbum ? createAlbum : null,+ child: Text(+ "Create",+ style: textTheme.bodyBold.copyWith(+ color: canCreateAlbum+ ? Colors.white+ : colorScheme.textMuted,+ ),),),- ),- onSubmitted: (value) async {- final trimmed = value.trim();- if (trimmed.isEmpty) return;- final created = await service.createAlbum(trimmed);- controller.clear();- albums.insert(0, created);- setState(() {});- },+ ],),),Flexible(