Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store list of local mods with updates on VueX #1181

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/settings-components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ import UtilityMixin from '../mixins/UtilityMixin.vue';
'Update all mods',
'Quickly update every installed mod to their latest versions.',
async () => {
const outdatedMods = ThunderstoreDownloaderProvider.instance.getLatestOfAllToUpdate(this.localModList, this.$store.state.thunderstoreModList);
const outdatedMods = this.$store.getters.localModsWithUpdates;
if (outdatedMods.length === 1) {
return "1 mod has an update available";
}
Expand Down Expand Up @@ -412,6 +412,5 @@ import UtilityMixin from '../mixins/UtilityMixin.vue';
doesLogFileExist() {
return this.logOutput.exists ? 'Log file exists' : 'Log file does not exist';
}

}
</script>
10 changes: 1 addition & 9 deletions src/components/views/DownloadModModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<p>The following mods will be downloaded and installed:</p>
<br/>
<ul class="list">
<li class="list-item" v-for='(key, index) in getListOfModsToUpdate()'
<li class="list-item" v-for='(key, index) in $store.getters.localModsWithUpdates'
:key='`to-update-${index}-${key.getVersion().getFullName()}`'>
{{key.getVersion().getName()}} will be updated to: {{key.getVersion().getVersionNumber().toString()}}
</li>
Expand Down Expand Up @@ -205,10 +205,6 @@ let assignId = 0;
return this.$store.state.thunderstoreModList || [];
}

get localModList(): ManifestV2[] {
return this.$store.state.localModList || [];
}

@Watch('$store.state.modals.downloadModModalMod')
async getModVersions() {
this.currentVersion = null;
Expand Down Expand Up @@ -375,10 +371,6 @@ let assignId = 0;
}, 1);
}

getListOfModsToUpdate(): ThunderstoreCombo[] {
return ThunderstoreDownloaderProvider.instance.getLatestOfAllToUpdate(this.localModList, this.thunderstorePackages);
}

static async installModAfterDownload(profile: Profile, mod: ThunderstoreMod, version: ThunderstoreVersion): Promise<R2Error | void> {
return new Promise(async (resolve, reject) => {
const manifestMod: ManifestV2 = new ManifestV2().fromThunderstoreMod(mod, version);
Expand Down
5 changes: 1 addition & 4 deletions src/components/views/InstalledModView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ export default class InstalledModView extends Vue {
}

get numberOfModsWithUpdates(): number {
return ThunderstoreDownloaderProvider.instance.getLatestOfAllToUpdate(
this.$store.state.localModList,
this.$store.state.thunderstoreModList
).length;
return this.$store.getters.localModsWithUpdates.length;
}
};
</script>
9 changes: 9 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ModFilterModule from './modules/ModFilterModule';
import { FolderMigration } from '../migrations/FolderMigration';
import ManifestV2 from '../model/ManifestV2';
import ThunderstoreMod from '../model/ThunderstoreMod';
import ThunderstoreDownloaderProvider from "../providers/ror2/downloading/ThunderstoreDownloaderProvider";
import ThunderstorePackages from '../r2mm/data/ThunderstorePackages';

Vue.use(Vuex);
Expand Down Expand Up @@ -83,6 +84,14 @@ export const store = {
state.deprecatedMods = ThunderstorePackages.getDeprecatedPackageMap();
}
},
getters: {
localModsWithUpdates(state: State) {
return ThunderstoreDownloaderProvider.instance.getLatestOfAllToUpdate(
state.localModList,
state.thunderstoreModList
);
}
},
modules: {
modals: ModalsModule,
modFilters: ModFilterModule,
Expand Down