Skip to content

Commit d35463d

Browse files
Remove unnecessary isProfileBeingImported and use activeStep instead
1 parent fd12d3b commit d35463d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/components/profiles-modals/ImportProfileModal.vue

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,20 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
3838
private importUpdateSelection: "IMPORT" | "UPDATE" | null = null;
3939
private percentageImported: number = 0;
4040
private profileImportCode: string = '';
41-
private isProfileBeingImported: boolean = false;
4241
private listenerId: number = 0;
4342
private newProfileName: string = '';
4443
private profileImportFilePath: string | null = null;
4544
private profileImportContent: ExportFormat | null = null;
46-
private activeStep: 'IMPORT_UPDATE_SELECTION' | 'FILE_CODE_SELECTION' | 'IMPORT_CODE' | 'IMPORT_FILE' | 'ADDING_PROFILE' | 'REVIEW_IMPORT' | 'NO_PACKAGES_IN_IMPORT' = 'IMPORT_UPDATE_SELECTION';
45+
private activeStep:
46+
'IMPORT_UPDATE_SELECTION'
47+
| 'FILE_CODE_SELECTION'
48+
| 'IMPORT_CODE'
49+
| 'IMPORT_FILE'
50+
| 'ADDING_PROFILE'
51+
| 'REVIEW_IMPORT'
52+
| 'NO_PACKAGES_IN_IMPORT'
53+
| 'PROFILE_IS_BEING_IMPORTED'
54+
= 'IMPORT_UPDATE_SELECTION';
4755
4856
async created() {
4957
fs = FsProvider.instance;
@@ -120,7 +128,7 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
120128
121129
async importProfileHandler(files: string[] | null) {
122130
if (files === null || files.length === 0) {
123-
this.isProfileBeingImported = false;
131+
this.closeModal();
124132
return;
125133
}
126134
@@ -203,7 +211,7 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
203211
await this.$store.dispatch('profiles/setSelectedProfile', { profileName: profileName, prewarmCache: true });
204212
}
205213
if (parsed.getMods().length > 0) {
206-
this.isProfileBeingImported = true;
214+
this.activeStep = 'PROFILE_IS_BEING_IMPORTED';
207215
setTimeout(async () => {
208216
await this.downloadImportedProfileMods(parsed.getMods(), async () => {
209217
if (files[0].endsWith('.r2z')) {
@@ -253,7 +261,6 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
253261
downloadProgressCallback(progress: number, modName: string, status: number, err: R2Error | null) {
254262
if (status == StatusEnum.FAILURE) {
255263
this.closeModal();
256-
this.isProfileBeingImported = false;
257264
if (err instanceof R2Error) {
258265
this.$store.commit('error/handleError', err);
259266
}
@@ -273,7 +280,6 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
273280
if (installResult instanceof R2Error) {
274281
this.$store.commit('error/handleError', installResult);
275282
keepIterating = false;
276-
this.isProfileBeingImported = false;
277283
return;
278284
}
279285
for (const imported of modList) {
@@ -290,7 +296,7 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
290296
if (callback !== undefined) {
291297
callback();
292298
}
293-
this.isProfileBeingImported = false;
299+
this.closeModal();
294300
}
295301
296302
// Called when the name for the imported profile is given and confirmed by the user.
@@ -421,11 +427,11 @@ export default class ImportProfileModal extends mixins(ProfilesMixin) {
421427
</template>
422428
</ModalCard>
423429

424-
<ModalCard v-else-if="isProfileBeingImported" key="PROFILE_IS_BEING_IMPORTED" :is-active="isOpen" :canClose="false">
430+
<ModalCard v-else-if="activeStep === 'PROFILE_IS_BEING_IMPORTED'" key="PROFILE_IS_BEING_IMPORTED" :is-active="isOpen" :canClose="false">
425431
<template v-slot:header>
426432
<h2 class="modal-title">{{percentageImported}}% imported</h2>
427433
</template>
428-
<template v-slot:body>
434+
<template v-slot:footer>
429435
<p>This may take a while, as mods are being downloaded.</p>
430436
<p>Please do not close {{appName}}.</p>
431437
</template>

0 commit comments

Comments
 (0)