Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate enabling all mods to Vuex from settings view #1251

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 5 additions & 34 deletions src/pages/Manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Loading