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