Ensure that favorites are parsed from fetched collections

This commit is contained in:
Vishnu Mohandas 2020-10-26 15:28:08 +05:30
parent 95ccf02b2e
commit 0c48d83384
2 changed files with 10 additions and 2 deletions

View file

@ -71,8 +71,15 @@ class FavoritesService {
}
}
Collection getFavoritesCollection() {
Future<Collection> 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

View file

@ -114,7 +114,8 @@ class _CollectionsGalleryWidgetState extends State<CollectionsGalleryWidget> {
});
if (favorites.length > 0) {
collections.add(CollectionWithThumbnail(
FavoritesService.instance.getFavoritesCollection(), favorites[0]));
await FavoritesService.instance.getFavoritesCollection(),
favorites[0]));
}
return CollectionItems(folders, collections);
}