diff --git a/package.json b/package.json index 272fc254..01f46077 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "bulma-steps": "^2.2.1", "bulma-switch": "^2.0.0", "core-js": "^3.6.5", - "dexie": "^3.0.3", + "dexie": "^3.2.7", "dot-prop": "^5.2.0", "electron-updater": "4.2.5", "elliptic": "^6.5.4", diff --git a/src/components/mixins/SplashMixin.vue b/src/components/mixins/SplashMixin.vue index adf5e002..2d39c3e2 100644 --- a/src/components/mixins/SplashMixin.vue +++ b/src/components/mixins/SplashMixin.vue @@ -67,6 +67,8 @@ export default class SplashMixin extends Vue { this.getRequestItem('ThunderstoreDownload').setProgress(100); } + // TODO: since the mod list is stored in IndexedDB storing it + // also on a file servers no purpose, clean this up. if (response) { ApiCacheUtils.storeLastRequest(response.data); } else { @@ -75,8 +77,8 @@ export default class SplashMixin extends Vue { } if (response) { - ThunderstorePackages.handlePackageApiResponse(response); - await this.$store.dispatch('tsMods/updateMods', ThunderstorePackages.PACKAGES); + await ThunderstorePackages.handlePackageApiResponse(this.activeGame.internalFolderName, response); + await this.$store.dispatch('tsMods/updateMods'); await this.moveToNextScreen(); } else { this.heroTitle = 'Failed to get mods from Thunderstore and cache'; @@ -85,7 +87,6 @@ export default class SplashMixin extends Vue { } async continueOffline() { - ThunderstorePackages.PACKAGES = []; await this.moveToNextScreen(); } diff --git a/src/components/mixins/UtilityMixin.vue b/src/components/mixins/UtilityMixin.vue index 7244a907..fbda0cea 100644 --- a/src/components/mixins/UtilityMixin.vue +++ b/src/components/mixins/UtilityMixin.vue @@ -28,7 +28,7 @@ export default class UtilityMixin extends Vue { const response = await ThunderstorePackages.update(this.$store.state.activeGame); await ApiCacheUtils.storeLastRequest(response.data); - await this.$store.dispatch("tsMods/updateMods", ThunderstorePackages.PACKAGES); + await this.$store.dispatch("tsMods/updateMods"); await this.$store.dispatch("profile/tryLoadModListFromDisk"); } diff --git a/src/components/views/DownloadModModal.vue b/src/components/views/DownloadModModal.vue index 552b2c0c..6a63a514 100644 --- a/src/components/views/DownloadModModal.vue +++ b/src/components/views/DownloadModModal.vue @@ -109,7 +109,6 @@ import StatusEnum from '../../model/enums/StatusEnum'; import ThunderstoreCombo from '../../model/ThunderstoreCombo'; import ProfileInstallerProvider from '../../providers/ror2/installing/ProfileInstallerProvider'; import ProfileModList from '../../r2mm/mods/ProfileModList'; -import ModBridge from '../../r2mm/mods/ModBridge'; import Profile from '../../model/Profile'; import { Progress } from '../all'; import Game from '../../model/game/Game'; @@ -242,19 +241,15 @@ let assignId = 0; this.downloadHandler(refSelectedThunderstoreMod, version); } + // TODO: rethink how this method and provider's downloadLatestOfAll() + // access the active game, local mod list and TS mod list. async downloadLatest() { this.closeModal(); - const localMods = await ProfileModList.getModList(this.contextProfile!); - if (localMods instanceof R2Error) { - this.downloadingMod = false; - this.$store.commit('error/handleError', localMods); - return; - } - const outdatedMods = localMods.filter(mod => !ModBridge.isCachedLatestVersion(mod)); + const modsWithUpdates: ThunderstoreCombo[] = this.$store.getters['profile/modsWithUpdates']; const currentAssignId = assignId++; const progressObject = { progress: 0, - initialMods: outdatedMods.map(value => `${value.getName()} (${value.getVersionNumber().toString()})`), + initialMods: modsWithUpdates.map(value => `${value.getMod().getName()} (${value.getVersion().toString()})`), modName: '', assignId: currentAssignId, failed: false, @@ -262,7 +257,7 @@ let assignId = 0; this.downloadObject = progressObject; DownloadModModal.allVersions.push([currentAssignId, this.downloadObject]); this.downloadingMod = true; - ThunderstoreDownloaderProvider.instance.downloadLatestOfAll(this.activeGame, outdatedMods, this.thunderstorePackages, (progress: number, modName: string, status: number, err: R2Error | null) => { + ThunderstoreDownloaderProvider.instance.downloadLatestOfAll(this.activeGame, modsWithUpdates, this.thunderstorePackages, (progress: number, modName: string, status: number, err: R2Error | null) => { const assignIndex = DownloadModModal.allVersions.findIndex(([number, val]) => number === currentAssignId); if (status === StatusEnum.FAILURE) { if (err !== null) { @@ -277,7 +272,7 @@ let assignId = 0; const obj = { progress: progress, modName: modName, - initialMods: outdatedMods.map(value => `${value.getName()} (${value.getVersionNumber().toString()})`), + initialMods: modsWithUpdates.map(value => `${value.getMod().getName()} (${value.getVersion().getVersionNumber().toString()})`), assignId: currentAssignId, failed: false, } diff --git a/src/components/views/LocalModList/LocalModCard.vue b/src/components/views/LocalModList/LocalModCard.vue index bf4bc708..97b9a41d 100644 --- a/src/components/views/LocalModList/LocalModCard.vue +++ b/src/components/views/LocalModList/LocalModCard.vue @@ -7,7 +7,6 @@ import ManifestV2 from '../../../model/ManifestV2'; import ThunderstoreMod from '../../../model/ThunderstoreMod'; import { LogSeverity } from '../../../providers/ror2/logging/LoggerProvider'; import Dependants from '../../../r2mm/mods/Dependants'; -import ModBridge from '../../../r2mm/mods/ModBridge'; @Component({ components: { @@ -28,16 +27,20 @@ export default class LocalModCard extends Vue { return this.tsMod ? this.tsMod.getDonationLink() : undefined; } + get isDeprecated() { + return this.tsMod ? this.tsMod.isDeprecated() : false; + } + get isLatestVersion() { - return ModBridge.isCachedLatestVersion(this.mod); + return this.$store.getters['tsMods/isLatestVersion'](this.mod); } get localModList(): ManifestV2[] { return this.$store.state.profile.modList; } - get tsMod() { - return ModBridge.getCachedThunderstoreModFromMod(this.mod); + get tsMod(): ThunderstoreMod | undefined { + return this.$store.getters['tsMods/tsMod'](this.mod); } @Watch("localModList") @@ -175,7 +178,7 @@ function dependencyStringToModName(x: string) {