Skip to content

Commit fc95df9

Browse files
Add reset action to vuex store to reset profile data when GameSelectionScreen is created
1 parent ca35974 commit fc95df9

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/pages/GameSelectionScreen.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ export default class GameSelectionScreen extends Vue {
326326
await this.$store.dispatch('checkMigrations');
327327
this.runningMigration = false;
328328
329+
await this.$store.dispatch('resetProfileModule');
329330
this.settings = await ManagerSettings.getSingleton(GameManager.defaultGame);
330331
const globalSettings = this.settings.getContext().global;
331332
this.favourites = globalSettings.favouriteGames || [];

src/store/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ export const store = {
6868
const settings = await ManagerSettings.getSingleton(game);
6969
commit('setSettings', settings);
7070
return settings;
71+
},
72+
73+
// TODO: Add reset actions for other modules
74+
async resetProfileModule({dispatch}: Context) {
75+
return await dispatch('profile/reset');
7176
}
7277
},
7378
mutations: {

src/store/modules/ProfileModule.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ export default {
119119
},
120120

121121
mutations: {
122+
resetLocalState(state: State) {
123+
state.activeProfile = null;
124+
state.modList = [];
125+
state.order = undefined;
126+
state.direction = undefined;
127+
state.disabledPosition = undefined;
128+
state.searchQuery = '';
129+
state.dismissedUpdateAll = false;
130+
},
131+
122132
dismissUpdateAll(state: State) {
123133
state.dismissedUpdateAll = true;
124134
},
@@ -292,6 +302,11 @@ export default {
292302
commit('setDisabledPosition', settings.getInstalledDisablePosition());
293303
},
294304

305+
async reset({commit, rootGetters}) {
306+
await rootGetters['settings'].setProfile('Default');
307+
commit('resetLocalState');
308+
},
309+
295310
async resolveConflicts(
296311
{},
297312
params: {

0 commit comments

Comments
 (0)