-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The module will hold the list of all mods available on Thunderstore API for the current active game, and provide helpers related to that data.
- Loading branch information
Showing
12 changed files
with
83 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { ActionTree, GetterTree, MutationTree } from 'vuex'; | ||
|
||
import { State as RootState } from '../index'; | ||
import ManifestV2 from '../../model/ManifestV2'; | ||
import ThunderstoreMod from '../../model/ThunderstoreMod'; | ||
import ThunderstoreDownloaderProvider from '../../providers/ror2/downloading/ThunderstoreDownloaderProvider'; | ||
import ThunderstorePackages from '../../r2mm/data/ThunderstorePackages'; | ||
|
||
|
||
interface State { | ||
deprecated: Map<string, boolean>; | ||
mods: ThunderstoreMod[]; | ||
} | ||
|
||
/** | ||
* For dealing with mods listed in communities, i.e. available through | ||
* the Thunderstore API. Mods received from the API are stored in | ||
* IndexedDB (via Dexie). For performance they're also stored in memory | ||
* by this Vuex store module. | ||
*/ | ||
export const TsModsModule = { | ||
namespaced: true, | ||
|
||
state: (): State => ({ | ||
deprecated: new Map<string, boolean>(), | ||
/*** All mods available through API for the current active game */ | ||
mods: [], | ||
}), | ||
|
||
getters: <GetterTree<State, RootState>>{ | ||
/*** Categories used by any mod listed in the community */ | ||
categories(state) { | ||
const categories = Array.from( | ||
new Set( | ||
state.mods.map((mod) => mod.getCategories()).flat() | ||
) | ||
); | ||
categories.sort(); | ||
return categories; | ||
}, | ||
|
||
/*** Which locally installed mods have updates in Thunderstore? */ | ||
modsWithUpdates: (state) => (profileMods: ManifestV2[]) => { | ||
return ThunderstoreDownloaderProvider.instance.getLatestOfAllToUpdate( | ||
profileMods, | ||
state.mods | ||
); | ||
} | ||
}, | ||
|
||
mutations: <MutationTree<State>>{ | ||
setMods(state, payload: ThunderstoreMod[]) { | ||
state.mods = payload; | ||
}, | ||
updateDeprecated(state) { | ||
state.deprecated = ThunderstorePackages.getDeprecatedPackageMap(); | ||
} | ||
}, | ||
|
||
actions: <ActionTree<State, RootState>>{ | ||
updateMods({commit}, modList: ThunderstoreMod[]) { | ||
commit('setMods', modList); | ||
commit('updateDeprecated'); | ||
} | ||
} | ||
} |