Skip to content

Commit

Permalink
added window state restore
Browse files Browse the repository at this point in the history
  • Loading branch information
0PandaDEV committed May 9, 2024
1 parent 91ebd5f commit 46653ac
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
if: matrix.platform == 'macos-latest'
uses: actions/upload-artifact@v3
with:
name: macos-signature-archives
name: updater-files-macos
path: |
src-tauri/target/release/bundle/macos/*.tar.gz
src-tauri/target/release/bundle/macos/*.tar.gz.sig
Expand All @@ -68,7 +68,7 @@ jobs:
if: matrix.platform == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: windows-signature-archives
name: updater-files-windows
path: |
src-tauri/target/release/bundle/msi/*.zip
src-tauri/target/release/bundle/msi/*.zip.sig
Expand All @@ -94,7 +94,7 @@ jobs:
if: matrix.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: ubuntu-signature-archives
name: updater-files-ubuntu
path: |
src-tauri/target/release/bundle/appimage/*.tar.gz
src-tauri/target/release/bundle/appimage/*.tar.gz.sig
16 changes: 16 additions & 0 deletions src-tauri/Cargo.lock

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

8 changes: 2 additions & 6 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ tauri-plugin-os = "2.0.0-beta"
tauri-plugin-fs = "2.0.0-beta"
tauri-plugin-dialog = "2.0.0-beta"
tauri-plugin-updater = "2.0.0-beta"
tauri-plugin-global-shortcut = "2.0.0-beta"
tauri-plugin-window-state = "2.0.0-beta"
serde_json = "1.0"
lazy_static = "1.4"
tokio = { version = "1", features = ["full"] }
Expand All @@ -32,9 +34,3 @@ rusty_ytdl = "0.7.1"
# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes.
# DO NOT REMOVE!!
custom-protocol = [ "tauri/custom-protocol" ]

[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-global-shortcut = "2.0.0-beta.3"

# [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
# tauri-plugin-window-state = "0.1.0"
4 changes: 3 additions & 1 deletion src-tauri/capabilities/migrated.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
"fs:default",
"global-shortcut:allow-is-registered",
"global-shortcut:allow-register",
"global-shortcut:allow-unregister"
"global-shortcut:allow-unregister",
"window-state:allow-restore-state",
"window-state:allow-save-window-state"
],
"platforms": [
"linux",
Expand Down
12 changes: 10 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
mod commands;
mod discord_rpc;

use tauri::Manager;
use tauri_plugin_window_state::{Builder, StateFlags};

fn main() {
env_logger::init();
let _ = discord_rpc::connect_rpc();

tauri::Builder::default()
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
.plugin(Builder::new()
.with_state_flags(StateFlags::all())
.build())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_dialog::init())
Expand All @@ -25,9 +30,12 @@ fn main() {
.setup(|app| {
tauri::async_runtime::block_on(async {
let _ = commands::check_for_updates(app.handle().clone()).await;
if let Some(window) = app.get_webview_window("main") {
let _ = window.restore_state(StateFlags::all());
}
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
}

0 comments on commit 46653ac

Please sign in to comment.