feat: added whitespaces removing from environment values

One user somehow got it in game running command. Have no idea
how could it happend but just in case added `trim()` calls
This commit is contained in:
Observer KRypt0n_ 2023-04-09 18:03:46 +02:00
parent f777963548
commit 13fd1ebb4f
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -91,11 +91,11 @@ impl SimpleAsyncComponent for EnvironmentApp {
adw::EntryRow {
set_title: "%command%",
set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()),
set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()).trim(),
connect_changed => |entry| {
if let Ok(mut config) = config::get() {
let command = entry.text().to_string();
let command = entry.text().trim().to_string();
config.game.command = if command.is_empty() {
None
@ -158,7 +158,7 @@ impl SimpleAsyncComponent for EnvironmentApp {
};
for (name, value) in &CONFIG.game.environment {
model.variables.guard().push_back((name.clone(), value.clone()));
model.variables.guard().push_back((name.trim().to_string(), value.trim().to_string()));
}
let variables = model.variables.widget();
@ -175,8 +175,8 @@ impl SimpleAsyncComponent for EnvironmentApp {
match msg {
EnvironmentMsg::Add => {
if let Ok(mut config) = config::get() {
let name = self.name.text().to_string();
let value = self.value.text().to_string();
let name = self.name.text().trim().to_string();
let value = self.value.text().trim().to_string();
config.game.environment.insert(name.clone(), value.clone());