diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-03-12 15:55:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-12 14:55:36 +0000 |
commit | 82739f56b198054acbde53527e9eb39fa14f2602 (patch) | |
tree | 8a1601eada3846ae554ec56fb6feede2be792338 /src-tauri | |
parent | ac8c02a3860c2b079dc3f3806c3638563ac16d10 (diff) | |
download | FlightCore-82739f56b198054acbde53527e9eb39fa14f2602.tar.gz FlightCore-82739f56b198054acbde53527e9eb39fa14f2602.zip |
feat: Allow opening a window with various repair features (#129)
* feat: Initial code for spawning repair window
* refactor: Move disable all but core mods button
to repair window
* refactor: Rename function
* refactor: Move button location
Still in DeveloperView for now, will be moved to settings page later
* feat: Add info banner
* feat: Set repair window title
* fix: Stop thread crash on duplicate window open
Instead of calling an unwrap, handle failure to create window which is
usually caused by spawning a second repair window although one already
exists.
* fix: Re-add accidentally removed lines from merge
* fix: Set top padding to zero px
As there's no menu bar in this view
* feat: Close all windows when close bttn is clicked
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/src/main.rs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c7451763..50e439c8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -37,7 +37,7 @@ use northstar::get_northstar_version_number; mod thunderstore; use thunderstore::query_thunderstore_packages_api; -use tauri::Manager; +use tauri::{Manager, Runtime}; use tauri_plugin_store::PluginBuilder; use tokio::time::sleep; @@ -115,10 +115,12 @@ fn main() { delete_northstar_mod, get_server_player_count, delete_thunderstore_mod, + open_repair_window, query_thunderstore_packages_api, get_pull_requests_wrapper, apply_launcher_pr, apply_mods_pr, + close_application, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); @@ -355,3 +357,33 @@ async fn get_server_player_count() -> Result<(i32, usize), String> { Ok((total_player_count, server_count)) } + +#[tauri::command] +/// Spawns repair window +async fn open_repair_window(handle: tauri::AppHandle) -> Result<(), String> { + // Spawn new window + let repair_window = match tauri::WindowBuilder::new( + &handle, + "RepairWindow", + tauri::WindowUrl::App("/#/repair".into()), + ) + .build() + { + Ok(res) => res, + Err(err) => return Err(err.to_string()), + }; + + // Set window title + match repair_window.set_title("FlightCore Repair Window") { + Ok(()) => (), + Err(err) => return Err(err.to_string()), + }; + Ok(()) +} + +/// Closes all windows and exits application +#[tauri::command] +async fn close_application<R: Runtime>(app: tauri::AppHandle<R>) -> Result<(), String> { + app.exit(0); // Close application + Ok(()) +} |