remove asynchronous call to fetch local depictedItems (#5792)

This commit is contained in:
Rohit Verma 2024-08-27 19:37:12 +05:30 committed by GitHub
parent 39a0b88e3a
commit ec4a6bc0c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,12 +16,9 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.processors.PublishProcessor
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import timber.log.Timber
import java.lang.reflect.Proxy
import java.util.*
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton
@ -88,7 +85,7 @@ class DepictsPresenter @Inject constructor(
var recentDepictedItemList: MutableList<DepictedItem> = ArrayList();
//show recentDepictedItemList when queryString is empty
if (querystring.isEmpty()) {
recentDepictedItemList = getRecentDepictedItems();
recentDepictedItemList = getRecentDepictedItems().toMutableList()
}
if (media == null) {
@ -268,17 +265,9 @@ class DepictsPresenter @Inject constructor(
/**
* Get the depicts from DepictsRoomdataBase
*/
fun getRecentDepictedItems(): MutableList<DepictedItem> {
val depictedItemList: MutableList<DepictedItem> = ArrayList()
CoroutineScope(Dispatchers.IO).launch {
private fun getRecentDepictedItems(): List<DepictedItem> = runBlocking {
val depictsList = depictsDao.depictsList().await()
for (i in depictsList.indices) {
val depictedItem = depictsList[i].item
depictedItemList.add(depictedItem)
}
}
return depictedItemList
return@runBlocking depictsList.map { it.item }
}
}