mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-05-08 16:24:36 +00:00
fix: remove direct access to provider.value
This commit is contained in:
parent
51710d5aee
commit
aea4bd7d16
@ -18,10 +18,10 @@ class HomeFeaturedSection extends HookConsumerWidget {
|
|||||||
return Skeletonizer(
|
return Skeletonizer(
|
||||||
enabled: featuredPlaylists.isLoadingAndEmpty,
|
enabled: featuredPlaylists.isLoadingAndEmpty,
|
||||||
child: HorizontalPlaybuttonCardView<PlaylistSimple>(
|
child: HorizontalPlaybuttonCardView<PlaylistSimple>(
|
||||||
items: featuredPlaylists.value?.items ?? [],
|
items: featuredPlaylists.asData?.value.items ?? [],
|
||||||
title: Text(context.l10n.featured),
|
title: Text(context.l10n.featured),
|
||||||
isLoadingNextPage: featuredPlaylists.isLoadingNextPage,
|
isLoadingNextPage: featuredPlaylists.isLoadingNextPage,
|
||||||
hasNextPage: featuredPlaylists.value?.hasMore ?? false,
|
hasNextPage: featuredPlaylists.asData?.value.hasMore ?? false,
|
||||||
onFetchMore: featuredPlaylistsNotifier.fetchMore,
|
onFetchMore: featuredPlaylistsNotifier.fetchMore,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -15,7 +15,8 @@ class HomePageFriendsSection extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final friendsQuery = ref.watch(friendsProvider);
|
final friendsQuery = ref.watch(friendsProvider);
|
||||||
final friends = friendsQuery.value?.friends ?? FakeData.friends.friends;
|
final friends =
|
||||||
|
friendsQuery.asData?.value.friends ?? FakeData.friends.friends;
|
||||||
|
|
||||||
final groupCount = useBreakpointValue(
|
final groupCount = useBreakpointValue(
|
||||||
sm: 3,
|
sm: 3,
|
||||||
@ -50,7 +51,8 @@ class HomePageFriendsSection extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (friendsQuery.isLoading || friendsQuery.value?.friends.isEmpty == true) {
|
if (friendsQuery.isLoading ||
|
||||||
|
friendsQuery.asData?.value.friends.isEmpty == true) {
|
||||||
return const SliverToBoxAdapter(
|
return const SliverToBoxAdapter(
|
||||||
child: SizedBox.shrink(),
|
child: SizedBox.shrink(),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class HomeNewReleasesSection extends HookConsumerWidget {
|
|||||||
|
|
||||||
if (auth == null ||
|
if (auth == null ||
|
||||||
newReleases.isLoading ||
|
newReleases.isLoading ||
|
||||||
newReleases.value?.items.isEmpty == true) {
|
newReleases.asData?.value.items.isEmpty == true) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ class HomeNewReleasesSection extends HookConsumerWidget {
|
|||||||
items: albums,
|
items: albums,
|
||||||
title: Text(context.l10n.new_releases),
|
title: Text(context.l10n.new_releases),
|
||||||
isLoadingNextPage: newReleases.isLoadingNextPage,
|
isLoadingNextPage: newReleases.isLoadingNextPage,
|
||||||
hasNextPage: newReleases.value?.hasMore ?? false,
|
hasNextPage: newReleases.asData?.value.hasMore ?? false,
|
||||||
onFetchMore: newReleasesNotifier.fetchMore,
|
onFetchMore: newReleasesNotifier.fetchMore,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,9 +33,9 @@ class UserAlbums extends HookConsumerWidget {
|
|||||||
|
|
||||||
final albums = useMemoized(() {
|
final albums = useMemoized(() {
|
||||||
if (searchText.value.isEmpty) {
|
if (searchText.value.isEmpty) {
|
||||||
return albumsQuery.value?.items ?? [];
|
return albumsQuery.asData?.value.items ?? [];
|
||||||
}
|
}
|
||||||
return albumsQuery.value?.items
|
return albumsQuery.asData?.value.items
|
||||||
.map((e) => (
|
.map((e) => (
|
||||||
weightedRatio(e.name!, searchText.value),
|
weightedRatio(e.name!, searchText.value),
|
||||||
e,
|
e,
|
||||||
@ -104,7 +104,7 @@ class UserAlbums extends HookConsumerWidget {
|
|||||||
TypeConversionUtils.simpleAlbum_X_Album(album),
|
TypeConversionUtils.simpleAlbum_X_Album(album),
|
||||||
),
|
),
|
||||||
if (albums.isNotEmpty &&
|
if (albums.isNotEmpty &&
|
||||||
albumsQuery.value?.hasMore == true)
|
albumsQuery.asData?.value.hasMore == true)
|
||||||
Waypoint(
|
Waypoint(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
isGrid: true,
|
isGrid: true,
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class UserArtists extends HookConsumerWidget {
|
|||||||
final searchText = useState('');
|
final searchText = useState('');
|
||||||
|
|
||||||
final filteredArtists = useMemoized(() {
|
final filteredArtists = useMemoized(() {
|
||||||
final artists = artistQuery.value?.items ?? [];
|
final artists = artistQuery.asData?.value.items ?? [];
|
||||||
|
|
||||||
if (searchText.value.isEmpty) {
|
if (searchText.value.isEmpty) {
|
||||||
return artists.toList();
|
return artists.toList();
|
||||||
@ -42,7 +42,7 @@ class UserArtists extends HookConsumerWidget {
|
|||||||
.where((e) => e.$1 > 50)
|
.where((e) => e.$1 > 50)
|
||||||
.map((e) => e.$2)
|
.map((e) => e.$2)
|
||||||
.toList();
|
.toList();
|
||||||
}, [artistQuery.value?.items, searchText.value]);
|
}, [artistQuery.asData?.value.items, searchText.value]);
|
||||||
|
|
||||||
final controller = useScrollController();
|
final controller = useScrollController();
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class UserArtists extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
backgroundColor: theme.scaffoldBackgroundColor,
|
backgroundColor: theme.scaffoldBackgroundColor,
|
||||||
body: artistQuery.value?.items.isEmpty == true
|
body: artistQuery.asData?.value.items.isEmpty == true
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@ -178,7 +178,7 @@ class UserLocalTracks extends HookConsumerWidget {
|
|||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: trackSnapshot.value != null
|
onPressed: trackSnapshot.value != null
|
||||||
? () async {
|
? () async {
|
||||||
if (trackSnapshot.value?.isNotEmpty == true) {
|
if (trackSnapshot.asData?.value.isNotEmpty == true) {
|
||||||
if (!isPlaylistPlaying) {
|
if (!isPlaylistPlaying) {
|
||||||
await playLocalTracks(
|
await playLocalTracks(
|
||||||
ref,
|
ref,
|
||||||
|
|||||||
@ -54,12 +54,12 @@ class UserPlaylists extends HookConsumerWidget {
|
|||||||
if (searchText.value.isEmpty) {
|
if (searchText.value.isEmpty) {
|
||||||
return [
|
return [
|
||||||
likedTracksPlaylist,
|
likedTracksPlaylist,
|
||||||
...?playlistsQuery.value?.items,
|
...?playlistsQuery.asData?.value.items,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
likedTracksPlaylist,
|
likedTracksPlaylist,
|
||||||
...?playlistsQuery.value?.items,
|
...?playlistsQuery.asData?.value.items,
|
||||||
]
|
]
|
||||||
.map((e) => (weightedRatio(e.name!, searchText.value), e))
|
.map((e) => (weightedRatio(e.name!, searchText.value), e))
|
||||||
.sorted((a, b) => b.$1.compareTo(a.$1))
|
.sorted((a, b) => b.$1.compareTo(a.$1))
|
||||||
@ -130,7 +130,7 @@ class UserPlaylists extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (playlists.isNotEmpty && index == playlists.length) {
|
if (playlists.isNotEmpty && index == playlists.length) {
|
||||||
if (playlistsQuery.value?.hasMore != true) {
|
if (playlistsQuery.asData?.value.hasMore != true) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,6 @@ class PlaylistCard extends HookConsumerWidget {
|
|||||||
final playlistNotifier = ref.watch(ProxyPlaylistNotifier.notifier);
|
final playlistNotifier = ref.watch(ProxyPlaylistNotifier.notifier);
|
||||||
final playing =
|
final playing =
|
||||||
useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying;
|
useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying;
|
||||||
final tracks = useState<List<TrackSimple>?>(null);
|
|
||||||
bool isPlaylistPlaying = useMemoized(
|
bool isPlaylistPlaying = useMemoized(
|
||||||
() => playlistQueue.containsCollection(playlist.id!),
|
() => playlistQueue.containsCollection(playlist.id!),
|
||||||
[playlistQueue, playlist.id],
|
[playlistQueue, playlist.id],
|
||||||
@ -51,7 +50,8 @@ class PlaylistCard extends HookConsumerWidget {
|
|||||||
isPlaying: isPlaylistPlaying,
|
isPlaying: isPlaylistPlaying,
|
||||||
isLoading:
|
isLoading:
|
||||||
(isPlaylistPlaying && playlistQueue.isFetching) || updating.value,
|
(isPlaylistPlaying && playlistQueue.isFetching) || updating.value,
|
||||||
isOwner: playlist.owner?.id == me.value?.id && me.value?.id != null,
|
isOwner: playlist.owner?.id == me.asData?.value.id &&
|
||||||
|
me.asData?.value.id != null,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
ServiceUtils.push(
|
ServiceUtils.push(
|
||||||
context,
|
context,
|
||||||
@ -74,7 +74,6 @@ class PlaylistCard extends HookConsumerWidget {
|
|||||||
|
|
||||||
await playlistNotifier.load(fetchedTracks, autoPlay: true);
|
await playlistNotifier.load(fetchedTracks, autoPlay: true);
|
||||||
playlistNotifier.addCollection(playlist.id!);
|
playlistNotifier.addCollection(playlist.id!);
|
||||||
tracks.value = fetchedTracks;
|
|
||||||
} finally {
|
} finally {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
updating.value = false;
|
updating.value = false;
|
||||||
@ -92,10 +91,9 @@ class PlaylistCard extends HookConsumerWidget {
|
|||||||
|
|
||||||
playlistNotifier.addTracks(fetchedTracks);
|
playlistNotifier.addTracks(fetchedTracks);
|
||||||
playlistNotifier.addCollection(playlist.id!);
|
playlistNotifier.addCollection(playlist.id!);
|
||||||
tracks.value = fetchedTracks;
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
final snackbar = SnackBar(
|
final snackbar = SnackBar(
|
||||||
content: Text("Added ${tracks.value?.length} tracks to queue"),
|
content: Text("Added ${fetchedTracks.length} tracks to queue"),
|
||||||
action: SnackBarAction(
|
action: SnackBarAction(
|
||||||
label: "Undo",
|
label: "Undo",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@ -65,7 +65,9 @@ UseTrackToggleLike useTrackToggleLike(Track track, WidgetRef ref) {
|
|||||||
final savedTracksNotifier = ref.watch(likedTracksProvider.notifier);
|
final savedTracksNotifier = ref.watch(likedTracksProvider.notifier);
|
||||||
|
|
||||||
final isLiked = useMemoized(
|
final isLiked = useMemoized(
|
||||||
() => savedTracks.value?.any((element) => element.id == track.id) ?? false,
|
() =>
|
||||||
|
savedTracks.asData?.value.any((element) => element.id == track.id) ??
|
||||||
|
false,
|
||||||
[savedTracks.value, track.id],
|
[savedTracks.value, track.id],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,10 @@ bool useIsUserPlaylist(WidgetRef ref, String playlistId) {
|
|||||||
|
|
||||||
return useMemoized(
|
return useMemoized(
|
||||||
() =>
|
() =>
|
||||||
userPlaylistsQuery.value?.items.any((e) =>
|
userPlaylistsQuery.asData?.value.items.any((e) =>
|
||||||
e.id == playlistId &&
|
e.id == playlistId &&
|
||||||
me.value != null &&
|
me.value != null &&
|
||||||
e.owner?.id == me.value?.id) ??
|
e.owner?.id == me.asData?.value.id) ??
|
||||||
false,
|
false,
|
||||||
[userPlaylistsQuery.value, playlistId, me.value],
|
[userPlaylistsQuery.value, playlistId, me.value],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -30,9 +30,9 @@ class AlbumPage extends HookConsumerWidget {
|
|||||||
title: album.name!,
|
title: album.name!,
|
||||||
description:
|
description:
|
||||||
"${context.l10n.released} • ${album.releaseDate} • ${album.artists!.first.name}",
|
"${context.l10n.released} • ${album.releaseDate} • ${album.artists!.first.name}",
|
||||||
tracks: tracks.value?.items ?? [],
|
tracks: tracks.asData?.value.items ?? [],
|
||||||
pagination: PaginationProps(
|
pagination: PaginationProps(
|
||||||
hasNextPage: tracks.value?.hasMore ?? false,
|
hasNextPage: tracks.asData?.value.hasMore ?? false,
|
||||||
isLoading: tracks.isLoading,
|
isLoading: tracks.isLoading,
|
||||||
onFetchMore: () async {
|
onFetchMore: () async {
|
||||||
await tracksNotifier.fetchMore();
|
await tracksNotifier.fetchMore();
|
||||||
|
|||||||
@ -82,7 +82,7 @@ class ArtistPageFooter extends ConsumerWidget {
|
|||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () async {
|
..onTap = () async {
|
||||||
await launchUrlString(
|
await launchUrlString(
|
||||||
"http://en.wikipedia.org/wiki?curid=${summary.value?.pageid}",
|
"http://en.wikipedia.org/wiki?curid=${summary.asData?.value?.pageid}",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class GenrePlaylistsPage extends HookConsumerWidget {
|
|||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: mediaQuery.mdAndDown ? 12 : 24,
|
horizontal: mediaQuery.mdAndDown ? 12 : 24,
|
||||||
),
|
),
|
||||||
sliver: playlists.value?.items.isNotEmpty != true
|
sliver: playlists.asData?.value.items.isNotEmpty != true
|
||||||
? Skeletonizer.sliver(
|
? Skeletonizer.sliver(
|
||||||
child: SliverToBoxAdapter(
|
child: SliverToBoxAdapter(
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
@ -114,13 +114,14 @@ class GenrePlaylistsPage extends HookConsumerWidget {
|
|||||||
crossAxisSpacing: 12,
|
crossAxisSpacing: 12,
|
||||||
mainAxisSpacing: 12,
|
mainAxisSpacing: 12,
|
||||||
),
|
),
|
||||||
itemCount: (playlists.value?.items.length ?? 0) + 1,
|
itemCount:
|
||||||
|
(playlists.asData?.value.items.length ?? 0) + 1,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final playlist =
|
final playlist = playlists.asData?.value.items
|
||||||
playlists.value?.items.elementAtOrNull(index);
|
.elementAtOrNull(index);
|
||||||
|
|
||||||
if (playlist == null) {
|
if (playlist == null) {
|
||||||
if (playlists.value?.hasMore == false) {
|
if (playlists.asData?.value.hasMore == false) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return Skeletonizer(
|
return Skeletonizer(
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
|||||||
final generatedPlaylist = ref.watch(generatePlaylistProvider(state));
|
final generatedPlaylist = ref.watch(generatePlaylistProvider(state));
|
||||||
|
|
||||||
final selectedTracks = useState<List<String>>(
|
final selectedTracks = useState<List<String>>(
|
||||||
generatedPlaylist.value?.map((e) => e.id!).toList() ?? [],
|
generatedPlaylist.asData?.value.map((e) => e.id!).toList() ?? [],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
@ -41,8 +41,8 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
|||||||
return null;
|
return null;
|
||||||
}, [generatedPlaylist.value]);
|
}, [generatedPlaylist.value]);
|
||||||
|
|
||||||
final isAllTrackSelected =
|
final isAllTrackSelected = selectedTracks.value.length ==
|
||||||
selectedTracks.value.length == (generatedPlaylist.value?.length ?? 0);
|
(generatedPlaylist.asData?.value.length ?? 0);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const PageWindowTitleBar(leading: BackButton()),
|
appBar: const PageWindowTitleBar(leading: BackButton()),
|
||||||
|
|||||||
@ -95,9 +95,9 @@ class PlainLyrics extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final lyrics =
|
final lyrics =
|
||||||
lyricsQuery.value?.lyrics.mapIndexed((i, e) {
|
lyricsQuery.asData?.value.lyrics.mapIndexed((i, e) {
|
||||||
final next =
|
final next = lyricsQuery.asData?.value.lyrics
|
||||||
lyricsQuery.value?.lyrics.elementAtOrNull(i + 1);
|
.elementAtOrNull(i + 1);
|
||||||
if (next != null &&
|
if (next != null &&
|
||||||
e.time - next.time >
|
e.time - next.time >
|
||||||
const Duration(milliseconds: 700)) {
|
const Duration(milliseconds: 700)) {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class PlaylistPage extends HookConsumerWidget {
|
|||||||
placeholder: ImagePlaceholder.collection,
|
placeholder: ImagePlaceholder.collection,
|
||||||
),
|
),
|
||||||
pagination: PaginationProps(
|
pagination: PaginationProps(
|
||||||
hasNextPage: tracks.value?.hasMore ?? false,
|
hasNextPage: tracks.asData?.value.hasMore ?? false,
|
||||||
isLoading: tracks.isLoading,
|
isLoading: tracks.isLoading,
|
||||||
onFetchMore: tracksNotifier.fetchMore,
|
onFetchMore: tracksNotifier.fetchMore,
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
@ -47,7 +47,7 @@ class PlaylistPage extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
title: playlist.name!,
|
title: playlist.name!,
|
||||||
description: playlist.description,
|
description: playlist.description,
|
||||||
tracks: tracks.value?.items ?? [],
|
tracks: tracks.asData?.value.items ?? [],
|
||||||
routePath: '/playlist/${playlist.id}',
|
routePath: '/playlist/${playlist.id}',
|
||||||
isLiked: isFavoritePlaylist.value ?? false,
|
isLiked: isFavoritePlaylist.value ?? false,
|
||||||
shareUrl: playlist.externalUrls?.spotify ?? "",
|
shareUrl: playlist.externalUrls?.spotify ?? "",
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class SearchAlbumsSection extends HookConsumerWidget {
|
|||||||
final notifier = ref.watch(searchProvider(SearchType.album).notifier);
|
final notifier = ref.watch(searchProvider(SearchType.album).notifier);
|
||||||
final albums = useMemoized(
|
final albums = useMemoized(
|
||||||
() =>
|
() =>
|
||||||
query.value?.items
|
query.asData?.value.items
|
||||||
.cast<AlbumSimple>()
|
.cast<AlbumSimple>()
|
||||||
.map(TypeConversionUtils.simpleAlbum_X_Album)
|
.map(TypeConversionUtils.simpleAlbum_X_Album)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
@ -29,7 +29,7 @@ class SearchAlbumsSection extends HookConsumerWidget {
|
|||||||
|
|
||||||
return HorizontalPlaybuttonCardView(
|
return HorizontalPlaybuttonCardView(
|
||||||
isLoadingNextPage: query.isLoadingNextPage,
|
isLoadingNextPage: query.isLoadingNextPage,
|
||||||
hasNextPage: query.value?.hasMore == true,
|
hasNextPage: query.asData?.value.hasMore == true,
|
||||||
items: albums,
|
items: albums,
|
||||||
onFetchMore: notifier.fetchMore,
|
onFetchMore: notifier.fetchMore,
|
||||||
title: Text(context.l10n.albums),
|
title: Text(context.l10n.albums),
|
||||||
|
|||||||
@ -16,11 +16,11 @@ class SearchArtistsSection extends HookConsumerWidget {
|
|||||||
final query = ref.watch(searchProvider(SearchType.artist));
|
final query = ref.watch(searchProvider(SearchType.artist));
|
||||||
final notifier = ref.watch(searchProvider(SearchType.artist).notifier);
|
final notifier = ref.watch(searchProvider(SearchType.artist).notifier);
|
||||||
|
|
||||||
final artists = query.value?.items.cast<Artist>() ?? [];
|
final artists = query.asData?.value.items.cast<Artist>() ?? [];
|
||||||
|
|
||||||
return HorizontalPlaybuttonCardView<Artist>(
|
return HorizontalPlaybuttonCardView<Artist>(
|
||||||
isLoadingNextPage: query.isLoadingNextPage,
|
isLoadingNextPage: query.isLoadingNextPage,
|
||||||
hasNextPage: query.value?.hasMore == true,
|
hasNextPage: query.asData?.value.hasMore == true,
|
||||||
items: artists,
|
items: artists,
|
||||||
onFetchMore: notifier.fetchMore,
|
onFetchMore: notifier.fetchMore,
|
||||||
title: Text(context.l10n.artists),
|
title: Text(context.l10n.artists),
|
||||||
|
|||||||
@ -15,11 +15,12 @@ class SearchPlaylistsSection extends HookConsumerWidget {
|
|||||||
final playlistsQuery = ref.watch(searchProvider(SearchType.playlist));
|
final playlistsQuery = ref.watch(searchProvider(SearchType.playlist));
|
||||||
final playlistsQueryNotifier =
|
final playlistsQueryNotifier =
|
||||||
ref.watch(searchProvider(SearchType.playlist).notifier);
|
ref.watch(searchProvider(SearchType.playlist).notifier);
|
||||||
final playlists = playlistsQuery.value?.items.cast<PlaylistSimple>() ?? [];
|
final playlists =
|
||||||
|
playlistsQuery.asData?.value.items.cast<PlaylistSimple>() ?? [];
|
||||||
|
|
||||||
return HorizontalPlaybuttonCardView(
|
return HorizontalPlaybuttonCardView(
|
||||||
isLoadingNextPage: playlistsQuery.isLoadingNextPage,
|
isLoadingNextPage: playlistsQuery.isLoadingNextPage,
|
||||||
hasNextPage: playlistsQuery.value?.hasMore == true,
|
hasNextPage: playlistsQuery.asData?.value.hasMore == true,
|
||||||
items: playlists,
|
items: playlists,
|
||||||
onFetchMore: playlistsQueryNotifier.fetchMore,
|
onFetchMore: playlistsQueryNotifier.fetchMore,
|
||||||
title: Text(context.l10n.playlists),
|
title: Text(context.l10n.playlists),
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class SearchTracksSection extends HookConsumerWidget {
|
|||||||
final searchTrackNotifier =
|
final searchTrackNotifier =
|
||||||
ref.watch(searchProvider(SearchType.track).notifier);
|
ref.watch(searchProvider(SearchType.track).notifier);
|
||||||
|
|
||||||
final tracks = searchTrack.value?.items.cast<Track>() ?? [];
|
final tracks = searchTrack.asData?.value.items.cast<Track>() ?? [];
|
||||||
final playlistNotifier = ref.watch(ProxyPlaylistNotifier.provider.notifier);
|
final playlistNotifier = ref.watch(ProxyPlaylistNotifier.provider.notifier);
|
||||||
final playlist = ref.watch(ProxyPlaylistNotifier.provider);
|
final playlist = ref.watch(ProxyPlaylistNotifier.provider);
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
@ -71,7 +71,7 @@ class SearchTracksSection extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
if (searchTrack.value?.hasMore == true && tracks.isNotEmpty)
|
if (searchTrack.asData?.value.hasMore == true && tracks.isNotEmpty)
|
||||||
Center(
|
Center(
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: searchTrack.isLoadingNextPage
|
onPressed: searchTrack.isLoadingNextPage
|
||||||
|
|||||||
@ -75,9 +75,9 @@ final userArtistAlbumReleasesProvider = Provider<List<Album>>((ref) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final userArtists =
|
final userArtists =
|
||||||
userArtistsQuery.value?.map((s) => s.id!).toList() ?? const [];
|
userArtistsQuery.asData?.value.map((s) => s.id!).toList() ?? const [];
|
||||||
|
|
||||||
final allReleases = newReleases.value?.items;
|
final allReleases = newReleases.asData?.value.items;
|
||||||
final userArtistReleases = allReleases?.where((album) {
|
final userArtistReleases = allReleases?.where((album) {
|
||||||
return album.artists?.any((artist) => userArtists.contains(artist.id!)) ==
|
return album.artists?.any((artist) => userArtists.contains(artist.id!)) ==
|
||||||
true;
|
true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user