From bcbde741d5fa047d0652769f3b0ab34e4e55bf54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4ki?= Date: Tue, 30 Jan 2024 17:03:11 +0200 Subject: [PATCH] Improve performance of Manager.setAllModsEnabled - Skip processing the mods that already are in the desired state - Update VueX store only once at the end, not after each mod, since this will trigger a costly rerendering (which will be addressed separately --- src/pages/Manager.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pages/Manager.vue b/src/pages/Manager.vue index 7d2e45dee..710b3ed23 100644 --- a/src/pages/Manager.vue +++ b/src/pages/Manager.vue @@ -499,7 +499,13 @@ import CategoryFilterModal from '../components/modals/CategoryFilterModal.vue'; } async setAllModsEnabled(enabled: boolean) { + let lastSuccessfulUpdate: ManifestV2[] = []; + for (const mod of this.localModList) { + if (mod.isEnabled() === enabled) { + continue; + } + let profileErr: R2Error | void; if (enabled) { profileErr = await ProfileInstallerProvider.instance.enableMod(mod, this.contextProfile!); @@ -520,9 +526,15 @@ import CategoryFilterModal from '../components/modals/CategoryFilterModal.vue'; if (update instanceof R2Error) { this.showError(update); continue; + } else { + lastSuccessfulUpdate = update; } - await this.$store.dispatch("updateModList", update); } + + if (lastSuccessfulUpdate.length) { + await this.$store.dispatch("updateModList", lastSuccessfulUpdate); + } + await this.$router.push({name: "manager.installed"}); }