diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt index 2ca3f21e..b2532e65 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt @@ -10,6 +10,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import androidx.paging.Pager import androidx.paging.PagingConfig +import androidx.paging.cachedIn import com.deliveryhero.whetstone.viewmodel.ContributesViewModel import com.slack.eithernet.ApiResult.Failure import com.slack.eithernet.ApiResult.Success @@ -40,19 +41,19 @@ constructor( private var hottestPostsPagingSource: LobstersPagingSource? = null private var newestPostsPagingSource: LobstersPagingSource? = null private val hottestPostsPager = - Pager(PagingConfig(20)) { + Pager(PagingConfig(pageSize = 20)) { pagingSourceFactory.create(api::getHottestPosts).also { hottestPostsPagingSource = it } } private val newestPostsPager = - Pager(PagingConfig(20)) { + Pager(PagingConfig(pageSize = 20)) { pagingSourceFactory.create(api::getHottestPosts).also { newestPostsPagingSource = it } } val hottestPosts - get() = hottestPostsPager.flow + get() = hottestPostsPager.flow.cachedIn(viewModelScope) val newestPosts - get() = newestPostsPager.flow + get() = newestPostsPager.flow.cachedIn(viewModelScope) private val savedPostsFlow get() = savedPostsRepository.savedPosts