Skip to content

Commit

Permalink
Improve performance of Manager.setAllModsEnabled
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
anttimaki committed Jan 30, 2024
1 parent 488dc4a commit bcbde74
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pages/Manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
Expand All @@ -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"});
}
Expand Down

0 comments on commit bcbde74

Please sign in to comment.