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 Sep 5, 2024
1 parent 49ab15c commit 5aa8b0e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion src/pages/Profiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class Profiles extends ProfilesMixin {
const settings = await this.$store.getters.settings;
await settings.load();
const lastProfileName = await this.$store.dispatch('profile/loadLastSelectedProfile');
const lastProfileName = "Default";
// If the view was entered via game selection, the mod list was updated
// and the cache cleared. The profile is already set in the Vuex store
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 @@ -14,6 +14,7 @@ import ManagerSettings from '../../r2mm/manager/ManagerSettings';
import ModListSort from '../../r2mm/mods/ModListSort';
import ProfileModList from '../../r2mm/mods/ProfileModList';
import SearchUtils from '../../utils/SearchUtils';
import GameManager from "../../model/game/GameManager";

interface State {
activeProfile: Profile | null;
Expand Down Expand Up @@ -119,6 +120,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 +303,10 @@ export default {
commit('setDisabledPosition', settings.getInstalledDisablePosition());
},

async reset({commit}) {
commit('resetLocalState');
},

async resolveConflicts(
{},
params: {
Expand Down

0 comments on commit 5aa8b0e

Please sign in to comment.