Lesson learned: Wrappers are the bane of my existence. Also here's the download cancelling logic.

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2024-10-31 20:56:10 +11:00
parent 01ce253bda
commit 13df631cc6
5 changed files with 98 additions and 57 deletions

View File

@ -9,10 +9,16 @@
<input placeholder="VERSION NAME" v-model="versionName" />
<button
class="w-full rounded-md p-4 bg-blue-600 text-white"
@click="startGameDownloads"
@click="startGameDownloadsWrapper"
>
Start Game Downloads
</button>
<button
class="w-full rounded-md p-4 bg-blue-600 text-white"
@click="cancelGameDownloadWrapper"
>
Cancel game download
</button>
</template>
<script setup lang="ts">
import { invoke } from "@tauri-apps/api/core";
@ -39,6 +45,7 @@ function queueGameWrapper() {
async function startGameDownloads() {
console.log("Downloading Games");
await invoke("start_game_downloads", { maxThreads: 4 })
console.log("Finished downloading games");
}
function startGameDownloadsWrapper() {
startGameDownloads()
@ -47,4 +54,16 @@ function startGameDownloadsWrapper() {
console.log(e)
})
}
async function cancelGameDownload() {
console.log("Cancelling game download");
await invoke("stop_specific_game_download", { gameId: gameId.value })
}
function cancelGameDownloadWrapper() {
console.log("Triggered game cancel wrapper");
cancelGameDownload()
.then(() => {})
.catch((e) => {
console.log(e)
})
}
</script>