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
|
// there's an edge case for value being bigger
|
||||||
// than total duration. Keeping it resolved
|
// than total duration. Keeping it resolved
|
||||||
value: progress.value.toDouble(),
|
value: progress.value.toDouble(),
|
||||||
onChanged: (v) {
|
onChanged: playlist?.isLoading == true
|
||||||
progress.value = v;
|
? null
|
||||||
},
|
: (v) {
|
||||||
|
progress.value = v;
|
||||||
|
},
|
||||||
onChangeEnd: (value) async {
|
onChangeEnd: (value) async {
|
||||||
await playlistNotifier.seek(
|
await playlistNotifier.seek(
|
||||||
Duration(
|
Duration(
|
||||||
|
@ -33,7 +33,8 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
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 albumController = useScrollController();
|
||||||
final playlistController = useScrollController();
|
final playlistController = useScrollController();
|
||||||
final artistController = useScrollController();
|
final artistController = useScrollController();
|
||||||
@ -42,23 +43,27 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
final getVariables = useCallback(
|
final getVariables = useCallback(
|
||||||
() => Tuple2(
|
() => Tuple2(
|
||||||
ref.read(searchTermStateProvider),
|
ref.read(searchTermStateProvider),
|
||||||
ref.read(spotifyProvider),
|
spotify,
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
final searchTrack = useInfiniteQuery(
|
final searchTrack = useInfiniteQuery(
|
||||||
job: Queries.search.get(SearchType.track.key),
|
job: Queries.search.get(SearchType.track.key),
|
||||||
externalData: getVariables());
|
externalData: Tuple2("", spotify),
|
||||||
|
);
|
||||||
final searchAlbum = useInfiniteQuery(
|
final searchAlbum = useInfiniteQuery(
|
||||||
job: Queries.search.get(SearchType.album.key),
|
job: Queries.search.get(SearchType.album.key),
|
||||||
externalData: getVariables());
|
externalData: Tuple2("", spotify),
|
||||||
|
);
|
||||||
final searchPlaylist = useInfiniteQuery(
|
final searchPlaylist = useInfiniteQuery(
|
||||||
job: Queries.search.get(SearchType.playlist.key),
|
job: Queries.search.get(SearchType.playlist.key),
|
||||||
externalData: getVariables());
|
externalData: Tuple2("", spotify),
|
||||||
|
);
|
||||||
final searchArtist = useInfiniteQuery(
|
final searchArtist = useInfiniteQuery(
|
||||||
job: Queries.search.get(SearchType.artist.key),
|
job: Queries.search.get(SearchType.artist.key),
|
||||||
externalData: getVariables());
|
externalData: Tuple2("", spotify),
|
||||||
|
);
|
||||||
|
|
||||||
void onSearch() {
|
void onSearch() {
|
||||||
for (final query in [
|
for (final query in [
|
||||||
@ -68,9 +73,9 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
searchArtist,
|
searchArtist,
|
||||||
]) {
|
]) {
|
||||||
query.enabled = false;
|
query.enabled = false;
|
||||||
query.fetched = true;
|
query.fetched = false;
|
||||||
query.setExternalData(getVariables());
|
query.setExternalData(getVariables());
|
||||||
query.refetch();
|
query.refetchPages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +155,9 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
const PlatformCircularProgressIndicator()
|
const PlatformCircularProgressIndicator()
|
||||||
else if (searchTrack.hasError)
|
else if (searchTrack.hasError)
|
||||||
PlatformText(searchTrack
|
PlatformText(searchTrack
|
||||||
.error?[searchTrack.pageParams.last])
|
.error?[searchTrack.pageParams.last]
|
||||||
|
?.toString() ??
|
||||||
|
"")
|
||||||
else
|
else
|
||||||
...tracks.asMap().entries.map((track) {
|
...tracks.asMap().entries.map((track) {
|
||||||
String duration =
|
String duration =
|
||||||
@ -233,8 +240,12 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
!searchPlaylist.isFetchingNextPage)
|
!searchPlaylist.isFetchingNextPage)
|
||||||
const PlatformCircularProgressIndicator(),
|
const PlatformCircularProgressIndicator(),
|
||||||
if (searchPlaylist.hasError)
|
if (searchPlaylist.hasError)
|
||||||
PlatformText(searchPlaylist
|
PlatformText(
|
||||||
.error?[searchPlaylist.pageParams.last]),
|
searchPlaylist.error?[
|
||||||
|
searchPlaylist.pageParams.last]
|
||||||
|
?.toString() ??
|
||||||
|
"",
|
||||||
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (artists.isNotEmpty)
|
if (artists.isNotEmpty)
|
||||||
PlatformText.headline("Artists"),
|
PlatformText.headline("Artists"),
|
||||||
@ -284,8 +295,12 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
!searchArtist.isFetchingNextPage)
|
!searchArtist.isFetchingNextPage)
|
||||||
const PlatformCircularProgressIndicator(),
|
const PlatformCircularProgressIndicator(),
|
||||||
if (searchArtist.hasError)
|
if (searchArtist.hasError)
|
||||||
PlatformText(searchArtist
|
PlatformText(
|
||||||
.error?[searchArtist.pageParams.last]),
|
searchArtist.error?[
|
||||||
|
searchArtist.pageParams.last]
|
||||||
|
?.toString() ??
|
||||||
|
"",
|
||||||
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (albums.isNotEmpty)
|
if (albums.isNotEmpty)
|
||||||
PlatformText.subheading("Albums"),
|
PlatformText.subheading("Albums"),
|
||||||
@ -333,8 +348,12 @@ class SearchPage extends HookConsumerWidget {
|
|||||||
!searchAlbum.isFetchingNextPage)
|
!searchAlbum.isFetchingNextPage)
|
||||||
const PlatformCircularProgressIndicator(),
|
const PlatformCircularProgressIndicator(),
|
||||||
if (searchAlbum.hasError)
|
if (searchAlbum.hasError)
|
||||||
PlatformText(searchAlbum
|
PlatformText(
|
||||||
.error?[searchAlbum.pageParams.last]),
|
searchAlbum
|
||||||
|
.error?[searchAlbum.pageParams.last]
|
||||||
|
?.toString() ??
|
||||||
|
"",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -15,9 +15,9 @@ class SearchQueries {
|
|||||||
: lastParam + 10,
|
: lastParam + 10,
|
||||||
getPreviousPageParam: (lastPage, lastParam) => lastParam - 10,
|
getPreviousPageParam: (lastPage, lastParam) => lastParam - 10,
|
||||||
task: (queryKey, pageParam, variables) {
|
task: (queryKey, pageParam, variables) {
|
||||||
|
if (variables.item1.trim().isEmpty) return [];
|
||||||
final queryString = variables.item1;
|
final queryString = variables.item1;
|
||||||
final spotify = variables.item2;
|
final spotify = variables.item2;
|
||||||
if (queryString.isEmpty) return [];
|
|
||||||
final searchType = getVariable(queryKey);
|
final searchType = getVariable(queryKey);
|
||||||
return spotify.search.get(
|
return spotify.search.get(
|
||||||
queryString,
|
queryString,
|
||||||
|
Loading…
Reference in New Issue
Block a user