Reduced amount of fetches for lists (#90)
This commit is contained in:
parent
251c054b70
commit
b0d0f43ec0
3 changed files with 34 additions and 26 deletions
|
|
@ -57,7 +57,7 @@ class _CategoriesState extends State<Categories> with AutomaticKeepAliveClientMi
|
|||
),
|
||||
itemCount: _categoriesStore.categories.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index > _categoriesStore.categories.length / 2 && _categoriesStore.hasMore) {
|
||||
if (index > _categoriesStore.categories.length - 8 && _categoriesStore.hasMore) {
|
||||
_categoriesStore.getCategories();
|
||||
}
|
||||
return CategoryCard(
|
||||
|
|
|
|||
|
|
@ -55,9 +55,6 @@ class _CategoryStreamsState extends State<CategoryStreams> {
|
|||
},
|
||||
child: Observer(
|
||||
builder: (context) {
|
||||
if (widget.listStore.streams.isEmpty && widget.listStore.isLoading && widget.listStore.error == null) {
|
||||
return const LoadingIndicator(subtitle: Text('Loading streams...'));
|
||||
}
|
||||
return Stack(
|
||||
alignment: AlignmentDirectional.bottomCenter,
|
||||
children: [
|
||||
|
|
@ -104,29 +101,38 @@ class _CategoryStreamsState extends State<CategoryStreams> {
|
|||
),
|
||||
),
|
||||
),
|
||||
SliverSafeArea(
|
||||
top: false,
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index > widget.listStore.streams.length / 2 && widget.listStore.hasMore) {
|
||||
widget.listStore.getStreams();
|
||||
}
|
||||
return Observer(
|
||||
builder: (context) => StreamCard(
|
||||
listStore: widget.listStore,
|
||||
streamInfo: widget.listStore.streams[index],
|
||||
showUptime: context.read<SettingsStore>().showThumbnailUptime,
|
||||
showThumbnail: context.read<SettingsStore>().showThumbnails,
|
||||
large: context.read<SettingsStore>().largeStreamCard,
|
||||
showCategory: false,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: widget.listStore.streams.length,
|
||||
if (widget.listStore.streams.isEmpty && widget.listStore.isLoading && widget.listStore.error == null)
|
||||
const SliverFillRemaining(
|
||||
child: Center(
|
||||
child: LoadingIndicator(
|
||||
subtitle: Text('Loading streams...'),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
SliverSafeArea(
|
||||
top: false,
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index > widget.listStore.streams.length - 8 && widget.listStore.hasMore) {
|
||||
widget.listStore.getStreams();
|
||||
}
|
||||
return Observer(
|
||||
builder: (context) => StreamCard(
|
||||
listStore: widget.listStore,
|
||||
streamInfo: widget.listStore.streams[index],
|
||||
showUptime: context.read<SettingsStore>().showThumbnailUptime,
|
||||
showThumbnail: context.read<SettingsStore>().showThumbnails,
|
||||
large: context.read<SettingsStore>().largeStreamCard,
|
||||
showCategory: false,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: widget.listStore.streams.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SafeArea(
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ class _StreamsListState extends State<StreamsList> with AutomaticKeepAliveClient
|
|||
controller: _listStore.scrollController,
|
||||
itemCount: _listStore.streams.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index > _listStore.streams.length / 2 && _listStore.hasMore) {
|
||||
if (index > _listStore.streams.length - 8 && _listStore.hasMore) {
|
||||
debugPrint('$index ${_listStore.streams.length}');
|
||||
|
||||
_listStore.getStreams();
|
||||
}
|
||||
return Observer(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue