ensure persistent_state is easier and more infallible to add fields to

This commit is contained in:
2025-11-06 23:55:04 +00:00
parent f07421e75a
commit c34cf187d5
3 changed files with 18 additions and 5 deletions
+16 -1
View File
@@ -1,4 +1,8 @@
use crate::{features::launch::Platform, gui::settings::Settings, util::consts::path};
use crate::{
features::launch::Platform,
gui::{app, settings::Settings},
util::consts::path,
};
use serde::{Deserialize, Serialize};
use std::{
fs::{self, File},
@@ -24,4 +28,15 @@ impl PersistentState {
let json = serde_json::to_string_pretty(&self).unwrap();
config_file.write_all(json.as_bytes()).unwrap();
}
pub fn apply_to(self, app: &mut app::App) {
let Self {
launcher,
anti_afk_enabled,
settings,
} = self;
app.launch.selected = launcher;
app.anti_afk.enabled = anti_afk_enabled;
app.settings = settings;
}
}