Don't force update weather data on every restart

This commit is contained in:
MM20 2022-01-02 17:40:00 +01:00
parent 7b2ae4c8ac
commit 1d589e5246
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -110,18 +110,21 @@ class WeatherRepositoryImpl(
var providerSetting: WeatherSettings.WeatherProvider? = null var providerSetting: WeatherSettings.WeatherProvider? = null
selectedProvider.collectLatest { selectedProvider.collectLatest {
if (it != providerSetting) { if (it != providerSetting) {
providerSetting = it
provider = get { parametersOf(it) } provider = get { parametersOf(it) }
location.value = provider.getLocation() location.value = provider.getLocation()
lastLocation.value = provider.getLastLocation() lastLocation.value = provider.getLastLocation()
autoLocation.value = provider.autoLocation autoLocation.value = provider.autoLocation
// Force weather data update but only if provider has changed; not during
// initialization
if (providerSetting != null) {
provider.resetLastUpdate() provider.resetLastUpdate()
requestUpdate() requestUpdate()
} }
providerSetting = it
}
} }
} }
requestUpdate()
} }
private fun groupForecastsPerDay(forecasts: List<Forecast>): List<DailyForecast> { private fun groupForecastsPerDay(forecasts: List<Forecast>): List<DailyForecast> {