Revert "fix: cache pager flows in ViewModel scope"

Trying to see if this fixes anything

This reverts commit 6b05a2991d.
This commit is contained in:
Harsh Shandilya 2022-11-28 11:53:12 +00:00
parent 41adf7566e
commit 238d410245

View file

@ -10,7 +10,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import androidx.paging.Pager import androidx.paging.Pager
import androidx.paging.PagingConfig import androidx.paging.PagingConfig
import androidx.paging.cachedIn
import com.deliveryhero.whetstone.viewmodel.ContributesViewModel import com.deliveryhero.whetstone.viewmodel.ContributesViewModel
import com.slack.eithernet.ApiResult.Failure import com.slack.eithernet.ApiResult.Failure
import com.slack.eithernet.ApiResult.Success import com.slack.eithernet.ApiResult.Success
@ -41,19 +40,19 @@ constructor(
private var hottestPostsPagingSource: LobstersPagingSource? = null private var hottestPostsPagingSource: LobstersPagingSource? = null
private var newestPostsPagingSource: LobstersPagingSource? = null private var newestPostsPagingSource: LobstersPagingSource? = null
private val hottestPostsPager = private val hottestPostsPager =
Pager(PagingConfig(pageSize = 20)) { Pager(PagingConfig(20)) {
pagingSourceFactory.create(api::getHottestPosts).also { hottestPostsPagingSource = it } pagingSourceFactory.create(api::getHottestPosts).also { hottestPostsPagingSource = it }
} }
private val newestPostsPager = private val newestPostsPager =
Pager(PagingConfig(pageSize = 20)) { Pager(PagingConfig(20)) {
pagingSourceFactory.create(api::getHottestPosts).also { newestPostsPagingSource = it } pagingSourceFactory.create(api::getHottestPosts).also { newestPostsPagingSource = it }
} }
val hottestPosts val hottestPosts
get() = hottestPostsPager.flow.cachedIn(viewModelScope) get() = hottestPostsPager.flow
val newestPosts val newestPosts
get() = newestPostsPager.flow.cachedIn(viewModelScope) get() = newestPostsPager.flow
private val savedPostsFlow private val savedPostsFlow
get() = savedPostsRepository.savedPosts get() = savedPostsRepository.savedPosts