Skip to content

Commit

Permalink
Refactor LocalModList.getDisabledDependencies
Browse files Browse the repository at this point in the history
Improve the readability of the code quite a bit and performance a
little bit.
  • Loading branch information
anttimaki committed Jan 29, 2024
1 parent 488dc4a commit 3151cf4
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/components/views/LocalModList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,14 @@ import UninstallModModal from './LocalModList/UninstallModModal.vue';
}
getDisabledDependencies(vueMod: any): ManifestV2[] {
const mod: Mod = new Mod().fromReactive(vueMod);
const installedMods = [...this.modifiableModList];
const installedDependencies = mod.getDependencies().filter((dependency: string) => {
return this.modifiableModList.find((localMod: ManifestV2) => dependency.toLowerCase().startsWith(localMod.getName().toLowerCase() + "-"));
})
.filter(value => installedMods.find(installed => value.toLowerCase().startsWith(installed.getName().toLowerCase() + "-")))
.map(value => installedMods.find(installed => value.toLowerCase().startsWith(installed.getName().toLowerCase() + "-")));
const dependencies = new Mod()
.fromReactive(vueMod)
.getDependencies()
.map((x) => x.toLowerCase().substring(0, x.lastIndexOf('-') + 1));
const safeInstalledDependencies = installedDependencies as ManifestV2[];
return safeInstalledDependencies.filter(value => !value.isEnabled());
return this.modifiableModList.filter(
(mod) => !mod.isEnabled() && dependencies.includes(mod.getName().toLowerCase() + '-')
);
}
getDependantList(mod: ManifestV2): Set<ManifestV2> {
Expand Down

0 comments on commit 3151cf4

Please sign in to comment.