Skip to content

Commit

Permalink
Refactor: Consolidate setQueryParam
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon committed Sep 30, 2024
1 parent 4aea486 commit bbc506f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
2 changes: 0 additions & 2 deletions src/components/nav/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
import { changeGameMode, getExpertMode, getGameMode } from '../../state/slices/userSettings';
import data from '../../utils/data';
import { PROFESSIONS } from '../../utils/gw2-data';
import { PARAMS, setQueryParm } from '../../utils/queryParam';
import NavAccordion from './NavAccordion';
import NavSettings from './NavSettings';
import ReapplyTemplateDialog from './ReapplyTemplateDialog';
Expand Down Expand Up @@ -99,7 +98,6 @@ const Navbar = () => {
// only cycles between raids and fractals
const newGameMode = gamemode === 'raids' ? 'fractals' : 'raids';

setQueryParm({ key: PARAMS.GAMEMODE, value: newGameMode });
dispatch(changeGameMode(newGameMode));

const isFractalsNew = newGameMode === 'fractals';
Expand Down
2 changes: 0 additions & 2 deletions src/components/nav/NavSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
getExpertMode,
getGameMode,
} from '../../state/slices/userSettings';
import { PARAMS, setQueryParm } from '../../utils/queryParam';
import LanguageSelection from '../baseComponents/LanguageSelection';
import Settings from '../baseComponents/Settings';
import ReapplyTemplateDialog from './ReapplyTemplateDialog';
Expand Down Expand Up @@ -94,7 +93,6 @@ export default function NavSettings({
};
const changeGameModeHandler = (e) => {
const newGameMode = e.target.value;
setQueryParm({ key: PARAMS.GAMEMODE, value: newGameMode });
dispatch(changeGameMode(newGameMode));

const isFractalsNew = newGameMode === 'fractals';
Expand Down
1 change: 1 addition & 0 deletions src/state/slices/userSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const userSettingsSlice = createSlice({
},
changeGameMode: (state, action: PayloadAction<GameMode>) => {
state.gameMode = action.payload;
setQueryParm({ key: PARAMS.GAMEMODE, value: action.payload });
},
},

Expand Down

0 comments on commit bbc506f

Please sign in to comment.