Skip to content

Commit

Permalink
LocalModCard: don't delegate mod disabling to LocalModList
Browse files Browse the repository at this point in the history
LocalModCard now disables mods without dependants internally, and
delegates mods with dependants to DisableModModal, effectively cutting
out the middleman LocalModList.
  • Loading branch information
anttimaki committed Feb 22, 2024
1 parent 72afea0 commit 578ab72
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 33 deletions.
32 changes: 1 addition & 31 deletions src/components/views/LocalModList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
v-for='(mod, index) in draggableList'
:key="`local-${mod.getName()}-${profileName}-${index}-${cardExpanded}`"
:mod="mod"
@disableMod="disableModRequireConfirmation"
@error="emitError"
@enableMod="enableMod"
@uninstallMod="uninstallModRequireConfirmation"
@updateMod="updateMod"
Expand Down Expand Up @@ -158,26 +158,6 @@ import SearchAndSort from './LocalModList/SearchAndSort.vue';
return modList;
}
async performDisable(mods: ManifestV2[]): Promise<R2Error | void> {
for (let mod of mods) {
const disableErr: R2Error | void = await ProfileInstallerProvider.instance.disableMod(mod, this.contextProfile!);
if (disableErr instanceof R2Error) {
// Failed to disable
this.$emit('error', disableErr);
return disableErr;
}
}
const updatedList = await ProfileModList.updateMods(mods, this.contextProfile!, (updatingMod: ManifestV2) => {
updatingMod.disable();
});
if (updatedList instanceof R2Error) {
// Failed to update mod list.
this.$emit('error', updatedList);
return updatedList;
}
await this.updateModListAfterChange(updatedList);
}
async uninstallModWithDependents(mod: ManifestV2) {
await this.uninstallMods([...this.getDependantList(mod), mod]);
}
Expand Down Expand Up @@ -234,16 +214,6 @@ import SearchAndSort from './LocalModList/SearchAndSort.vue';
}
}
disableModRequireConfirmation(mod: ManifestV2) {
for (const value of this.getDependantList(mod)) {
if (value.isEnabled()) {
this.$store.commit('openDisableModModal', mod);
return;
}
}
this.performDisable([mod]);
}
viewDependencyList(mod: ManifestV2) {
this.showDependencyList(mod, DependencyListDisplayType.VIEW);
}
Expand Down
24 changes: 22 additions & 2 deletions src/components/views/LocalModList/LocalModCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { ExpandableCard, Link } from '../../all';
import DonateButton from '../../buttons/DonateButton.vue';
import ManifestV2 from '../../../model/ManifestV2';
import LoggerProvider, { LogSeverity } from '../../../providers/ror2/logging/LoggerProvider';
import Dependants from '../../../r2mm/mods/Dependants';
import ModBridge from '../../../r2mm/mods/ModBridge';
@Component({
Expand Down Expand Up @@ -73,8 +75,26 @@ export default class LocalModCard extends Vue {
);
}
disableMod() {
this.$emit('disableMod', this.mod);
async disableMod() {
const dependants = Dependants.getDependantList(this.mod, this.$store.state.localModList);
for (const mod of dependants) {
if (mod.isEnabled()) {
this.$store.commit('openDisableModModal', this.mod);
return;
}
}
try {
await this.$store.dispatch(
'profile/disableModsFromActiveProfile',
{ mods: [this.mod] }
);
} catch (e) {
this.$emit('error', e);
const err: Error = e as Error;
LoggerProvider.instance.Log(LogSeverity.ACTION_STOPPED, `${err.name}\n-> ${err.message}`);
}
}
enableMod(mod: ManifestV2) {
Expand Down

0 comments on commit 578ab72

Please sign in to comment.