Skip to content

Commit 1eed662

Browse files
Move downloadAndInstallSpecific away from the UI component
1 parent cc4d610 commit 1eed662

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

src/components/views/DownloadModModal.vue

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@
4747
4848
import { mixins } from "vue-class-component";
4949
import { Component } from 'vue-property-decorator';
50-
import { Store } from "vuex";
5150
5251
import { Progress } from '../all';
5352
import ModalCard from '../ModalCard.vue';
5453
import DownloadModVersionSelectModal from "../../components/views/DownloadModVersionSelectModal.vue";
5554
import UpdateAllInstalledModsModal from "../../components/views/UpdateAllInstalledModsModal.vue";
5655
import DownloadMixin from "../mixins/DownloadMixin.vue";
57-
import { ImmutableProfile } from '../../model/Profile';
5856
import R2Error from '../../model/errors/R2Error';
5957
import ThunderstoreMod from '../../model/ThunderstoreMod';
6058
import ThunderstoreVersion from '../../model/ThunderstoreVersion';
@@ -71,32 +69,6 @@ import ThunderstoreDownloaderProvider from '../../providers/ror2/downloading/Thu
7169
})
7270
export default class DownloadModModal extends mixins(DownloadMixin) {
7371
74-
public static async downloadAndInstallSpecific(
75-
profile: ImmutableProfile,
76-
combo: ThunderstoreCombo,
77-
store: Store<any>
78-
): Promise<void> {
79-
const assignId = await store.dispatch(
80-
'download/addDownload',
81-
[`${combo.getMod().getName()} (${combo.getVersion().getVersionNumber().toString()})`]
82-
);
83-
84-
try {
85-
const downloadedMods = await ThunderstoreDownloaderProvider.instance.download(
86-
profile,
87-
combo,
88-
store.state.download.ignoreCache,
89-
(downloadProgress: number, modName: string, status: number, err: R2Error | null) => {
90-
store.dispatch('download/downloadProgressCallback', { assignId, downloadProgress, modName, status, err });
91-
}
92-
);
93-
await store.dispatch('download/installMod', {downloadedMods, assignId, profile});
94-
} catch (e) {
95-
store.commit('download/updateDownload', { assignId, failed: true });
96-
throw e;
97-
}
98-
}
99-
10072
async downloadHandler(tsMod: ThunderstoreMod, tsVersion: ThunderstoreVersion) {
10173
this.closeModal();
10274

src/pages/Manager.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ import ModalCard from '../components/ModalCard.vue';
639639
}
640640
641641
try {
642-
await DownloadModModal.downloadAndInstallSpecific(this.profile.asImmutableProfile(), combo, this.$store);
642+
await this.$store.dispatch('download/downloadAndInstallSpecific', {profile: this.profile.asImmutableProfile(), combo});
643643
const modList = await ProfileModList.getModList(this.profile.asImmutableProfile());
644644
if (modList instanceof R2Error) {
645645
throw modList;

src/store/modules/DownloadModule.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,28 @@ export const DownloadModule = {
126126
});
127127
},
128128

129+
async downloadAndInstallSpecific({state, commit, dispatch}, params: {
130+
combo: ThunderstoreCombo,
131+
profile: ImmutableProfile
132+
}) {
133+
const assignId = await dispatch('addDownload', [`${params.combo.getMod().getName()} (${params.combo.getVersion().getVersionNumber().toString()})`]);
134+
135+
try {
136+
const downloadedMods = await ThunderstoreDownloaderProvider.instance.download(
137+
params.profile,
138+
params.combo,
139+
state.ignoreCache,
140+
(downloadProgress: number, modName: string, status: number, err: R2Error | null) => {
141+
dispatch('downloadProgressCallback', { assignId, downloadProgress, modName, status, err });
142+
}
143+
);
144+
await dispatch('installMods', {downloadedMods, assignId, profile: params.profile});
145+
} catch (e) {
146+
commit('updateDownload', { assignId, failed: true });
147+
throw e;
148+
}
149+
},
150+
129151
async downloadProgressCallback({commit}, params: {
130152
assignId: number,
131153
downloadProgress: number,

0 commit comments

Comments
 (0)