diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-10-13 13:21:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-13 13:21:06 +0200 |
commit | b3b558dbab5ac41a64f36d36aac81f0b996101b0 (patch) | |
tree | 985666659cb5d3e8a14012ce07b07eafdf2f5ce5 /src-tauri/src/main.rs | |
parent | 97d4773d5ee55cf6a9081475f2bc3011b23e1037 (diff) | |
download | FlightCore-b3b558dbab5ac41a64f36d36aac81f0b996101b0.tar.gz FlightCore-b3b558dbab5ac41a64f36d36aac81f0b996101b0.zip |
refactor: Move relevant functions to util module (#623)
* refactor: Move to `get_flightcore_version_number` to util module
* refactor: Move to `open_repair_window` to util mod
* refactor: Move to `close_application` to util mod
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r-- | src-tauri/src/main.rs | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 93f67a33..8d6ea769 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize}; use tauri::api::dialog::blocking::MessageDialogBuilder; #[cfg(target_os = "windows")] use tauri::api::dialog::{MessageDialogButtons, MessageDialogKind}; -use tauri::{Manager, Runtime}; +use tauri::Manager; use tokio::time::sleep; use ts_rs::TS; @@ -119,7 +119,7 @@ fn main() { .invoke_handler(tauri::generate_handler![ util::force_panic, northstar::install::find_game_install_location, - get_flightcore_version_number, + util::get_flightcore_version_number, northstar::get_northstar_version_number, check_is_northstar_outdated, repair_and_verify::verify_install_location, @@ -147,7 +147,7 @@ fn main() { platform_specific::install_northstar_proton_wrapper, platform_specific::uninstall_northstar_proton_wrapper, platform_specific::get_local_northstar_proton_wrapper_version, - open_repair_window, + util::open_repair_window, thunderstore::query_thunderstore_packages_api, github::get_list_of_tags, github::compare_tags, @@ -155,7 +155,7 @@ fn main() { github::pull_requests::apply_launcher_pr, github::pull_requests::apply_mods_pr, github::pull_requests::get_launcher_download_link, - close_application, + util::close_application, development::install_git_main, get_available_northstar_versions, northstar::profile::fetch_profiles, @@ -194,19 +194,6 @@ fn main() { }; } -/// Returns the current version number as a string -#[tauri::command] -async fn get_flightcore_version_number() -> String { - let version = env!("CARGO_PKG_VERSION"); - if cfg!(debug_assertions) { - // Debugging enabled - format!("v{} (debug mode)", version) - } else { - // Debugging disabled - format!("v{}", version) - } -} - /// Helps with converting release candidate numbers which are different on Thunderstore /// due to restrictions imposed by the platform pub fn convert_release_candidate_number(version_number: String) -> String { @@ -303,36 +290,6 @@ async fn clean_up_download_folder_wrapper( } } -/// Spawns repair window -#[tauri::command] -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(()) -} - /// Gets list of available Northstar versions from Thunderstore #[tauri::command] async fn get_available_northstar_versions() -> Result<Vec<NorthstarThunderstoreReleaseWrapper>, ()> |