Skip to content

Commit

Permalink
chore: temp workaround for playlists with hidden videos
Browse files Browse the repository at this point in the history
to stop fetching more items
  • Loading branch information
MSOB7YY committed Dec 24, 2023
1 parent 5472b9b commit 8acfc81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/youtube/pages/yt_playlist_subpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ class _YTHostedPlaylistSubpageState extends State<YTHostedPlaylistSubpage> {
if (_isLoadingMoreItems.value) return;
if (!controller.hasClients) return;

final needsToLoadMore = widget.playlist.streamCount >= 0 && widget.playlist.streams.length < widget.playlist.streamCount;
final fetched = widget.playlist.streams.length;
final total = widget.playlist.streamCount;
// -- mainly a workaround for playlists containing hidden videos
// -- works only for small playlists (<=100 videos).
if (fetched > 0 && fetched <= 100 && total > 0 && total <= 100) return;
final needsToLoadMore = total >= 0 && fetched < total;
if (needsToLoadMore && controller.offset >= controller.position.maxScrollExtent - 400 && !controller.position.outOfRange) {
await _fetch100Video();
}
Expand Down

0 comments on commit 8acfc81

Please sign in to comment.