Scroll back to last seen item(from unread list) (#935)
* refactor: use initial items in unread reading-view-model * chore: remove code comment
This commit is contained in:
parent
54e022169a
commit
74d0c50da7
@ -48,6 +48,8 @@ class ReadingViewModel @Inject constructor(
|
||||
private val currentFeed: Feed?
|
||||
get() = readingUiState.value.articleWithFeed?.feed
|
||||
|
||||
private var initialArticleItems: List<ArticleFlowItem> = emptyList()
|
||||
|
||||
fun initData(articleId: String) {
|
||||
setLoading()
|
||||
viewModelScope.launch(ioDispatcher) {
|
||||
@ -151,7 +153,11 @@ class ReadingViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun prefetchArticleId(pagingItems: ItemSnapshotList<ArticleFlowItem>) {
|
||||
val items = pagingItems.items
|
||||
if (initialArticleItems.isEmpty()) {
|
||||
initialArticleItems = pagingItems.items
|
||||
}
|
||||
|
||||
val items = initialArticleItems
|
||||
val currentId = currentArticle?.id
|
||||
val index = items.indexOfFirst { item ->
|
||||
item is ArticleFlowItem.Article && item.articleWithFeed.article.id == currentId
|
||||
|
Loading…
x
Reference in New Issue
Block a user