Skip to content

Commit

Permalink
Merge pull request #1190 from ebkr/cleanup-mod-list-ordering
Browse files Browse the repository at this point in the history
Clean up code related to ordering local mod list
  • Loading branch information
MythicManiac authored Jan 30, 2024
2 parents 7c0fd36 + 7dcaa68 commit da310ec
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 68 deletions.
4 changes: 0 additions & 4 deletions src/components/ExpandableCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@
this.visible = !this.visible;
}
emitMove(direction: string) {
this.$emit("move" + direction);
}
async created() {
this.visible = this.expandedByDefault;
}
Expand Down
24 changes: 2 additions & 22 deletions src/components/views/LocalModList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
<slot name="above-list"></slot>

<draggable v-model='draggableList' group="local-mods" handle=".handle"
@start="drag=canShowSortIcons; $emit('sort-start')"
@end="drag=false; $emit('sort-end')"
@start="drag=canShowSortIcons"
@end="drag=false"
:force-fallback="true"
:scroll-sensitivity="100">
<local-mod-card
Expand Down Expand Up @@ -236,26 +236,6 @@ import LocalModCard from './LocalModList/LocalModCard.vue';
this.filterModList();
}
async moveUp(vueMod: any) {
const mod: ManifestV2 = new ManifestV2().fromReactive(vueMod);
const updatedList = await ProfileModList.shiftModEntryUp(mod, this.contextProfile!);
if (updatedList instanceof R2Error) {
this.$emit('error', updatedList);
return;
}
await this.updateModListAfterChange(updatedList);
}
async moveDown(vueMod: any) {
const mod: ManifestV2 = new ManifestV2().fromReactive(vueMod);
const updatedList = await ProfileModList.shiftModEntryDown(mod, this.contextProfile!);
if (updatedList instanceof R2Error) {
this.$emit('error', updatedList);
return;
}
await this.updateModListAfterChange(updatedList);
}
getMissingDependencies(vueMod: any): string[] {
const mod: Mod = new Mod().fromReactive(vueMod);
return mod.getDependencies().filter((dependency: string) => {
Expand Down
42 changes: 0 additions & 42 deletions src/r2mm/mods/ProfileModList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,48 +262,6 @@ export default class ProfileModList {
}
}

public static async shiftModEntryUp(mod: ManifestV2, profile: Profile): Promise<ManifestV2[] | R2Error> {
let list: ManifestV2[] | R2Error = await this.getModList(profile);
if (list instanceof R2Error) {
return list;
}
const index = list.findIndex((stored: ManifestV2) => stored.getName() === mod.getName())
if (index === 0) {
return list;
} else {
list = list.filter((stored: ManifestV2) => stored.getName() !== mod.getName());
const start = list.slice(0, index - 1);
const end = list.slice(index - 1);
list = [...start, mod, ...end];
}
const saveErr = await this.saveModList(profile, list);
if (saveErr instanceof R2Error) {
return saveErr;
}
return this.getModList(profile);
}

public static async shiftModEntryDown(mod: ManifestV2, profile: Profile): Promise<ManifestV2[] | R2Error> {
let list: ManifestV2[] | R2Error = await this.getModList(profile);
if (list instanceof R2Error) {
return list;
}
const index = list.findIndex((stored: ManifestV2) => stored.getName() === mod.getName())
if (index === list.length) {
return list;
} else {
list = list.filter((stored: ManifestV2) => stored.getName() !== mod.getName());
const start = list.slice(0, index + 1);
const end = list.slice(index + 1);
list = [...start, mod, ...end];
}
const saveErr = await this.saveModList(profile, list);
if (saveErr instanceof R2Error) {
return saveErr;
}
return this.getModList(profile);
}

public static getDisabledModCount(modList: ManifestV2[]): number {
return modList.filter(value => !value.isEnabled()).length;
}
Expand Down

0 comments on commit da310ec

Please sign in to comment.