Skip to content
Permalink
Browse files

One more async instead of launch

  • Loading branch information...
chrisbanes committed Aug 28, 2019
1 parent 1b77bcf commit 799f384922676b64b617aff3f87ac151c50383b0
Showing with 5 additions and 5 deletions.
  1. +5 −5 domain/src/main/java/app/tivi/domain/interactors/UpdateFollowedShows.kt
@@ -27,8 +27,8 @@ import app.tivi.extensions.parallelForEach
import app.tivi.inject.ProcessLifetime
import app.tivi.util.AppCoroutineDispatchers
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.plus
import javax.inject.Inject

@@ -43,20 +43,20 @@ class UpdateFollowedShows @Inject constructor(
override val scope: CoroutineScope = processScope + dispatchers.io

override suspend fun doWork(params: Params) = coroutineScope {
val syncFollowed = launch {
val syncFollowed = async {
if (params.forceRefresh || followedShowsRepository.needFollowedShowsSync()) {
followedShowsRepository.syncFollowedShows()
}
}
val syncWatched = launch {
val syncWatched = async {
// Refresh the watched shows list with a short expiry
if (params.forceRefresh || watchedShowsRepository.needUpdate(instantInPast(hours = 1))) {
watchedShowsRepository.updateWatchedShows()
}
}

syncFollowed.join()
syncWatched.join()
syncFollowed.await()
syncWatched.await()

// Finally sync the seasons/episodes and watches
followedShowsRepository.syncFollowedShows()

0 comments on commit 799f384

Please sign in to comment.
You can’t perform that action at this time.