fix: releases section is empty when user doesn't follow any artists #1104

This commit is contained in:
Kingkor Roy Tirtho 2024-01-22 19:09:57 +06:00
parent a8e9b824f3
commit 682e88e0c5

View File

@ -21,16 +21,21 @@ class HomeNewReleasesSection extends HookConsumerWidget {
userArtistsQuery.data?.map((s) => s.id!).toList() ?? const []; userArtistsQuery.data?.map((s) => s.id!).toList() ?? const [];
final albums = useMemoized( final albums = useMemoized(
() => newReleases.pages () {
.whereType<Page<AlbumSimple>>() final allReleases = newReleases.pages
.expand((page) => page.items ?? const <AlbumSimple>[]) .whereType<Page<AlbumSimple>>()
.where((album) { .expand((page) => page.items ?? const <AlbumSimple>[])
return album.artists .map((album) => TypeConversionUtils.simpleAlbum_X_Album(album));
?.any((artist) => userArtists.contains(artist.id!)) ==
true; final userArtistReleases = allReleases.where((album) {
}) return album.artists
.map((album) => TypeConversionUtils.simpleAlbum_X_Album(album)) ?.any((artist) => userArtists.contains(artist.id!)) ==
.toList(), true;
}).toList();
if (userArtistReleases.isEmpty) return allReleases.toList();
return userArtistReleases;
},
[newReleases.pages], [newReleases.pages],
); );