Skip to content

Commit

Permalink
Merge pull request #1290 from ebkr/fix-disable-toggle
Browse files Browse the repository at this point in the history
Fix mod disable toggle
  • Loading branch information
anttimaki authored Apr 15, 2024
2 parents 731bdf4 + 6c7c4d1 commit d2f63f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
22 changes: 19 additions & 3 deletions src/components/views/LocalModList/LocalModCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class LocalModCard extends Vue {
disabledDependencies: ManifestV2[] = [];
missingDependencies: string[] = [];
disableChangePending = false;
get donationLink() {
return this.tsMod ? this.tsMod.getDonationLink() : undefined;
Expand Down Expand Up @@ -72,11 +73,17 @@ export default class LocalModCard extends Vue {
}
async disableMod() {
if (this.disableChangePending) {
return;
}
this.disableChangePending = true;
const dependants = Dependants.getDependantList(this.mod, this.localModList);
for (const mod of dependants) {
if (mod.isEnabled()) {
this.$store.commit('openDisableModModal', this.mod);
this.disableChangePending = false;
return;
}
}
Expand All @@ -92,9 +99,16 @@ export default class LocalModCard extends Vue {
severity: LogSeverity.ACTION_STOPPED
});
}
this.disableChangePending = false;
}
async enableMod(mod: ManifestV2) {
if (this.disableChangePending) {
return;
}
this.disableChangePending = true;
const dependencies = Dependants.getDependencyList(mod, this.localModList);
try {
Expand All @@ -108,6 +122,8 @@ export default class LocalModCard extends Vue {
severity: LogSeverity.ACTION_STOPPED
});
}
this.disableChangePending = false;
}
async uninstallMod() {
Expand Down Expand Up @@ -223,12 +239,12 @@ function dependencyStringToModName(x: string) {
<span @click.prevent.stop="() => mod.isEnabled() ? disableMod() : enableMod(mod)"
class='card-header-icon'>
<div class="field">
<input id="switchExample"
<input :id="`switch-${mod.getName()}`"
type="checkbox"
name="switchExample"
:class='`switch is-small ${mod.isEnabled() ? "switch is-info" : ""}`'
:checked="mod.isEnabled()" />
<label for="switchExample" v-tooltip.left="mod.isEnabled() ? 'Disable' : 'Enable'"></label>
<label :for="`switch-${mod.getName()}`"
v-tooltip.left="mod.isEnabled() ? 'Disable' : 'Enable'"></label>
</div>
</span>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
return tree;
}
for (const value of tree.getRecursiveFiles()) {
if (mode === ModMode.DISABLED && mod.isEnabled()) {
if (mode === ModMode.DISABLED && mod.isEnabled() && !value.toLowerCase().endsWith(".old")) {
await FsProvider.instance.rename(value, `${value}.old`);
} else if (mode === ModMode.ENABLED && !mod.isEnabled()) {
if (value.toLowerCase().endsWith(".old")) {
await FsProvider.instance.rename(value, value.substring(0, value.length - ('.old').length));
}
} else if (mode === ModMode.ENABLED && !mod.isEnabled() && value.toLowerCase().endsWith(".old")) {
await FsProvider.instance.rename(value, value.substring(0, value.length - ('.old').length));
}
}
}
Expand Down

0 comments on commit d2f63f3

Please sign in to comment.