commit 521aa31cf695b208fb6929eddf6609318ff4dcf9 parent d1be5bb3c03305748a5d5ecc12a78f35eb9c10c6 Author: Sylvia Ivory <git@sivory.net> Date: Thu, 19 Jun 2025 17:13:11 -0700 Prevent saving settings without valid coordinates Diffstat:
| M | src/settings.rs | | | 20 | ++++++++++++++------ |
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/settings.rs b/src/settings.rs @@ -259,18 +259,26 @@ impl Settings { text_input::default }; - let latitude_style = if self.latitude.parse::<f64>().is_ok() || latitude.is_none() { - text_input::default - } else { + let latitude_style = if self.latitude.parse::<f64>().is_err() + && matches!( + self.location, + WeatherLocation::LocationName | WeatherLocation::Coordinates + ) { save_message = None; text_input_error + } else { + text_input::default }; - let longitude_style = if self.longitude.parse::<f64>().is_ok() || longitude.is_none() { - text_input::default - } else { + let longitude_style = if self.longitude.parse::<f64>().is_err() + && matches!( + self.location, + WeatherLocation::LocationName | WeatherLocation::Coordinates + ) { save_message = None; text_input_error + } else { + text_input::default }; let mut background_mode_row =