diff options
-rw-r--r-- | src-tauri/src/main.rs | 16 | ||||
-rw-r--r-- | src-ui/src/main.ts | 12 |
2 files changed, 7 insertions, 21 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7fd7bf2e..79386ca6 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -36,20 +36,6 @@ fn main() { } }); - let app_handle = app.app_handle(); - tauri::async_runtime::spawn(async move { - // Checking install location inside a timed loop is a bad idea - // If the user has the game on a harddrive for example, it will prevent the harddrive from ever spinning down - // Instead, install location checks should be event based. - loop { - sleep(Duration::from_millis(5000)).await; - println!("sending install location"); - app_handle - .emit_all("install-location-result", find_game_install_location()) - .unwrap(); - } - }); - Ok(()) }) .manage(Counter(Default::default())) @@ -57,12 +43,14 @@ fn main() { hello_world, add_count, force_panic, + find_game_install_location, get_version_number ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } +#[tauri::command] fn find_game_install_location() -> String { // Attempt parsing Steam library directly match steamlocate::SteamDir::locate() { diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts index e769a1b5..e5149bdd 100644 --- a/src-ui/src/main.ts +++ b/src-ui/src/main.ts @@ -14,13 +14,6 @@ document.addEventListener("DOMContentLoaded", async function () { let versionNumberHolderEl = $("version-number-holder") as HTMLElement; // listen backend-ping event (from Tauri Rust App) - listen("install-location-result", function (evt: TauriEvent<string>) { - // alert(evt.payload); - // result = evt as String; - installLocationHolderEl.textContent = evt.payload; - }) - - // listen backend-ping event (from Tauri Rust App) listen("backend-ping", function (evt: TauriEvent<any>) { pingEl.classList.add("on"); setTimeout(function () { @@ -50,6 +43,11 @@ document.addEventListener("DOMContentLoaded", async function () { }); // Run the following on initial page load + // Get version number let version_number_string = await invoke("get_version_number") as string; versionNumberHolderEl.textContent = version_number_string; + + // Get install location + let install_location = await invoke("find_game_install_location") as string; + installLocationHolderEl.textContent = install_location; }) |