From 30b19761d66c6be28a4e28780fb941b4854aa817 Mon Sep 17 00:00:00 2001 From: Maarten <50550545+mmvanheusden@users.noreply.github.com> Date: Sun, 1 Feb 2026 15:44:33 +0100 Subject: [PATCH] feat: block app when downloading --- src-tauri/src/main.rs | 5 +++-- src/ts/main.ts | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e283aa68..1fb4a2c8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -15,7 +15,7 @@ use std::sync::{Arc, OnceLock}; use std::time::Duration; use std::{env, thread}; use tauri::async_runtime::Mutex; -use tauri::{AppHandle, Manager, State}; +use tauri::{AppHandle, Emitter, Manager, State}; struct AppState { pty_pair: Arc>, @@ -38,7 +38,7 @@ async fn preload_vectum(app: AppHandle) { } #[tauri::command] -async fn start_download(steam_download: steam::SteamDownload, state: State<'_, AppState>) -> Result<(), String> { +async fn start_download(steam_download: steam::SteamDownload, app: AppHandle, state: State<'_, AppState>) -> Result<(), String> { // Also change working directory // std::env::set_current_dir(&WORKING_DIR.get().unwrap()).unwrap(); @@ -73,6 +73,7 @@ async fn start_download(steam_download: steam::SteamDownload, state: State<'_, A thread::spawn(move || { let status = child.wait().unwrap(); println!("Command exited with status: {status}"); + app.emit("command-exited", {}).unwrap(); // exit(status.exit_code() as i32) }); Ok(()) diff --git a/src/ts/main.ts b/src/ts/main.ts index f4487510..da07a91b 100644 --- a/src/ts/main.ts +++ b/src/ts/main.ts @@ -5,6 +5,7 @@ import {openPath, openUrl} from '@tauri-apps/plugin-opener'; import "@xterm/xterm/css/xterm.css"; import {Terminal} from "@xterm/xterm"; import { FitAddon } from '@xterm/addon-fit'; +import { listen } from "@tauri-apps/api/event"; function setLoader(state: boolean) { $("#busy").prop("hidden", !state); @@ -193,6 +194,7 @@ $(async () => { console.debug("DepotDownloader download process completed. Starting game download..."); + setLoadingState(true); await invoke("start_download", {steamDownload: steamDownload}); console.log("Send frontend data over to backend. Ready for next download."); }); @@ -223,4 +225,9 @@ $(async () => { $("#downloadbtn").prop("ariaDisabled", false); } }); +}); + + +listen("command-exited", () => { + setLoadingState(false); }); \ No newline at end of file