mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix(search): grey screen, only tracks update on new search string, playlists,albums,artists show up before hitting return/submit
This commit is contained in:
parent
1bb38c3917
commit
a774817240
@ -111,9 +111,11 @@ class PlayerControls extends HookConsumerWidget {
|
||||
// there's an edge case for value being bigger
|
||||
// than total duration. Keeping it resolved
|
||||
value: progress.value.toDouble(),
|
||||
onChanged: (v) {
|
||||
progress.value = v;
|
||||
},
|
||||
onChanged: playlist?.isLoading == true
|
||||
? null
|
||||
: (v) {
|
||||
progress.value = v;
|
||||
},
|
||||
onChangeEnd: (value) async {
|
||||
await playlistNotifier.seek(
|
||||
Duration(
|
||||
|
@ -33,7 +33,8 @@ class SearchPage extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, ref) {
|
||||
final Auth auth = ref.watch(authProvider);
|
||||
final auth = ref.watch(authProvider);
|
||||
final spotify = ref.watch(spotifyProvider);
|
||||
final albumController = useScrollController();
|
||||
final playlistController = useScrollController();
|
||||
final artistController = useScrollController();
|
||||
@ -42,23 +43,27 @@ class SearchPage extends HookConsumerWidget {
|
||||
final getVariables = useCallback(
|
||||
() => Tuple2(
|
||||
ref.read(searchTermStateProvider),
|
||||
ref.read(spotifyProvider),
|
||||
spotify,
|
||||
),
|
||||
[],
|
||||
);
|
||||
|
||||
final searchTrack = useInfiniteQuery(
|
||||
job: Queries.search.get(SearchType.track.key),
|
||||
externalData: getVariables());
|
||||
job: Queries.search.get(SearchType.track.key),
|
||||
externalData: Tuple2("", spotify),
|
||||
);
|
||||
final searchAlbum = useInfiniteQuery(
|
||||
job: Queries.search.get(SearchType.album.key),
|
||||
externalData: getVariables());
|
||||
job: Queries.search.get(SearchType.album.key),
|
||||
externalData: Tuple2("", spotify),
|
||||
);
|
||||
final searchPlaylist = useInfiniteQuery(
|
||||
job: Queries.search.get(SearchType.playlist.key),
|
||||
externalData: getVariables());
|
||||
job: Queries.search.get(SearchType.playlist.key),
|
||||
externalData: Tuple2("", spotify),
|
||||
);
|
||||
final searchArtist = useInfiniteQuery(
|
||||
job: Queries.search.get(SearchType.artist.key),
|
||||
externalData: getVariables());
|
||||
job: Queries.search.get(SearchType.artist.key),
|
||||
externalData: Tuple2("", spotify),
|
||||
);
|
||||
|
||||
void onSearch() {
|
||||
for (final query in [
|
||||
@ -68,9 +73,9 @@ class SearchPage extends HookConsumerWidget {
|
||||
searchArtist,
|
||||
]) {
|
||||
query.enabled = false;
|
||||
query.fetched = true;
|
||||
query.fetched = false;
|
||||
query.setExternalData(getVariables());
|
||||
query.refetch();
|
||||
query.refetchPages();
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +155,9 @@ class SearchPage extends HookConsumerWidget {
|
||||
const PlatformCircularProgressIndicator()
|
||||
else if (searchTrack.hasError)
|
||||
PlatformText(searchTrack
|
||||
.error?[searchTrack.pageParams.last])
|
||||
.error?[searchTrack.pageParams.last]
|
||||
?.toString() ??
|
||||
"")
|
||||
else
|
||||
...tracks.asMap().entries.map((track) {
|
||||
String duration =
|
||||
@ -233,8 +240,12 @@ class SearchPage extends HookConsumerWidget {
|
||||
!searchPlaylist.isFetchingNextPage)
|
||||
const PlatformCircularProgressIndicator(),
|
||||
if (searchPlaylist.hasError)
|
||||
PlatformText(searchPlaylist
|
||||
.error?[searchPlaylist.pageParams.last]),
|
||||
PlatformText(
|
||||
searchPlaylist.error?[
|
||||
searchPlaylist.pageParams.last]
|
||||
?.toString() ??
|
||||
"",
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (artists.isNotEmpty)
|
||||
PlatformText.headline("Artists"),
|
||||
@ -284,8 +295,12 @@ class SearchPage extends HookConsumerWidget {
|
||||
!searchArtist.isFetchingNextPage)
|
||||
const PlatformCircularProgressIndicator(),
|
||||
if (searchArtist.hasError)
|
||||
PlatformText(searchArtist
|
||||
.error?[searchArtist.pageParams.last]),
|
||||
PlatformText(
|
||||
searchArtist.error?[
|
||||
searchArtist.pageParams.last]
|
||||
?.toString() ??
|
||||
"",
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (albums.isNotEmpty)
|
||||
PlatformText.subheading("Albums"),
|
||||
@ -333,8 +348,12 @@ class SearchPage extends HookConsumerWidget {
|
||||
!searchAlbum.isFetchingNextPage)
|
||||
const PlatformCircularProgressIndicator(),
|
||||
if (searchAlbum.hasError)
|
||||
PlatformText(searchAlbum
|
||||
.error?[searchAlbum.pageParams.last]),
|
||||
PlatformText(
|
||||
searchAlbum
|
||||
.error?[searchAlbum.pageParams.last]
|
||||
?.toString() ??
|
||||
"",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -15,9 +15,9 @@ class SearchQueries {
|
||||
: lastParam + 10,
|
||||
getPreviousPageParam: (lastPage, lastParam) => lastParam - 10,
|
||||
task: (queryKey, pageParam, variables) {
|
||||
if (variables.item1.trim().isEmpty) return [];
|
||||
final queryString = variables.item1;
|
||||
final spotify = variables.item2;
|
||||
if (queryString.isEmpty) return [];
|
||||
final searchType = getVariable(queryKey);
|
||||
return spotify.search.get(
|
||||
queryString,
|
||||
|
Loading…
Reference in New Issue
Block a user