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?
|
private val currentFeed: Feed?
|
||||||
get() = readingUiState.value.articleWithFeed?.feed
|
get() = readingUiState.value.articleWithFeed?.feed
|
||||||
|
|
||||||
|
private var initialArticleItems: List<ArticleFlowItem> = emptyList()
|
||||||
|
|
||||||
fun initData(articleId: String) {
|
fun initData(articleId: String) {
|
||||||
setLoading()
|
setLoading()
|
||||||
viewModelScope.launch(ioDispatcher) {
|
viewModelScope.launch(ioDispatcher) {
|
||||||
@ -151,7 +153,11 @@ class ReadingViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun prefetchArticleId(pagingItems: ItemSnapshotList<ArticleFlowItem>) {
|
fun prefetchArticleId(pagingItems: ItemSnapshotList<ArticleFlowItem>) {
|
||||||
val items = pagingItems.items
|
if (initialArticleItems.isEmpty()) {
|
||||||
|
initialArticleItems = pagingItems.items
|
||||||
|
}
|
||||||
|
|
||||||
|
val items = initialArticleItems
|
||||||
val currentId = currentArticle?.id
|
val currentId = currentArticle?.id
|
||||||
val index = items.indexOfFirst { item ->
|
val index = items.indexOfFirst { item ->
|
||||||
item is ArticleFlowItem.Article && item.articleWithFeed.article.id == currentId
|
item is ArticleFlowItem.Article && item.articleWithFeed.article.id == currentId
|
||||||
|
Loading…
x
Reference in New Issue
Block a user