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 { onPressed: () async {
if (playlistName.text.isEmpty) return; if (playlistName.text.isEmpty) return;
final me = await spotify.me.get(); final me = await spotify.me.get();
await spotify.playlists await spotify.playlists.createPlaylist(
.createPlaylist(
me.id!, me.id!,
playlistName.text, playlistName.text,
collaborative: collaborative.value, collaborative: collaborative.value,
public: public.value, public: public.value,
description: description.text, description: description.text,
) );
.then((_) { await QueryBowl.of(context)
QueryBowl.of(context).refetchQueries([ .getQuery(
Queries.playlist.ofMine.queryKey, Queries.playlist.ofMine.queryKey,
]); )
Navigator.pop(context); ?.refetch();
}); Navigator.pop(context);
}, },
) )
], ],

View File

@ -165,9 +165,9 @@ class PlaylistHeartButton extends HookConsumerWidget {
final togglePlaylistLike = useMutation<bool, Tuple2<SpotifyApi, bool>>( final togglePlaylistLike = useMutation<bool, Tuple2<SpotifyApi, bool>>(
job: Mutations.playlist.toggleFavorite(playlist.id!), job: Mutations.playlist.toggleFavorite(playlist.id!),
onData: (payload, variables, queryContext) { onData: (payload, variables, queryContext) async {
isLikedQuery.refetch(); await isLikedQuery.refetch();
QueryBowl.of(context) await QueryBowl.of(context)
.getQuery(Queries.playlist.ofMine.queryKey) .getQuery(Queries.playlist.ofMine.queryKey)
?.refetch(); ?.refetch();
}, },

View File

@ -306,7 +306,7 @@ class TrackTile extends HookConsumerWidget {
), ),
if (userPlaylist && auth.isLoggedIn) if (userPlaylist && auth.isLoggedIn)
Action( Action(
icon: removeTrack.isLoading && icon: (removeTrack.isLoading || !removeTrack.hasData) &&
removingTrack.value == track.value.uri removingTrack.value == track.value.uri
? const Center( ? const Center(
child: PlatformCircularProgressIndicator(), child: PlatformCircularProgressIndicator(),

View File

@ -157,6 +157,13 @@ class ArtistPage extends HookConsumerWidget {
FollowingType.artist, FollowingType.artist,
[artistId], [artistId],
); );
await isFollowingQuery.refetch();
QueryBowl.of(context)
.getInfiniteQuery(
Queries.artist.followedByMe
.queryKey,
)
?.refetch();
} catch (e, stack) { } catch (e, stack) {
logger.e( logger.e(
"FollowButton.onPressed", "FollowButton.onPressed",