diff --git a/lib/services/favorites_service.dart b/lib/services/favorites_service.dart index 7e902fa4c..2074b06fa 100644 --- a/lib/services/favorites_service.dart +++ b/lib/services/favorites_service.dart @@ -71,8 +71,15 @@ class FavoritesService { } } - Collection getFavoritesCollection() { + Future getFavoritesCollection() async { if (!_preferences.containsKey(_favoritesCollectionIDKey)) { + final collections = _collectionsService.getOwnedCollections(); + for (final collection in collections) { + if (collection.type == CollectionType.favorites) { + await _preferences.setInt(_favoritesCollectionIDKey, collection.id); + return collection; + } + } return null; } return _collectionsService diff --git a/lib/ui/collections_gallery_widget.dart b/lib/ui/collections_gallery_widget.dart index 8e2d33acd..8aa4adc1a 100644 --- a/lib/ui/collections_gallery_widget.dart +++ b/lib/ui/collections_gallery_widget.dart @@ -114,7 +114,8 @@ class _CollectionsGalleryWidgetState extends State { }); if (favorites.length > 0) { collections.add(CollectionWithThumbnail( - FavoritesService.instance.getFavoritesCollection(), favorites[0])); + await FavoritesService.instance.getFavoritesCollection(), + favorites[0])); } return CollectionItems(folders, collections); }