Skip to content
Permalink
Browse files

Sync shows on login when idle

  • Loading branch information...
chrisbanes committed Apr 12, 2019
1 parent 688814f commit e1d9c7bc6ae525e18515bbee4d3d740aa6394561
@@ -19,5 +19,6 @@ package app.tivi.actions
interface ShowTasks {
fun syncShowWatchedEpisodes(showId: Long)
fun syncFollowedShows()
fun syncFollowedShowsWhenIdle()
fun setupNightSyncs()
}
@@ -44,6 +44,18 @@ class ShowTasksImpl @Inject constructor(
workManager.enqueue(request)
}

override fun syncFollowedShowsWhenIdle() {
val request = OneTimeWorkRequest.Builder(SyncAllFollowedShows::class.java)
.addTag(SyncAllFollowedShows.TAG)
.setConstraints(
Constraints.Builder()
.setRequiresDeviceIdle(true)
.build()
)
.build()
workManager.enqueue(request)
}

override fun setupNightSyncs() {
val request = PeriodicWorkRequest.Builder(SyncAllFollowedShows::class.java,
24, TimeUnit.HOURS, 6, TimeUnit.HOURS)
@@ -119,7 +119,7 @@ class TraktManager @Inject constructor(
persistAuthState(newState)
}
// Now trigger a sync of all shows
showTasks.syncFollowedShows()
showTasks.syncFollowedShowsWhenIdle()
}

private fun readAuthState(): AuthState {

0 comments on commit e1d9c7b

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