Skip to content

Commit

Permalink
Fix deprecation displays
Browse files Browse the repository at this point in the history
Use precalculated deprecation map that takes into account dependency
deprecations on LocalModCard.

Use the same map on OnlineModView to filter out deprecated mods unless
user uses filters to specifically ask for them.

And finally use the same map, via Vuex getter, to show the number of
mods available online on the navigation sidebar. This works a bit oddly
since the filter for deprecated mods is taken into account, but other
filters (e.g. NSFW content) are not. However, this is how it worked
before the changes too, and further changes are considered outside the
current scope.
  • Loading branch information
anttimaki committed Mar 18, 2024
1 parent 4657ed1 commit f364fae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/components/navigation/NavigationMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import R2Error from '../../model/errors/R2Error';
import Game from '../../model/game/Game';
import GameManager from '../../model/game/GameManager';
import Profile from '../../model/Profile';
import ThunderstoreMod from '../../model/ThunderstoreMod';
import {
LaunchMode,
launch,
Expand All @@ -83,11 +82,9 @@ export default class NavigationMenu extends Vue {
private LaunchMode = LaunchMode;
get thunderstoreModCount() {
let mods: ThunderstoreMod[] = this.$store.state.tsMods.mods;
return this.$store.state.modFilters.showDeprecatedPackages
? mods.length
: mods.filter((m) => !m.isDeprecated()).length;
? this.$store.state.tsMods.mods.length
: this.$store.getters['tsMods/undeprecatedModCount'];
}
get localModCount(): number {
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/LocalModList/LocalModCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class LocalModCard extends Vue {
}
get isDeprecated() {
return this.tsMod ? this.tsMod.isDeprecated() : false;
return this.$store.state.tsMods.deprecated.get(this.mod.getName()) || false;
}
get isLatestVersion() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/views/OnlineModView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ export default class OnlineModView extends Vue {
this.searchableThunderstoreModList = this.searchableThunderstoreModList.filter(mod => !mod.getNsfwFlag());
}
if (!showDeprecatedPackages) {
this.searchableThunderstoreModList = this.searchableThunderstoreModList.filter(mod => !mod.isDeprecated());
this.searchableThunderstoreModList = this.searchableThunderstoreModList.filter(
mod => !this.$store.state.tsMods.deprecated.get(mod.getFullName())
);
}
if (filterCategories.length > 0) {
this.searchableThunderstoreModList = this.searchableThunderstoreModList.filter((x: ThunderstoreMod) => {
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/TsModsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export const TsModsModule = {
/*** Return ThunderstoreMod representation of a ManifestV2 */
tsMod: (_state, getters) => (mod: ManifestV2): ThunderstoreMod | undefined => {
return getters.cachedMod(mod).tsMod;
},

undeprecatedModCount(state) {
return [...state.deprecated].filter(([_, isDeprecated]) => !isDeprecated).length;
}
},

Expand Down

0 comments on commit f364fae

Please sign in to comment.