Skip to content

Commit

Permalink
Provider filter: update mappings for all shows after changing region
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed Feb 23, 2024
1 parent 3095cd4 commit 841033a
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import com.battlelancer.seriesguide.SgApp
import com.battlelancer.seriesguide.movies.MoviesSettings
import com.battlelancer.seriesguide.provider.SgRoomDatabase
import com.battlelancer.seriesguide.shows.ShowsSettings
import com.battlelancer.seriesguide.sync.SgSyncAdapter
import com.battlelancer.seriesguide.tmdbapi.TmdbTools2
import com.battlelancer.seriesguide.util.ViewTools
import com.uwetrottmann.tmdb2.entities.WatchProviders
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.text.NumberFormat
import java.util.Locale
import kotlin.coroutines.CoroutineContext
Expand Down Expand Up @@ -285,8 +287,14 @@ object StreamingSearch {
regionLiveData.postValue(region)
// In case changed in quick succession, do not run in parallel to avoid breaking diff
SgApp.coroutineScope.launch(SgApp.SINGLE) {
// Update providers for new region
updateWatchProviders(context, SgWatchProvider.Type.SHOWS, region)
updateWatchProviders(context, SgWatchProvider.Type.MOVIES, region)
// Schedule shows to update mappings for new region
SgRoomDatabase.getInstance(context).sgShow2Helper().resetLastUpdated()
withContext(Dispatchers.Main) {
SgSyncAdapter.requestSyncDeltaImmediate(context, true)
}
}
}

Expand Down

0 comments on commit 841033a

Please sign in to comment.