install logic improvement
- removed unnecessary command argument - reduced unnecessary install command call
This commit is contained in:
parent
10f91afa84
commit
9132a3c98c
3 changed files with 15 additions and 30 deletions
|
@ -19,13 +19,8 @@ use types::InstallErr;
|
|||
/// ## Arguments
|
||||
///
|
||||
/// * `game_path` - Absolute path to the game folder/directory.
|
||||
/// * `is_launch_option_set` - Whether if steam launch option is already set or not.
|
||||
#[tauri::command]
|
||||
pub async fn install(
|
||||
window: tauri::Window,
|
||||
game_path: String,
|
||||
is_launch_option_set: bool,
|
||||
) -> Result<(), InstallErr> {
|
||||
pub async fn install(window: tauri::Window, game_path: String) -> Result<(), InstallErr> {
|
||||
println!("install command called");
|
||||
|
||||
//
|
||||
|
@ -74,7 +69,7 @@ pub async fn install(
|
|||
//
|
||||
|
||||
match install_bepinex::install_bepinex(game_path).await {
|
||||
Ok(()) => {}
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
|
||||
|
@ -83,7 +78,7 @@ pub async fn install(
|
|||
//
|
||||
|
||||
match install_mod::install_wbm_mod(game_path).await {
|
||||
Ok(()) => {}
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
|
||||
|
@ -91,11 +86,9 @@ pub async fn install(
|
|||
// Set steam launch option if OS is linux or macOS
|
||||
//
|
||||
|
||||
if !is_launch_option_set {
|
||||
match launch_options::unix_launch_option_setup(&window, game_path).await {
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
match launch_options::unix_launch_option_setup(&window, game_path).await {
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -90,11 +90,11 @@
|
|||
|
||||
<button
|
||||
on:click|once={() => {
|
||||
install({ isLaunchOptionSet: true })
|
||||
lastInstallErr = undefined
|
||||
store.lastInstallErr.set(undefined)
|
||||
store.wasInstallSuccessful.set(true)
|
||||
}}
|
||||
>
|
||||
Done! Continue!
|
||||
Done!
|
||||
</button>
|
||||
{:else if lastInstallErr == InstallErr.FailedToSendLaunchOption}
|
||||
Failed to receive steam launch option data :(
|
||||
|
|
|
@ -11,31 +11,23 @@ function buttonClicked() {
|
|||
store.spinCog.set(true)
|
||||
}
|
||||
|
||||
interface InstallArgs {
|
||||
gamePath?: string
|
||||
isLaunchOptionSet?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the install command in the backend.
|
||||
*
|
||||
* @param {InstallArgs} gamePath - Absolute path to the game directory in the steam library. Leave it empty to use default location.
|
||||
* @param {string} gamePath - Absolute path to the game directory in the steam library. Leave it empty to use default location.
|
||||
*/
|
||||
export function install(args: InstallArgs = {}) {
|
||||
export function install(gamePath: string = "") {
|
||||
buttonClicked()
|
||||
|
||||
// get stored gamePath if it's empty
|
||||
if (!args.gamePath) {
|
||||
if (!gamePath) {
|
||||
store.gamePath.update((value) => {
|
||||
args.gamePath = value
|
||||
gamePath = value
|
||||
return value
|
||||
})
|
||||
}
|
||||
|
||||
invoke(COMMANDS.INSTALL, {
|
||||
gamePath: args.gamePath || "",
|
||||
isLaunchOptionSet: args.isLaunchOptionSet || false,
|
||||
})
|
||||
invoke(COMMANDS.INSTALL, { gamePath })
|
||||
.then(() => {
|
||||
store.wasInstallSuccessful.set(true)
|
||||
})
|
||||
|
@ -80,7 +72,7 @@ export function selectGamePathAndRun(type: "install" | "remove") {
|
|||
|
||||
switch (type) {
|
||||
case "install": {
|
||||
install({ gamePath: value })
|
||||
install(value)
|
||||
}
|
||||
|
||||
case "remove": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue