Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
populate and save general store on startup
Brendan Allanaa2b02b6ebe3
diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rsindex b59397129..8e615db6c 100644--- a/apps/desktop/src-tauri/src/general_settings.rs+++ b/apps/desktop/src-tauri/src/general_settings.rs@@ -79,8 +79,8 @@ fn true_b() -> bool {impl GeneralSettingsStore {pub fn get(app: &AppHandle<Wry>) -> Result<Option<Self>, String> {- match app.get_store("store").map(|s| s.get("general_settings")) {- Some(Some(store)) => {+ match app.store("store").map(|s| s.get("general_settings")) {+ Ok(Some(store)) => {// Handle potential deserialization errors gracefullymatch serde_json::from_value(store) {Ok(settings) => Ok(Some(settings)),@@ -93,7 +93,7 @@ impl GeneralSettingsStore {// i don't trust anyone to not overwrite the whole store lolspub fn update(app: &AppHandle, update: impl FnOnce(&mut Self)) -> Result<(), String> {- let Some(store) = app.get_store("store") else {+ let Ok(store) = app.store("store") else {return Err("Store not found".to_string());};@@ -102,16 +102,30 @@ impl GeneralSettingsStore {store.set("general_settings", json!(settings));store.save().map_err(|e| e.to_string())}-}-pub type GeneralSettingsState = Mutex<GeneralSettingsStore>;+ fn save(&self, app: &AppHandle) -> Result<(), String> {+ let Ok(store) = app.store("store") else {+ return Err("Store not found".to_string());+ };++ store.set("general_settings", json!(self));+ store.save().map_err(|e| e.to_string())+ }+}pub fn init(app: &AppHandle) {println!("Initializing GeneralSettingsStore");- // Use unwrap_or_default() to handle potential errors gracefully- let store = GeneralSettingsStore::get(app)- .unwrap_or(None)- .unwrap_or_default();- app.manage(GeneralSettingsState::new(store));++ let store = match GeneralSettingsStore::get(app) {+ Ok(Some(store)) => store,+ Ok(None) => GeneralSettingsStore::default(),+ e => {+ e.unwrap();+ return;+ }+ };++ store.save(app).unwrap();+println!("GeneralSettingsState managed");}