Skip to content

Commit

Permalink
Add reset action to vuex store to reset profile data when GameSelecti…
Browse files Browse the repository at this point in the history
…onScreen is created
  • Loading branch information
VilppeRiskidev committed Jul 19, 2024
1 parent ca35974 commit fc95df9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pages/GameSelectionScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export default class GameSelectionScreen extends Vue {
await this.$store.dispatch('checkMigrations');
this.runningMigration = false;
await this.$store.dispatch('resetProfileModule');
this.settings = await ManagerSettings.getSingleton(GameManager.defaultGame);
const globalSettings = this.settings.getContext().global;
this.favourites = globalSettings.favouriteGames || [];
Expand Down
5 changes: 5 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export const store = {
const settings = await ManagerSettings.getSingleton(game);
commit('setSettings', settings);
return settings;
},

// TODO: Add reset actions for other modules
async resetProfileModule({dispatch}: Context) {
return await dispatch('profile/reset');
}
},
mutations: {
Expand Down
15 changes: 15 additions & 0 deletions src/store/modules/ProfileModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ export default {
},

mutations: {
resetLocalState(state: State) {
state.activeProfile = null;
state.modList = [];
state.order = undefined;
state.direction = undefined;
state.disabledPosition = undefined;
state.searchQuery = '';
state.dismissedUpdateAll = false;
},

dismissUpdateAll(state: State) {
state.dismissedUpdateAll = true;
},
Expand Down Expand Up @@ -292,6 +302,11 @@ export default {
commit('setDisabledPosition', settings.getInstalledDisablePosition());
},

async reset({commit, rootGetters}) {
await rootGetters['settings'].setProfile('Default');
commit('resetLocalState');
},

async resolveConflicts(
{},
params: {
Expand Down

0 comments on commit fc95df9

Please sign in to comment.