Skip to content

Commit 9251136

Browse files
Add data resetting to vuex storage modules and use the functionality in page components
1 parent 762be48 commit 9251136

File tree

7 files changed

+28
-13
lines changed

7 files changed

+28
-13
lines changed

src/pages/GameSelectionScreen.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ export default class GameSelectionScreen extends Vue {
327327
await this.$store.dispatch('checkMigrations');
328328
this.runningMigration = false;
329329
330-
await this.$store.dispatch('resetProfileModule');
330+
await this.$store.dispatch('resetLocalState');
331+
331332
this.settings = await ManagerSettings.getSingleton(GameManager.defaultGame);
332333
const globalSettings = this.settings.getContext().global;
333334
this.favourites = globalSettings.favouriteGames || [];

src/pages/Profiles.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export default class Profiles extends ProfilesMixin {
115115
const settings = await this.$store.getters.settings;
116116
await settings.load();
117117
118+
await this.$store.commit('modFilters/reset');
119+
await this.$store.commit('tsMods/reset');
120+
await this.$store.commit('profile/reset');
121+
118122
const lastProfileName = await this.$store.dispatch('profile/loadLastSelectedProfile');
119123
120124
// If the view was entered via game selection, the mod list was updated

src/store/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ export const store = {
7070
return settings;
7171
},
7272

73-
// TODO: Add reset actions for other modules
74-
async resetProfileModule({dispatch}: Context) {
75-
return await dispatch('profile/reset');
76-
}
73+
async resetLocalState({commit}: Context) {
74+
return await Promise.all([
75+
commit('profile/reset'),
76+
commit('profiles/reset'),
77+
commit('tsMods/reset'),
78+
commit('modFilters/reset'),
79+
])
80+
},
7781
},
7882
mutations: {
7983
setActiveGame(state: State, game: Game) {

src/store/modules/ModFilterModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GetterTree } from 'vuex';
1+
import { ActionTree, GetterTree } from 'vuex';
22

33
import { State as RootState } from '../index';
44

@@ -11,7 +11,7 @@ interface State {
1111
}
1212

1313
/**
14-
* State for OnlineModList, i.e. list for all the mods available on Thunderstore.
14+
* State for ModFilter, i.e. filters for mod listings.
1515
*/
1616
export default {
1717
namespaced: true,

src/store/modules/ProfileModule.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import ManagerSettings from '../../r2mm/manager/ManagerSettings';
1414
import ModListSort from '../../r2mm/mods/ModListSort';
1515
import ProfileModList from '../../r2mm/mods/ProfileModList';
1616
import SearchUtils from '../../utils/SearchUtils';
17-
import GameManager from "../../model/game/GameManager";
1817

1918
interface State {
2019
activeProfile: Profile | null;
@@ -120,7 +119,7 @@ export default {
120119
},
121120

122121
mutations: {
123-
resetLocalState(state: State) {
122+
reset(state: State) {
124123
state.modList = [];
125124
state.order = undefined;
126125
state.direction = undefined;
@@ -302,10 +301,6 @@ export default {
302301
commit('setDisabledPosition', settings.getInstalledDisablePosition());
303302
},
304303

305-
async reset({commit}) {
306-
commit('resetLocalState');
307-
},
308-
309304
async resolveConflicts(
310305
{},
311306
params: {

src/store/modules/ProfilesModule.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export const ProfilesModule = {
2323
setProfileList(state: State, profileList: string[]) {
2424
state.profileList = profileList;
2525
},
26+
reset(state: State) {
27+
state.profileList = ['Default'];
28+
},
2629
},
2730
actions: <ActionTree<State, RootState>>{
2831
async addProfile({rootGetters, state, dispatch}, name: string) {

src/store/modules/TsModsModule.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ export const TsModsModule = {
116116
},
117117

118118
mutations: <MutationTree<State>>{
119+
reset(state: State) {
120+
state.cache = new Map<string, CachedMod>();
121+
state.connectionError = '';
122+
state.deprecated = new Map<string, boolean>();
123+
state.exclusions = [];
124+
state.mods = [];
125+
state.modsLastUpdated = undefined;
126+
},
119127
clearModCache(state) {
120128
state.cache.clear();
121129
},

0 commit comments

Comments
 (0)