aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/components
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-07-24 13:51:34 +0200
committerGitHub <noreply@github.com>2023-07-24 13:51:34 +0200
commit44583f739af9db81751655f7391757a28e949239 (patch)
treea381c8c968833c21a1277052a2d8b605b7ee69c1 /src-vue/src/components
parentdac7b0b18ab5a36d3a25154108e9acecc6c5fe93 (diff)
downloadFlightCore-44583f739af9db81751655f7391757a28e949239.tar.gz
FlightCore-44583f739af9db81751655f7391757a28e949239.zip
chore: Store `game_path` and `install_type` as `GameInstall` in store (#445)
We pass the `GameInstall` object to backend on most calls, yet we store the parameters individually in frontend. This PR resolves that by storing the whole object instead of individual parameters, simplifying a lot of the code that calls the backend. * chore: Store game_path and install_type as GameInstall in store * Add missed uses of old attributes * fix: Update missed attribute in DevView * fix: Update missed attribute in SettingsView * refactor: Update functions to use new object in RepairView * Initialize game_install as empty object --------- Co-authored-by: GeckoEidechse <gecko.eidechse+git@pm.me>
Diffstat (limited to 'src-vue/src/components')
-rw-r--r--src-vue/src/components/LocalModCard.vue15
-rw-r--r--src-vue/src/components/ThunderstoreModCard.vue15
2 files changed, 4 insertions, 26 deletions
diff --git a/src-vue/src/components/LocalModCard.vue b/src-vue/src/components/LocalModCard.vue
index dd3629f8..f8d0256d 100644
--- a/src-vue/src/components/LocalModCard.vue
+++ b/src-vue/src/components/LocalModCard.vue
@@ -30,7 +30,6 @@
import { defineComponent } from "vue";
import { invoke } from "@tauri-apps/api";
import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod";
-import { GameInstall } from "../utils/GameInstall";
import { showErrorNotification, showNotification } from "../utils/ui";
export default defineComponent({
@@ -50,16 +49,10 @@ export default defineComponent({
async updateWhichModsEnabled(mod: NorthstarMod) {
this.global_load_indicator = true;
- // Setup up struct
- let game_install = {
- game_path: this.$store.state.game_path,
- install_type: this.$store.state.install_type
- } as GameInstall;
-
// enable/disable specific mod
try {
await invoke("set_mod_enabled_status", {
- gameInstall: game_install,
+ gameInstall: this.$store.state.game_install,
modName: mod.name,
// Need to set it to the opposite of current state,
// as current state is only updated after command is run
@@ -76,11 +69,7 @@ export default defineComponent({
return true;
},
async deleteMod(mod: NorthstarMod) {
- let game_install = {
- game_path: this.$store.state.game_path,
- install_type: this.$store.state.install_type
- } as GameInstall;
- await invoke("delete_northstar_mod", { gameInstall: game_install, nsmodName: mod.name })
+ await invoke("delete_northstar_mod", { gameInstall: this.$store.state.game_install, nsmodName: mod.name })
.then((message) => {
// Just a visual indicator that it worked
showNotification(this.$t('mods.local.success_deleting', { modName: mod.name }));
diff --git a/src-vue/src/components/ThunderstoreModCard.vue b/src-vue/src/components/ThunderstoreModCard.vue
index 2fbbac40..30ffbc68 100644
--- a/src-vue/src/components/ThunderstoreModCard.vue
+++ b/src-vue/src/components/ThunderstoreModCard.vue
@@ -71,7 +71,6 @@ import { ThunderstoreModVersion } from "../../../src-tauri/bindings/Thunderstore
import { invoke, shell } from "@tauri-apps/api";
import { ThunderstoreModStatus } from "../utils/thunderstore/ThunderstoreModStatus";
import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod";
-import { GameInstall } from "../utils/GameInstall";
import { NorthstarState } from "../utils/NorthstarState";
import { ElMessageBox } from "element-plus";
import { showErrorNotification, showNotification } from "../utils/ui";
@@ -217,12 +216,7 @@ export default defineComponent({
}
)
.then(async () => { // Deletion confirmed
- let game_install = {
- game_path: this.$store.state.game_path,
- install_type: this.$store.state.install_type
- } as GameInstall;
-
- await invoke<string>("delete_thunderstore_mod", { gameInstall: game_install, thunderstoreModString: this.latestVersion.full_name })
+ await invoke<string>("delete_thunderstore_mod", { gameInstall: this.$store.state.game_install, thunderstoreModString: this.latestVersion.full_name })
.then((message) => {
showNotification(this.$t('mods.card.remove_success', { modName: mod.name }), message);
})
@@ -239,11 +233,6 @@ export default defineComponent({
},
async installMod(mod: ThunderstoreMod) {
- let game_install = {
- game_path: this.$store.state.game_path,
- install_type: this.$store.state.install_type
- } as GameInstall;
-
// set internal state according to current installation state
if (this.modStatus === ThunderstoreModStatus.OUTDATED) {
this.isBeingUpdated = true;
@@ -254,7 +243,7 @@ export default defineComponent({
// Capture translation method in a context, so it can be used outside Vue component context.
// (see https://github.com/R2NorthstarTools/FlightCore/issues/384)
(async (translate: Function) => {
- await invoke<string>("install_mod_caller", { gameInstall: game_install, thunderstoreModString: this.latestVersion.full_name }).then((message) => {
+ await invoke<string>("install_mod_caller", { gameInstall: this.$store.state.game_install, thunderstoreModString: this.latestVersion.full_name }).then((message) => {
showNotification(translate('mods.card.install_success', { modName: mod.name }), message);
})
.catch((error) => {