fix: crash on unavailable source api

the screen not updating because of errors
This commit is contained in:
2025-08-14 17:02:48 +02:00
parent 8284ae9695
commit f0344bd3ba
11 changed files with 336 additions and 96 deletions

View File

@@ -14,9 +14,15 @@ public class WeatherService(IWeatherClient weatherApi, IOptions<ApiConfiguration
{
private readonly ApiConfiguration _apiConfig = options.Value;
public Task<WeatherData> GetWeatherAsync(string lat, string lon)
public Task<WeatherData> GetWeatherAsync(string? lat, string? lon)
{
var location = $"{lat},{lon}";
if (string.IsNullOrEmpty(lat) || string.IsNullOrEmpty(lon))
{
location = _apiConfig.DefaultCity;
}
return weatherApi.GetForecastAsync(_apiConfig.Keys.Weather, location);
}
}