From d8c220f0de759eb209b35567faf1618b77ea9ba6 Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Fri, 3 Jan 2025 01:54:00 +0100 Subject: [PATCH] feat: Re-implement opening repair window --- src-tauri/src/lib.rs | 1 + src-tauri/src/util.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index e55b610c9..3fe93da32 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -29,6 +29,7 @@ pub fn run() { util::get_flightcore_version_number, util::get_server_player_count, util::is_debug_mode, + util::open_repair_window, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index 9cd57a213..a9387c361 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -36,6 +36,29 @@ pub async fn get_flightcore_version_number() -> String { } } +/// Spawns repair window +#[tauri::command] +pub async fn open_repair_window(handle: tauri::AppHandle) -> Result<(), String> { + // Spawn new window + let repair_window = match tauri::WebviewWindowBuilder::new( + &handle, + "RepairWindow", + tauri::WebviewUrl::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(()) +} + /// Fetches `/client/servers` endpoint from master server async fn fetch_server_list() -> Result { let url = format!("{MASTER_SERVER_URL}{SERVER_BROWSER_ENDPOINT}");