Skip to content

Commit 2da3e6f

Browse files
committed
Addressed more PR comments:
- Nits / comment changes - Restore old functionality to setIconPath - Changed Profiles.vue onMounted to be sequential rather than lambda style promises.
1 parent a9e21a0 commit 2da3e6f

File tree

6 files changed

+23
-40
lines changed

6 files changed

+23
-40
lines changed

src/pages/Profiles.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,20 @@ async function backToGameSelection() {
132132
133133
onMounted( async () => {
134134
const settings = await store.getters.settings;
135+
await settings.load();
135136
136-
settings.load()
137-
.then(() => store.dispatch('profile/loadLastSelectedProfile'))
138-
.then((profileName: string) => {
139-
// If the view was entered via game selection, the mod list was updated
140-
// and the cache cleared. The profile is already set in the Vuex store
141-
// but we want to trigger the cache prewarming. Always doing this for
142-
// empty profiles is deemed a fair tradeoff. On the other hand there's
143-
// no point to trigger this when returning from the manager view and the
144-
// mods are already cached.
145-
if (store.state.tsMods.cache.size === 0) {
146-
setSelectedProfile(profileName, false);
147-
}
148-
})
149-
.then(updateProfileList);
137+
const lastSelectedProfileName = await store.dispatch('profile/loadLastSelectedProfile');
138+
139+
// If the view was entered via game selection, the mod list was updated
140+
// and the cache cleared. The profile is already set in the Vuex store
141+
// but we want to trigger the cache prewarming. Always doing this for
142+
// empty profiles is deemed a fair tradeoff. On the other hand there's
143+
// no point to trigger this when returning from the manager view and the
144+
// mods are already cached.
145+
if (store.state.tsMods.cache.size === 0) {
146+
await setSelectedProfile(lastSelectedProfileName, false);
147+
}
148+
149+
await updateProfileList();
150150
})
151151
</script>

src/pages/Splash.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@
121121
import { ExternalLink, Hero, Progress } from '../components/all';
122122
import Game from '../model/game/Game';
123123
import FsProvider from '../providers/generic/file/FsProvider';
124-
import GameDirectoryResolverProvider from '../providers/ror2/game/GameDirectoryResolverProvider';
125-
import LinuxGameDirectoryResolver from '../r2mm/manager/linux/GameDirectoryResolver';
126124
import PathResolver from '../r2mm/manager/PathResolver';
127125
import { computed, onMounted, ref } from 'vue';
128126
import { State } from '../store';

src/providers/generic/zip/AdmZipProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export default class AdmZipProvider extends ZipProvider {
1313
return window.zip.readFile(zip, file);
1414
}
1515

16-
// Type is Promise<ZipEntryInterface[]>
17-
async getEntries(zip: string): Promise<any> {
16+
async getEntries(zip: string): Promise<ZipEntryInterface[]> {
1817
return window.zip.getEntries(zip) as ZipEntryInterface[];
1918
}
2019

src/r2mm/mods/ProfileModList.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -288,25 +288,16 @@ export default class ProfileModList {
288288
path.join(PathResolver.MOD_ROOT, "cache", mod.getName(), mod.getVersionNumber().toString(), "icon.png"),
289289
]
290290

291-
return new Promise(async (resolve, reject) => {
291+
for (const iconPath of paths) {
292292
try {
293-
for (const iconPath of paths) {
294-
const exists = await FsProvider.instance.exists(iconPath);
295-
if (exists) {
296-
const content = await FsProvider.instance.base64FromZip(iconPath);
297-
mod.setIcon(`data:image/png;base64,${content}`);
298-
resolve(true);
299-
break;
300-
}
301-
}
302-
resolve(false);
293+
const content = await FsProvider.instance.base64FromZip(iconPath);
294+
mod.setIcon(`data:image/png;base64,${content}`);
295+
return;
303296
} catch (e) {
304-
reject(e);
305-
}
306-
}).then(resolved => {
307-
if (!resolved) {
308-
mod.setIcon("/unknown.png");
297+
continue;
309298
}
310-
});
299+
}
300+
301+
mod.setIcon("/unknown.png");
311302
}
312303
}

src/store/modules/DownloadModule.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ export const DownloadModule = {
274274
}
275275
},
276276
addDownload(state: State, download: DownloadProgress) {
277-
// @ts-ignore
278277
state.allDownloads = [...state.allDownloads, download];
279278
},
280279
setDone(state: State, downloadId: number) {

src/store/modules/TsModsModule.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ export const TsModsModule = {
184184

185185
if (localState.get(cacheKey) === undefined) {
186186
const tsMod = state.mods.find((m) => m.getFullName() === mod.getName());
187-
188-
// Updating Vuex state directly instead of mutations is a bad
189-
// practice but everything seems to work here since we only
190-
// mutate the map instead of replacing it altogether.
191187
if (tsMod === undefined) {
192188
localState.set(cacheKey, {tsMod: undefined, isLatest: true});
193189
} else {

0 commit comments

Comments
 (0)