mirror of
https://github.com/mmvanheusden/SteamDepotDownloaderGUI.git
synced 2026-02-04 05:31:19 +01:00
feat: block app when downloading
This commit is contained in:
@@ -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<Mutex<PtyPair>>,
|
||||
@@ -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(())
|
||||
|
||||
@@ -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<string>("command-exited", () => {
|
||||
setLoadingState(false);
|
||||
});
|
||||
Reference in New Issue
Block a user