mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-22 02:52:37 -05:00
Fix alerts-only country-recommended sources leaking into weather picker
WeatherSourcesForLocationSheet's recommendedSources list wasn't filtered by Capability.WEATHER (unlike its globalSources list), so an alerts-only source recommended for a country could appear, and even get auto-selected, as a weather source. Every country's recommended source has so far also been a weather source, so this never surfaced until an alerts-only country-recommended source existed. Also make new-location alert-source selection fall back to the country's recommended alerts source when the chosen weather source isn't itself alerts-capable, instead of only pairing alerts when the weather source happens to be self-paired.
This commit is contained in:
1 parent
effa4f4a48
commit
ee3db85233
2 files changed
+5
-1
No files matched your search
+4
-1
@@ -9,6 +9,7 @@ import androidx.lifecycle.viewModelScope
|
||||
import com.pranshulgg.weather_master_app.R
|
||||
import com.pranshulgg.weather_master_app.core.model.sources.Capability
|
||||
import com.pranshulgg.weather_master_app.core.model.sources.SearchSource
|
||||
import com.pranshulgg.weather_master_app.core.model.sources.getSourcesForCountry
|
||||
import com.pranshulgg.weather_master_app.core.model.domain.location.Location
|
||||
import com.pranshulgg.weather_master_app.core.model.domain.toAppException
|
||||
import com.pranshulgg.weather_master_app.core.model.domain.toMessageRes
|
||||
@@ -84,7 +85,9 @@ class SearchScreenViewModel @Inject constructor(
|
||||
val alertSource = if (Capability.ALERTS in weatherSource.capabilities) {
|
||||
weatherSource
|
||||
} else {
|
||||
resolved.alertSource
|
||||
getSourcesForCountry(resolved.countryCode?.uppercase())
|
||||
.firstOrNull { Capability.ALERTS in it.capabilities }
|
||||
?: resolved.alertSource
|
||||
}
|
||||
locationsRepo.saveLocation(resolved.copy(source = weatherSource, alertSource = alertSource))
|
||||
onBack()
|
||||
|
||||
+1
@@ -55,6 +55,7 @@ object SharedBottomSheet {
|
||||
) {
|
||||
if (show) {
|
||||
val recommendedSources = getSourcesForCountry(countryCode?.uppercase())
|
||||
.filter { Capability.WEATHER in it.capabilities }
|
||||
val globalSources = getSourcesGlobal().filter { Capability.WEATHER in it.capabilities }
|
||||
|
||||
val isApiKeyAvailable: (Source) -> Boolean = { source ->
|
||||
|
||||
Reference in new issue
Block a user