Skip to content

Commit

Permalink
fix: Playlist refresh not working KRTirtho#915
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Dec 2, 2023
1 parent b0beeca commit 5f1df5a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
23 changes: 13 additions & 10 deletions lib/components/shared/tracks_view/track_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ class TrackView extends HookConsumerWidget {
)
: null,
extendBodyBehindAppBar: true,
body: CustomScrollView(
slivers: [
const TrackViewFlexHeader(),
SliverAnimatedSwitcher(
duration: const Duration(milliseconds: 500),
child: props.tracks.isEmpty
? const ShimmerTrackTileGroup()
: const TrackViewBodySection(),
),
],
body: RefreshIndicator(
onRefresh: props.pagination.onRefresh,
child: CustomScrollView(
slivers: [
const TrackViewFlexHeader(),
SliverAnimatedSwitcher(
duration: const Duration(milliseconds: 500),
child: props.tracks.isEmpty
? const ShimmerTrackTileGroup()
: const TrackViewBodySection(),
),
],
),
),
);
}
Expand Down
9 changes: 7 additions & 2 deletions lib/components/shared/tracks_view/track_view_props.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ class PaginationProps {
final bool hasNextPage;
final bool isLoading;
final VoidCallback onFetchMore;
final Future<void> Function() onRefresh;
final Future<List<Track>> Function() onFetchAll;

const PaginationProps({
required this.hasNextPage,
required this.isLoading,
required this.onFetchMore,
required this.onFetchAll,
required this.onRefresh,
});

factory PaginationProps.fromQuery(
Expand All @@ -24,6 +26,7 @@ class PaginationProps {
isLoading: query.isLoadingNextPage,
onFetchMore: query.fetchNext,
onFetchAll: onFetchAll,
onRefresh: query.refreshAll,
);
}

Expand All @@ -33,7 +36,8 @@ class PaginationProps {
other.hasNextPage == hasNextPage &&
other.isLoading == isLoading &&
other.onFetchMore == onFetchMore &&
other.onFetchAll == onFetchAll;
other.onFetchAll == onFetchAll &&
other.onRefresh == onRefresh;
}

@override
Expand All @@ -42,7 +46,8 @@ class PaginationProps {
hasNextPage.hashCode ^
isLoading.hashCode ^
onFetchMore.hashCode ^
onFetchAll.hashCode;
onFetchAll.hashCode ^
onRefresh.hashCode;
}

class InheritedTrackView extends InheritedWidget {
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/playlist/liked_playlist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class LikedPlaylistPage extends HookConsumerWidget {
onFetchAll: () async {
return tracks.toList();
},
onRefresh: () async {
await likedTracks.refresh();
},
),
title: playlist.name!,
description: playlist.description,
Expand Down

0 comments on commit 5f1df5a

Please sign in to comment.