From 3b4b528b2f04ce2f43ef6fd20075af2537a10a73 Mon Sep 17 00:00:00 2001 From: Philip Kristoffersen Date: Sun, 22 May 2022 15:08:16 +0200 Subject: [PATCH] Steamline how auth_key input is assigned (#147) --- src/ui/ui_settings.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ui/ui_settings.rs b/src/ui/ui_settings.rs index 69e7609..c0604ae 100644 --- a/src/ui/ui_settings.rs +++ b/src/ui/ui_settings.rs @@ -179,16 +179,19 @@ impl MyEguiApp { ui.checkbox(&mut self.settings.steamgrid_db.enabled, "Download images"); if self.settings.steamgrid_db.enabled { ui.horizontal(|ui| { - let mut empty_string = "".to_string(); - let auth_key = self + let mut auth_key = self .settings .steamgrid_db .auth_key - .as_mut() - .unwrap_or(&mut empty_string); + .clone() + .unwrap_or_default(); ui.label("Authentication key: "); - if ui.text_edit_singleline(auth_key).changed() { - *auth_key = auth_key.to_string(); + if ui.text_edit_singleline(&mut auth_key).changed() { + if auth_key.is_empty(){ + self.settings.steamgrid_db.auth_key = None; + }else{ + self.settings.steamgrid_db.auth_key = Some(auth_key.to_string()); + } } if auth_key.is_empty() { if ui.button("Paste from clipboard").clicked() {