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

Clean up code related to ordering local mod list #1190

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
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
Loading