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,16 +28,19 @@ class TrackView extends HookConsumerWidget {
) )
: null, : null,
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
body: CustomScrollView( body: RefreshIndicator(
slivers: [ onRefresh: props.pagination.onRefresh,
const TrackViewFlexHeader(), child: CustomScrollView(
SliverAnimatedSwitcher( slivers: [
duration: const Duration(milliseconds: 500), const TrackViewFlexHeader(),
child: props.tracks.isEmpty SliverAnimatedSwitcher(
? const ShimmerTrackTileGroup() duration: const Duration(milliseconds: 500),
: const TrackViewBodySection(), child: props.tracks.isEmpty
), ? const ShimmerTrackTileGroup()
], : const TrackViewBodySection(),
),
],
),
), ),
); );
} }

View File

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

View File

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