From 420e41ced58f40a4c4ff07ab53b322ce8e6c0636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4ki?= Date: Thu, 7 Mar 2024 10:26:53 +0200 Subject: [PATCH] Delegate enabling all mods to Vuex from settings view This cleans up the Manager component and speeds up feature since the old implementation updated the mod list after each mod was enabled, whereas the new one does it only once at the end. --- src/pages/Manager.vue | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/src/pages/Manager.vue b/src/pages/Manager.vue index ab2c9e3c..27934dec 100644 --- a/src/pages/Manager.vue +++ b/src/pages/Manager.vue @@ -144,7 +144,6 @@ import { Hero, Link, Modal, Progress } from '../components/all'; import ThunderstoreMod from '../model/ThunderstoreMod'; import ThunderstoreCombo from '../model/ThunderstoreCombo'; import ProfileModList from '../r2mm/mods/ProfileModList'; -import ProfileInstallerProvider from '../providers/ror2/installing/ProfileInstallerProvider'; import PathResolver from '../r2mm/manager/PathResolver'; import PreloaderFixer from '../r2mm/manager/PreloaderFixer'; @@ -481,38 +480,6 @@ import CategoryFilterModal from '../components/modals/CategoryFilterModal.vue'; } } - async setAllModsEnabled() { - let lastSuccessfulUpdate: ManifestV2[] = []; - - try { - for (const mod of this.localModList) { - if (mod.isEnabled()) { - continue; - } - - const profileErr = await ProfileInstallerProvider.instance.enableMod(mod, this.contextProfile!); - if (profileErr instanceof R2Error) { - this.$store.commit('error/handleError', profileErr); - continue; - } - const update = await ProfileModList.updateMod(mod, this.contextProfile!, async (mod) => mod.enable()); - if (update instanceof R2Error) { - this.$store.commit('error/handleError', update); - } else { - lastSuccessfulUpdate = update; - } - } - } catch (e) { - this.$store.commit('error/handleError', R2Error.fromThrownValue(e, "Error enabling mods")); - } finally { - if (lastSuccessfulUpdate.length) { - await this.$store.dispatch('profile/updateModList', lastSuccessfulUpdate); - } - } - - await this.$router.push({name: "manager.installed"}); - } - changeDataFolder() { const fs = FsProvider.instance; const dir: string = PathResolver.ROOT; @@ -598,7 +565,11 @@ import CategoryFilterModal from '../components/modals/CategoryFilterModal.vue'; this.settings = (() => this.settings)(); break; case "EnableAll": - await this.setAllModsEnabled(); + await this.$store.dispatch( + "profile/enableModsOnActiveProfile", + {mods: this.localModList} + ); + await this.$router.push({name: "manager.installed"}); break; case "DisableAll": await this.$store.dispatch(