diff --git a/lib/services/favorites_service.dart b/lib/services/favorites_service.dart index 7e902fa4c439c797a2148ed902134a327bd80baa..2074b06fa81167859b2c449ad83f0120f3468707 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 8e2d33acde0ee00b950ffdaea592bcb9ec012346..8aa4adc1af10fd944ed347aeb7e090fed5eaad12 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); }