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 17, 2024
1 parent b910f51 commit 569946e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 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, this.$store);
} catch (e) {
this.$store.commit('error/handleError', R2Error.fromThrownValue(e));
}
}
}
</script>
19 changes: 8 additions & 11 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, installModsToProfile} 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,18 +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, 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) => {
Expand Down

0 comments on commit 569946e

Please sign in to comment.