Skip to content

Commit c868b98

Browse files
Fix getModList errors being silently ignored
1 parent d03f65a commit c868b98

File tree

4 files changed

+56
-32
lines changed

4 files changed

+56
-32
lines changed

Diff for: src/components/views/DownloadModModal.vue

+25-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
<template>
22
<div>
3-
<div id='downloadProgressModal' :class="['modal', {'is-active':$store.state.download.isModProgressModalOpen}]" v-if="$store.getters['download/currentDownload'] !== null">
3+
<div
4+
id='downloadProgressModal'
5+
:class="['modal', {'is-active':$store.state.download.isModProgressModalOpen}]"
6+
v-if="$store.getters['download/currentDownload'] !== null"
7+
>
48
<div class="modal-background" @click="setIsModProgressModalOpen(false);"></div>
59
<div class='modal-content'>
610
<div class='notification is-info'>
7-
<h3 class='title'>Downloading and installing {{$store.getters['download/currentDownload'].modName}}</h3>
11+
12+
<h3 v-if="$store.getters['download/currentDownload'].downloadProgress < 100" class='title'>
13+
Downloading {{$store.getters['download/currentDownload'].modName}}
14+
</h3>
15+
<h3 v-else class='title'>
16+
Installing {{$store.getters['download/currentDownload'].modName}}
17+
</h3>
18+
819
<p>Downloading: {{Math.floor($store.getters['download/currentDownload'].downloadProgress)}}% complete</p>
20+
921
<Progress
1022
:max='100'
1123
:value="$store.getters['download/currentDownload'].downloadProgress"
1224
:className="['is-dark']"
1325
/>
14-
<p v-if="$store.getters['download/currentDownload'].installProgress">Installing: {{$store.getters['download/currentDownload'].installProgress}}% complete</p>
26+
27+
<p v-if="$store.getters['download/currentDownload'].installProgress">
28+
Installing: {{Math.floor($store.getters['download/currentDownload'].installProgress)}}% complete
29+
</p>
1530
<p v-else>Installing: waiting for download to finish</p>
31+
1632
<Progress
1733
:max='100'
1834
:value="$store.getters['download/currentDownload'].installProgress"
@@ -101,11 +117,12 @@ import ProfileModList from '../../r2mm/mods/ProfileModList';
101117
}
102118
}
103119
const modList = await ProfileModList.getModList(profile.asImmutableProfile());
104-
if (!(modList instanceof R2Error)) {
105-
const err = await ConflictManagementProvider.instance.resolveConflicts(modList, profile.asImmutableProfile());
106-
if (err instanceof R2Error) {
107-
return reject(err);
108-
}
120+
if (modList instanceof R2Error) {
121+
return reject(modList);
122+
}
123+
const err = await ConflictManagementProvider.instance.resolveConflicts(modList, profile.asImmutableProfile());
124+
if (err instanceof R2Error) {
125+
return reject(err);
109126
}
110127
return resolve();
111128
});

Diff for: src/pages/DownloadMonitor.vue

+27-19
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@
2525
<Progress
2626
:max='100'
2727
:value='100'
28-
:className="['is-danger']"
28+
:className="['is-success']"
29+
/>
30+
</div>
31+
32+
<div v-else-if="downloadObject.downloadProgress === 100 && downloadObject.installProgress === 100">
33+
<p>Download complete</p>
34+
<Progress
35+
:max='100'
36+
:value='100'
37+
:className="['is-success']"
2938
/>
3039
</div>
3140

@@ -42,24 +51,23 @@
4251
/>
4352
</div>
4453

45-
<div v-if="downloadObject.installProgress < 100" class="col">
46-
<div v-if="downloadObject.downloadProgress < 100">
47-
<p>Installing:</p>
48-
<p v-if="downloadObject.downloadProgress < 100">Waiting for download to finish</p>
49-
<Progress
50-
:max='100'
51-
:className="['is-info']"
52-
/>
53-
</div>
54-
<div v-else>
55-
<p>Installing: {{ downloadObject.modName }}</p>
56-
<p>{{Math.min(Math.floor(downloadObject.installProgress), 100)}}% complete</p>
57-
<Progress
58-
:max='100'
59-
:value='downloadObject.installProgress'
60-
:className="['is-info']"
61-
/>
62-
</div>
54+
<div v-if="downloadObject.downloadProgress < 100" class="col">
55+
<p>Installing:</p>
56+
<p>Waiting for download to finish</p>
57+
<Progress
58+
:max='100'
59+
:value='0'
60+
:className="['is-info']"
61+
/>
62+
</div>
63+
<div v-else class="col">
64+
<p>Installing: {{ downloadObject.modName }}</p>
65+
<p>{{Math.min(Math.floor(downloadObject.installProgress), 100)}}% complete</p>
66+
<Progress
67+
:max='100'
68+
:value='downloadObject.installProgress'
69+
:className="['is-info']"
70+
/>
6371
</div>
6472

6573
</div>

Diff for: src/r2mm/downloading/BetterThunderstoreDownloader.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader
115115
console.error(`Ignore unknown status code "${status}"`);
116116
return;
117117
}
118-
totalProgressCallback(Math.round(totalDownloadProgress), modInProgressName, status, err);
118+
totalProgressCallback(totalDownloadProgress, modInProgressName, status, err);
119119
}
120120

121121
for (const comboInProgress of allModsToDownload) {
@@ -196,7 +196,7 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader
196196

197197
public generateProgressPercentage(progress: number, currentIndex: number, total: number): number {
198198
const completedProgress = (currentIndex / total) * 100;
199-
return completedProgress + (progress * 1/total);
199+
return Math.round(completedProgress + (progress * 1/total));
200200
}
201201

202202
public async queueDownloadDependencies(entries: IterableIterator<[number, ThunderstoreCombo]>, ignoreCache: boolean, callback: (progress: number, modName: string, status: number, err: R2Error | null) => void) {

Diff for: src/utils/ProfileUtils.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ export async function installModsToProfile(
7474

7575
const installedVersions = profileMods.map((m) => m.getDependencyString());
7676
const disabledMods = disabledModsOverride || profileMods.filter((m) => !m.isEnabled()).map((m) => m.getName());
77-
let currentMod;
7877
let modName = 'Unknown';
78+
7979
try {
8080
for (const [index, comboMod] of comboList.entries()) {
81-
currentMod = comboMod;
82-
modName = currentMod.getMod().getFullName();
81+
modName = comboMod.getMod().getFullName();
8382

8483
const manifestMod = new ManifestV2().fromThunderstoreMod(comboMod.getMod(), comboMod.getVersion());
8584

0 commit comments

Comments
 (0)