fix: user playlists not updating after creating/deleting, artist follow not updating after follow/unfollow

This commit is contained in:
Kingkor Roy Tirtho 2022-12-08 12:58:36 +06:00
parent 42d284f8d8
commit 6cc2a185d0
4 changed files with 19 additions and 13 deletions

View File

@ -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);
},
)
],

View File

@ -165,9 +165,9 @@ class PlaylistHeartButton extends HookConsumerWidget {
final togglePlaylistLike = useMutation<bool, Tuple2<SpotifyApi, bool>>(
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();
},

View File

@ -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(),

View File

@ -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",