From 82739f56b198054acbde53527e9eb39fa14f2602 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Sun, 12 Mar 2023 15:55:36 +0100 Subject: 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 --- src-tauri/src/main.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src-tauri/src') 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(app: tauri::AppHandle) -> Result<(), String> { + app.exit(0); // Close application + Ok(()) +} -- cgit v1.2.3