Skip to content

Commit

Permalink
feat: add window state persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelint committed Jul 2, 2024
1 parent 4ffd0c1 commit c43cef1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
26 changes: 25 additions & 1 deletion webapp/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webapp/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dirs = "5.0"
log = "^0.4"
tracing = "0.1"
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.6.8", features = [ "api-all", "process-command-api"] }

Expand Down
5 changes: 5 additions & 0 deletions webapp/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod sidecar_lifecycle_service;
use std::sync::Mutex;
use tauri_plugin_log::LogTarget;
use tauri::{Manager, State, WindowEvent};
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
use sidecar_lifecycle_service::SidecarLifeCycleService;

struct AppState {
Expand Down Expand Up @@ -49,6 +50,7 @@ fn main() {
tauri::Builder::default()
.manage(state)
.plugin(log_builder.build())
.plugin(tauri_plugin_window_state::Builder::default().build())
.setup(move |app| {
let app_state: State<AppState> = app.state();
app_state.code_sidecar_mutex
Expand All @@ -66,6 +68,9 @@ fn main() {
.unwrap()
.stop()
.expect("Core Sidecar stop failed");

let app_handle: tauri::AppHandle = event.window().app_handle();
app_handle.save_window_state(StateFlags::all()).ok();
}
_ => {}
})
Expand Down

0 comments on commit c43cef1

Please sign in to comment.