From 6cc2a185d0c4c19f176e6f65b8ada19ebc76af5e Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Thu, 8 Dec 2022 12:58:36 +0600 Subject: [PATCH] fix: user playlists not updating after creating/deleting, artist follow not updating after follow/unfollow --- .../playlist/playlist_create_dialog.dart | 17 ++++++++--------- lib/components/shared/heart_button.dart | 6 +++--- .../shared/track_table/track_tile.dart | 2 +- lib/pages/artist/artist.dart | 7 +++++++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/components/playlist/playlist_create_dialog.dart b/lib/components/playlist/playlist_create_dialog.dart index 1e112519f..e5220438d 100644 --- a/lib/components/playlist/playlist_create_dialog.dart +++ b/lib/components/playlist/playlist_create_dialog.dart @@ -34,20 +34,19 @@ class PlaylistCreateDialog extends HookConsumerWidget { onPressed: () async { if (playlistName.text.isEmpty) return; final me = await spotify.me.get(); - await spotify.playlists - .createPlaylist( + await spotify.playlists.createPlaylist( me.id!, playlistName.text, collaborative: collaborative.value, public: public.value, description: description.text, - ) - .then((_) { - QueryBowl.of(context).refetchQueries([ - Queries.playlist.ofMine.queryKey, - ]); - Navigator.pop(context); - }); + ); + await QueryBowl.of(context) + .getQuery( + Queries.playlist.ofMine.queryKey, + ) + ?.refetch(); + Navigator.pop(context); }, ) ], diff --git a/lib/components/shared/heart_button.dart b/lib/components/shared/heart_button.dart index bee9cc601..4c294967a 100644 --- a/lib/components/shared/heart_button.dart +++ b/lib/components/shared/heart_button.dart @@ -165,9 +165,9 @@ class PlaylistHeartButton extends HookConsumerWidget { final togglePlaylistLike = useMutation>( job: Mutations.playlist.toggleFavorite(playlist.id!), - onData: (payload, variables, queryContext) { - isLikedQuery.refetch(); - QueryBowl.of(context) + onData: (payload, variables, queryContext) async { + await isLikedQuery.refetch(); + await QueryBowl.of(context) .getQuery(Queries.playlist.ofMine.queryKey) ?.refetch(); }, diff --git a/lib/components/shared/track_table/track_tile.dart b/lib/components/shared/track_table/track_tile.dart index 01c357fe3..b52f4b67c 100644 --- a/lib/components/shared/track_table/track_tile.dart +++ b/lib/components/shared/track_table/track_tile.dart @@ -306,7 +306,7 @@ class TrackTile extends HookConsumerWidget { ), if (userPlaylist && auth.isLoggedIn) Action( - icon: removeTrack.isLoading && + icon: (removeTrack.isLoading || !removeTrack.hasData) && removingTrack.value == track.value.uri ? const Center( child: PlatformCircularProgressIndicator(), diff --git a/lib/pages/artist/artist.dart b/lib/pages/artist/artist.dart index c70893a51..14faafc1e 100644 --- a/lib/pages/artist/artist.dart +++ b/lib/pages/artist/artist.dart @@ -157,6 +157,13 @@ class ArtistPage extends HookConsumerWidget { FollowingType.artist, [artistId], ); + await isFollowingQuery.refetch(); + QueryBowl.of(context) + .getInfiniteQuery( + Queries.artist.followedByMe + .queryKey, + ) + ?.refetch(); } catch (e, stack) { logger.e( "FollowButton.onPressed",