fix: Playlist refresh not working #915

This commit is contained in:
Kingkor Roy Tirtho 2023-12-02 22:49:29 +06:00
parent b0beeca0cb
commit 5f1df5a87d
3 changed files with 23 additions and 12 deletions

View File

@ -28,7 +28,9 @@ class TrackView extends HookConsumerWidget {
)
: null,
extendBodyBehindAppBar: true,
body: CustomScrollView(
body: RefreshIndicator(
onRefresh: props.pagination.onRefresh,
child: CustomScrollView(
slivers: [
const TrackViewFlexHeader(),
SliverAnimatedSwitcher(
@ -39,6 +41,7 @@ class TrackView extends HookConsumerWidget {
),
],
),
),
);
}
}

View File

@ -6,6 +6,7 @@ class PaginationProps {
final bool hasNextPage;
final bool isLoading;
final VoidCallback onFetchMore;
final Future<void> Function() onRefresh;
final Future<List<Track>> Function() onFetchAll;
const PaginationProps({
@ -13,6 +14,7 @@ class PaginationProps {
required this.isLoading,
required this.onFetchMore,
required this.onFetchAll,
required this.onRefresh,
});
factory PaginationProps.fromQuery(
@ -24,6 +26,7 @@ class PaginationProps {
isLoading: query.isLoadingNextPage,
onFetchMore: query.fetchNext,
onFetchAll: onFetchAll,
onRefresh: query.refreshAll,
);
}
@ -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
@ -42,7 +46,8 @@ class PaginationProps {
hasNextPage.hashCode ^
isLoading.hashCode ^
onFetchMore.hashCode ^
onFetchAll.hashCode;
onFetchAll.hashCode ^
onRefresh.hashCode;
}
class InheritedTrackView extends InheritedWidget {

View File

@ -31,6 +31,9 @@ class LikedPlaylistPage extends HookConsumerWidget {
onFetchAll: () async {
return tracks.toList();
},
onRefresh: () async {
await likedTracks.refresh();
},
),
title: playlist.name!,
description: playlist.description,