diff --git a/pages/store/index.vue b/pages/store/index.vue
index 4f349bf..77edfa8 100644
--- a/pages/store/index.vue
+++ b/pages/store/index.vue
@@ -7,41 +7,34 @@
+
+
+
+
+
-
-
@@ -50,6 +43,7 @@ import { invoke } from "@tauri-apps/api/core";
const gameId = ref("");
const versionName = ref("");
+const status = ref("");
async function queueGame() {
await invoke("queue_game_download", {
@@ -79,13 +73,9 @@ function startGameDownloadsWrapper() {
console.log(e)
})
}
-async function cancelGameDownload() {
- console.log("Cancelling game download");
- await invoke("cancel_specific_game_download", { gameId: gameId.value })
-}
function cancelGameDownloadWrapper() {
console.log("Triggered game cancel wrapper");
- cancelGameDownload()
+ setGameDownloadStatus("Cancelled")
.then(() => {})
.catch((e) => {
console.log(e)
@@ -101,37 +91,26 @@ function getGameDownloadProgressWrapper() {
.catch((e) => {
console.log(e)
})
+}
+/* status can be any of the following values:
+ Uninitialised,
+ Queued,
+ Paused,
+ Manifest,
+ Downloading,
+ Finished,
+ Stalled,
+ Failed,
+ Cancelled,
+*/
-}
-async function pauseGameDownload() {
- console.log("Getting game download status");
- await invoke("pause_game_download", { gameId: gameId.value })
-}
-function pauseGameDownloadWrapper() {
- pauseGameDownload()
- .then(() => {})
- .catch((e) => {
- console.log(e)
- })
-
-}
-async function resumeGameDownload() {
- console.log("Getting game download status");
- await invoke("resume_game_download", { gameId: gameId.value })
-}
-function resumeGameDownloadWrapper() {
- resumeGameDownload()
- .then(() => {})
- .catch((e) => {
- console.log(e)
- })
-}
-async function setGameDownload() {
+async function setGameDownloadStatus(status: string) {
console.log("Setting game download status");
- await invoke("set_download_state", { gameId: gameId.value, status: "Paused" })
+ await invoke("set_download_state", { gameId: gameId.value, status: status })
}
-function setGameDownloadWrapper() {
- setGameDownload()
+function setGameDownloadStatusWrapper() {
+ console.log("Called setGameDownloadWrapper");
+ setGameDownloadStatus(status.value)
.then(() => {})
.catch((e) => {
console.log(e)
diff --git a/src-tauri/src/downloads/download_commands.rs b/src-tauri/src/downloads/download_commands.rs
index 24131ea..9109842 100644
--- a/src-tauri/src/downloads/download_commands.rs
+++ b/src-tauri/src/downloads/download_commands.rs
@@ -116,33 +116,14 @@ pub async fn get_game_download_progress(
Ok(progress)
}
-#[tauri::command]
-pub async fn pause_game_download(
- state: tauri::State<'_, Mutex>,
- game_id: String,
-) -> Result<(), String> {
- get_game_download(state, game_id).change_state(GameDownloadState::Paused);
-
- Ok(())
-}
-
-#[tauri::command]
-pub async fn resume_game_download(
- state: tauri::State<'_, Mutex>,
- game_id: String,
-) -> Result<(), String> {
- get_game_download(state, game_id).change_state(GameDownloadState::Downloading);
-
- Ok(())
-}
#[tauri::command]
pub async fn set_download_state(
state: tauri::State<'_, Mutex>,
game_id: String,
status: GameDownloadState
) -> Result<(), String> {
+ info!("Setting game state");
get_game_download(state, game_id).change_state(status);
-
Ok(())
}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 3158e2e..e8a9c2c 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -124,8 +124,6 @@ pub fn run() {
start_game_downloads,
cancel_specific_game_download,
get_game_download_progress,
- resume_game_download,
- pause_game_download,
set_download_state
])
.plugin(tauri_plugin_shell::init())