Skip to content

Commit

Permalink
fix: user playlists not updating after creating/deleting, artist foll…
Browse files Browse the repository at this point in the history
…ow not updating after follow/unfollow
  • Loading branch information
KRTirtho committed Dec 8, 2022
1 parent 42d284f commit 6cc2a18
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
17 changes: 8 additions & 9 deletions lib/components/playlist/playlist_create_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
)
],
Expand Down
6 changes: 3 additions & 3 deletions lib/components/shared/heart_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down
2 changes: 1 addition & 1 deletion lib/components/shared/track_table/track_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
7 changes: 7 additions & 0 deletions lib/pages/artist/artist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6cc2a18

Please sign in to comment.