Weather widget: add warning if selected providerr is unavailable

This commit is contained in:
MM20
2024-06-30 15:19:09 +02:00
parent e96a382b00
commit 845a11b54b
6 changed files with 98 additions and 18 deletions
@@ -27,6 +27,7 @@ import java.util.*
import kotlin.time.Duration.Companion.minutes
interface WeatherRepository {
fun getActiveProvider(): Flow<WeatherProviderInfo?>
fun getProviders(): Flow<List<WeatherProviderInfo>>
fun searchLocations(query: String): Flow<List<WeatherLocation>>
@@ -147,6 +148,14 @@ internal class WeatherRepositoryImpl(
}
}
override fun getActiveProvider(): Flow<WeatherProviderInfo?> {
return settings.providerId.flatMapLatest { id ->
getProviders().map {
it.find { it.id == id }
}
}
}
override fun getProviders(): Flow<List<WeatherProviderInfo>> {
val providers = mutableListOf<WeatherProviderInfo>()
providers.add(