Skip to content

remove asynchronous call to fetch local depictedItems #5792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2024
Merged
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 @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
val depictsList = depictsDao.depictsList().await()

for (i in depictsList.indices) {
val depictedItem = depictsList[i].item
depictedItemList.add(depictedItem)
}
}
return depictedItemList
private fun getRecentDepictedItems(): List<DepictedItem> = runBlocking {
val depictsList = depictsDao.depictsList().await()
return@runBlocking depictsList.map { it.item }
}
}

Expand Down
Loading