Skip to content

Commit

Permalink
replace MainScope with coroutineScope for database operations
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit9625 committed Oct 26, 2024
1 parent 249ed1c commit 61d5010
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import fr.free.nrw.commons.utils.CustomSelectorUtils
import fr.free.nrw.commons.utils.CustomSelectorUtils.Companion.checkWhetherFileExistsOnCommonsUsingSHA1
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.util.Calendar
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -65,7 +65,7 @@ class ImageLoader
/**
* Coroutine Scope.
*/
private val scope: CoroutineScope = MainScope()
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO)

/**
* Query image and setUp the view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import fr.free.nrw.commons.upload.UploadProgressActivity
import fr.free.nrw.commons.upload.UploadResult
import fr.free.nrw.commons.wikidata.WikidataEditService
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
Expand Down Expand Up @@ -534,7 +534,7 @@ class UploadWorker(
contribution.contentUri?.let {
val imageSha1 = contribution.imageSHA1.toString()
val modifiedSha1 = fileUtilsWrapper.getSHA1(fileUtilsWrapper.getFileInputStream(contribution.localUri?.path))
MainScope().launch {
CoroutineScope(Dispatchers.IO).launch {
uploadedStatusDao.insertUploaded(
UploadedStatus(
imageSha1,
Expand Down

0 comments on commit 61d5010

Please sign in to comment.