mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 00:02:41 +10:00
feat(downloads): Generic function to set download state
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -37,6 +37,13 @@
|
|||||||
>
|
>
|
||||||
Resume game download
|
Resume game download
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class="w-full rounded-md p-4 bg-blue-600 text-white"
|
||||||
|
@click="setGameDownloadWrapper"
|
||||||
|
>
|
||||||
|
Set game download
|
||||||
|
</button>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
@ -118,6 +125,16 @@ function resumeGameDownloadWrapper() {
|
|||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
async function setGameDownload() {
|
||||||
|
console.log("Setting game download status");
|
||||||
|
await invoke("set_download_state", { gameId: gameId.value, status: "Paused" })
|
||||||
|
}
|
||||||
|
function setGameDownloadWrapper() {
|
||||||
|
setGameDownload()
|
||||||
|
.then(() => {})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -135,6 +135,16 @@ pub async fn resume_game_download(
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn set_download_state(
|
||||||
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
|
game_id: String,
|
||||||
|
status: GameDownloadState
|
||||||
|
) -> Result<(), String> {
|
||||||
|
get_game_download(state, game_id).change_state(status);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn get_game_download(
|
fn get_game_download(
|
||||||
state: tauri::State<'_, Mutex<AppState>>,
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
|
|||||||
@ -12,7 +12,6 @@ use std::{
|
|||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
thread::sleep,
|
thread::sleep,
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
use urlencoding::encode;
|
use urlencoding::encode;
|
||||||
|
|
||||||
|
|||||||
@ -125,7 +125,8 @@ pub fn run() {
|
|||||||
cancel_specific_game_download,
|
cancel_specific_game_download,
|
||||||
get_game_download_progress,
|
get_game_download_progress,
|
||||||
resume_game_download,
|
resume_game_download,
|
||||||
pause_game_download
|
pause_game_download,
|
||||||
|
set_download_state
|
||||||
])
|
])
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
|
|||||||
Reference in New Issue
Block a user