Use withContext(Dispatchers.IO) when writing android files
This commit is contained in:
@ -27,8 +27,8 @@ android {
|
||||
applicationId = "app.omnivore.omnivore"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 2100000
|
||||
versionName = "0.210.0"
|
||||
versionCode = 2110000
|
||||
versionName = "0.211.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
||||
@ -150,21 +150,26 @@ class FollowingViewModel @Inject constructor(
|
||||
|
||||
fun loadUsingSearchAPI() {
|
||||
viewModelScope.launch {
|
||||
val context = applicationContext
|
||||
val result = libraryRepository.librarySearch(
|
||||
context = context,
|
||||
cursor = librarySearchCursor,
|
||||
query = searchQueryString()
|
||||
)
|
||||
result.cursor?.let {
|
||||
librarySearchCursor = it
|
||||
}
|
||||
result.savedItems.map {
|
||||
val isSavedInDB = libraryRepository.isSavedItemContentStoredInDB(context = applicationContext, it.savedItem.slug)
|
||||
withContext(Dispatchers.IO) {
|
||||
val context = applicationContext
|
||||
val result = libraryRepository.librarySearch(
|
||||
context = context,
|
||||
cursor = librarySearchCursor,
|
||||
query = searchQueryString()
|
||||
)
|
||||
result.cursor?.let {
|
||||
librarySearchCursor = it
|
||||
}
|
||||
result.savedItems.map {
|
||||
val isSavedInDB = libraryRepository.isSavedItemContentStoredInDB(
|
||||
context = applicationContext,
|
||||
it.savedItem.slug
|
||||
)
|
||||
|
||||
if (!isSavedInDB) {
|
||||
delay(2000)
|
||||
contentRequestChannel.send(it.savedItem.slug)
|
||||
if (!isSavedInDB) {
|
||||
delay(2000)
|
||||
contentRequestChannel.send(it.savedItem.slug)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,20 +177,23 @@ class LibraryViewModel @Inject constructor(
|
||||
fun loadUsingSearchAPI() {
|
||||
val context = applicationContext
|
||||
viewModelScope.launch {
|
||||
val result = libraryRepository.librarySearch(
|
||||
context = context,
|
||||
cursor = librarySearchCursor,
|
||||
query = searchQueryString()
|
||||
)
|
||||
result.cursor?.let {
|
||||
librarySearchCursor = it
|
||||
}
|
||||
result.savedItems.map {
|
||||
val isSavedInDB = libraryRepository.isSavedItemContentStoredInDB(context, it.savedItem.slug)
|
||||
withContext(Dispatchers.IO) {
|
||||
val result = libraryRepository.librarySearch(
|
||||
context = context,
|
||||
cursor = librarySearchCursor,
|
||||
query = searchQueryString()
|
||||
)
|
||||
result.cursor?.let {
|
||||
librarySearchCursor = it
|
||||
}
|
||||
result.savedItems.map {
|
||||
val isSavedInDB =
|
||||
libraryRepository.isSavedItemContentStoredInDB(context, it.savedItem.slug)
|
||||
|
||||
if (!isSavedInDB) {
|
||||
delay(2000)
|
||||
contentRequestChannel.send(it.savedItem.slug)
|
||||
if (!isSavedInDB) {
|
||||
delay(2000)
|
||||
contentRequestChannel.send(it.savedItem.slug)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user