Skip to content

Commit

Permalink
fix: releases section is empty when user doesn't follow any artists #…
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jan 22, 2024
1 parent a8e9b82 commit 682e88e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/components/home/sections/new_releases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ class HomeNewReleasesSection extends HookConsumerWidget {
userArtistsQuery.data?.map((s) => s.id!).toList() ?? const [];

final albums = useMemoized(
() => newReleases.pages
.whereType<Page<AlbumSimple>>()
.expand((page) => page.items ?? const <AlbumSimple>[])
.where((album) {
return album.artists
?.any((artist) => userArtists.contains(artist.id!)) ==
true;
})
.map((album) => TypeConversionUtils.simpleAlbum_X_Album(album))
.toList(),
() {
final allReleases = newReleases.pages
.whereType<Page<AlbumSimple>>()
.expand((page) => page.items ?? const <AlbumSimple>[])
.map((album) => TypeConversionUtils.simpleAlbum_X_Album(album));

final userArtistReleases = allReleases.where((album) {
return album.artists
?.any((artist) => userArtists.contains(artist.id!)) ==
true;
}).toList();

if (userArtistReleases.isEmpty) return allReleases.toList();
return userArtistReleases;
},
[newReleases.pages],
);

Expand Down

0 comments on commit 682e88e

Please sign in to comment.