asdf98 commited on
Commit
2940ebf
·
verified ·
1 Parent(s): c0f31a5

Fix lib.rs state lifetime in setup zoom memory load

Browse files
Files changed (1) hide show
  1. src-tauri/src/lib.rs +4 -2
src-tauri/src/lib.rs CHANGED
@@ -98,9 +98,11 @@ pub fn run() {
98
  #[cfg(desktop)]
99
  app.handle().plugin(tauri_plugin_global_shortcut::Builder::new().build())?;
100
 
 
101
  if let Ok(zoom_mem) = crate::persistence::load_json::<std::collections::HashMap<String, f64>>(app.handle(), "zoom_memory.json") {
102
- let state = app.state::<AppState>();
103
- if let Ok(mut tabs) = state.tabs.lock() {
 
104
  tabs.zoom_memory = zoom_mem;
105
  }
106
  }
 
98
  #[cfg(desktop)]
99
  app.handle().plugin(tauri_plugin_global_shortcut::Builder::new().build())?;
100
 
101
+ // Load zoom memory from disk
102
  if let Ok(zoom_mem) = crate::persistence::load_json::<std::collections::HashMap<String, f64>>(app.handle(), "zoom_memory.json") {
103
+ if !zoom_mem.is_empty() {
104
+ let app_state = app.state::<AppState>();
105
+ let mut tabs = app_state.tabs.lock().expect("tabs lock");
106
  tabs.zoom_memory = zoom_mem;
107
  }
108
  }