diff --git a/web/app.py b/web/app.py index a16a0bb..e8fdf42 100644 --- a/web/app.py +++ b/web/app.py @@ -98,10 +98,20 @@ def create_app(config, screens: dict, scheduler) -> Flask: scheduler.invalidate_screen("weather") return redirect(url_for("settings_weather", saved=1)) else: + # The city text field isn't pre-filled (unlike the manual + # lat/lon fields below it), so it's blank on every + # settings-only save -- toggles, forecast_days, etc. Only + # clear the resolved city label when the coordinates + # actually changed; otherwise this would silently wipe the + # city on every save even though lat/lon round-trip fine. + current = config.get_screen_settings("weather") + new_lat = float(lat_raw) if lat_raw else None + new_lon = float(lon_raw) if lon_raw else None + coords_unchanged = new_lat == current.get("latitude") and new_lon == current.get("longitude") config.update_screen_settings("weather", { - "city": "", - "latitude": float(lat_raw) if lat_raw else None, - "longitude": float(lon_raw) if lon_raw else None, + "city": current.get("city", "") if coords_unchanged else "", + "latitude": new_lat, + "longitude": new_lon, "forecast_days": forecast_days, "update_minutes": update_minutes, **display_toggles,