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