From e9f7ac85ab64ea3767141612a54685dc0bafca2c Mon Sep 17 00:00:00 2001 From: Ash Date: Sun, 20 Mar 2022 19:26:06 +0800 Subject: [PATCH] Fix scroll load articles --- .../main/java/me/ash/reader/ui/page/home/flow/ArticleList.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleList.kt b/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleList.kt index 49e2d3b..8a4020d 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleList.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleList.kt @@ -23,7 +23,7 @@ fun LazyListScope.generateArticleList( homeViewModel: HomeViewModel, scope: CoroutineScope ) { - if (pagingItems == null) return + pagingItems ?: return var lastItemDay: String? = null for (itemIndex in 0 until pagingItems.itemCount) { val currentItem = pagingItems.peek(itemIndex) ?: continue @@ -39,7 +39,7 @@ fun LazyListScope.generateArticleList( } item { ArticleItem( - articleWithFeed = currentItem, + articleWithFeed = pagingItems[itemIndex] ?: return@item, ) { readViewModel.dispatch(ReadViewAction.ScrollToItem(0)) readViewModel.dispatch(ReadViewAction.InitData(it))