Skip to content

Commit

Permalink
Move downloadCompletedCallback to DownloadMixin to make it easier to
Browse files Browse the repository at this point in the history
split DownloadModModal component
  • Loading branch information
VilppeRiskidev committed Dec 18, 2024
1 parent bfe2233 commit d0b6581
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
13 changes: 12 additions & 1 deletion src/components/mixins/DownloadMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
import Vue from 'vue';
import Component from 'vue-class-component';
import ThunderstoreMod from "../../model/ThunderstoreMod";
import R2Error from "../../model/errors/R2Error";
import Game from "../../model/game/Game";
import Profile from "../../model/Profile";
import ThunderstoreCombo from "../../model/ThunderstoreCombo";
import ThunderstoreMod from "../../model/ThunderstoreMod";
import { installModsAndResolveConflicts } from "../../utils/ProfileUtils";
@Component
Expand All @@ -29,5 +32,13 @@ export default class DownloadMixin extends Vue {
get profile(): Profile {
return this.$store.getters['profile/activeProfile'];
}
async downloadCompletedCallback(downloadedMods: ThunderstoreCombo[]): Promise<void> {
try {
await installModsAndResolveConflicts(downloadedMods, this.profile.asImmutableProfile(), this.$store);
} catch (e) {
this.$store.commit('error/handleError', R2Error.fromThrownValue(e));
}
}
}
</script>
20 changes: 8 additions & 12 deletions src/components/views/DownloadModModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import Profile from '../../model/Profile';
import { Progress } from '../all';
import ConflictManagementProvider from '../../providers/generic/installing/ConflictManagementProvider';
import ModalCard from '../ModalCard.vue';
import { installModsAndResolveConflicts } from '../../utils/ProfileUtils';
import DownloadMixin from "../mixins/DownloadMixin.vue";
import DownloadModVersionSelectModal from "../../components/views/DownloadModVersionSelectModal.vue";
Expand Down Expand Up @@ -214,7 +213,10 @@ interface DownloadProgress {
downloadVersion: [currentAssignId, obj]
});
}
}, this.downloadCompletedCallback);
}, (downloadedMods) => {
this.downloadCompletedCallback(downloadedMods);
this.downloadingMod = false;
});
}
downloadHandler(tsMod: ThunderstoreMod, tsVersion: ThunderstoreVersion) {
Expand Down Expand Up @@ -268,19 +270,13 @@ interface DownloadProgress {
downloadVersion: [currentAssignId, obj]
});
}
}, this.downloadCompletedCallback);
}, (downloadedMods) => {
this.downloadCompletedCallback(downloadedMods);
this.downloadingMod = false;
});
}, 1);
}
async downloadCompletedCallback(downloadedMods: ThunderstoreCombo[]) {
try {
await installModsAndResolveConflicts(downloadedMods, this.profile.asImmutableProfile(), this.$store);
} catch (e) {
this.$store.commit('error/handleError', R2Error.fromThrownValue(e));
}
this.downloadingMod = false;
}
static async installModAfterDownload(profile: Profile, mod: ThunderstoreMod, version: ThunderstoreVersion): Promise<R2Error | void> {
return new Promise(async (resolve, reject) => {
const manifestMod: ManifestV2 = new ManifestV2().fromThunderstoreMod(mod, version);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ProfileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import Profile, { ImmutableProfile } from "../model/Profile";
import ThunderstoreCombo from "../model/ThunderstoreCombo";
import VersionNumber from "../model/VersionNumber";
import FsProvider from "../providers/generic/file/FsProvider";
import ConflictManagementProvider from "../providers/generic/installing/ConflictManagementProvider";
import ZipProvider from "../providers/generic/zip/ZipProvider";
import ProfileInstallerProvider from "../providers/ror2/installing/ProfileInstallerProvider";
import * as PackageDb from '../r2mm/manager/PackageDexieStore';
import ProfileModList from "../r2mm/mods/ProfileModList";
import ConflictManagementProvider from "../providers/generic/installing/ConflictManagementProvider";
import {Store} from "vuex";

export async function exportModsToCombos(exportMods: ExportMod[], game: Game): Promise<ThunderstoreCombo[]> {
Expand Down

0 comments on commit d0b6581

Please sign in to comment.