Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import com.example.android.codelabs.paging.api.IN_QUALIFIER
import com.example.android.codelabs.paging.db.RemoteKeys
import com.example.android.codelabs.paging.db.RepoDatabase
import com.example.android.codelabs.paging.model.Repo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.single
import retrofit2.HttpException
import java.io.IOException
import java.io.InvalidObjectException
Expand All @@ -48,7 +52,8 @@ class GithubRemoteMediator(
remoteKeys?.nextKey?.minus(1) ?: GITHUB_STARTING_PAGE_INDEX
}
LoadType.PREPEND -> {
val remoteKeys = getRemoteKeyForFirstItem(state)
val remoteKeys = flowOf(getRemoteKeyForFirstItem(state))
.flowOn(Dispatchers.IO).single()
if (remoteKeys == null) {
Comment on lines +55 to 57

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still crash on first launch

// The LoadType is PREPEND so some data was loaded before,
// so we should have been able to get remote keys
Expand Down