From 8215755edab528a84b2fd29d946935bfdc93bc78 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Tue, 5 Jul 2022 05:28:58 -0400 Subject: [PATCH] Decrease infinite scroll fetch index --- lib/screens/home/stores/list_store.dart | 10 +--------- lib/screens/home/top/categories.dart | 2 +- lib/screens/home/top/category_streams.dart | 2 +- lib/screens/home/widgets/streams_list.dart | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/screens/home/stores/list_store.dart b/lib/screens/home/stores/list_store.dart index c40003d9..826ad023 100644 --- a/lib/screens/home/stores/list_store.dart +++ b/lib/screens/home/stores/list_store.dart @@ -74,15 +74,7 @@ abstract class ListStoreBase with Store { }); } - switch (listType) { - case ListType.followed: - if (listType == ListType.followed && authStore.isLoggedIn) getStreams(); - break; - case ListType.top: - case ListType.category: - getStreams(); - break; - } + getStreams(); } /// Fetches the streams based on the type and current cursor. diff --git a/lib/screens/home/top/categories.dart b/lib/screens/home/top/categories.dart index 9aea1c25..ca6da422 100644 --- a/lib/screens/home/top/categories.dart +++ b/lib/screens/home/top/categories.dart @@ -88,7 +88,7 @@ class _CategoriesState extends State with AutomaticKeepAliveClientMi ), itemCount: _categoriesStore.categories.length, itemBuilder: (context, index) { - if (index > _categoriesStore.categories.length - 8 && _categoriesStore.hasMore) { + if (index > _categoriesStore.categories.length - 10 && _categoriesStore.hasMore) { _categoriesStore.getCategories(); } return CategoryCard( diff --git a/lib/screens/home/top/category_streams.dart b/lib/screens/home/top/category_streams.dart index cb8cb0b7..0d652bc4 100644 --- a/lib/screens/home/top/category_streams.dart +++ b/lib/screens/home/top/category_streams.dart @@ -145,7 +145,7 @@ class _CategoryStreamsState extends State { sliver: SliverList( delegate: SliverChildBuilderDelegate( (context, index) { - if (index > _listStore.streams.length - 8 && _listStore.hasMore) { + if (index > _listStore.streams.length - 10 && _listStore.hasMore) { _listStore.getStreams(); } return Observer( diff --git a/lib/screens/home/widgets/streams_list.dart b/lib/screens/home/widgets/streams_list.dart index 8a88be44..e9200eb3 100644 --- a/lib/screens/home/widgets/streams_list.dart +++ b/lib/screens/home/widgets/streams_list.dart @@ -95,7 +95,7 @@ class _StreamsListState extends State with AutomaticKeepAliveClient controller: widget.scrollController, itemCount: _listStore.streams.length, itemBuilder: (context, index) { - if (index > _listStore.streams.length - 8 && _listStore.hasMore) { + if (index > _listStore.streams.length - 10 && _listStore.hasMore) { debugPrint('$index ${_listStore.streams.length}'); _listStore.getStreams();