Skip to content

Commit

Permalink
Rotation and talent state now properly replaced in UI instead of merg…
Browse files Browse the repository at this point in the history
…ed on update

Resolves #48
  • Loading branch information
secretbis committed Apr 18, 2021
1 parent 00861c0 commit 8148d28
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ function App() {

function onSimClick() {
dispatch({ type: 'iterationResults', value: null })
dispatch({ type: 'resultsResourceUsageByAbility', value: null })
dispatch({ type: 'resultsByBuff', value: null })
dispatch({ type: 'resultsByDebuff', value: null })
dispatch({ type: 'resultsByDamageType', value: null })
dispatch({ type: 'resultsByAbility', value: null })
dispatch({ type: 'resultsDps', value: null })
sim()
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/rankings/rankings.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const RankingBarChart = ({ data }) => (
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: 'DPS',
legend: 'DPS (3 minutes)',
itemTextColor: '#fff',
legendPosition: 'middle',
legendOffset: -40
Expand Down
2 changes: 1 addition & 1 deletion ui/src/rotation/rotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function({ rotation, dispatch }) {
try {
const parsed = JSON.parse(rotationStr);
setJsonValid(true);
dispatch({ type: 'character.rotation', value: parsed });
dispatch({ type: 'setRotation', value: parsed });
} catch(e) {
setJsonValid(false);
}
Expand Down
18 changes: 17 additions & 1 deletion ui/src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,23 @@ export function stateReducer(state, action) {
[action.value.name]: action.value.value
}
}
} else {
} else if(action.type == 'setRotation') {
newState = {
...state,
character: {
...state.character,
rotation: action.value
}
}
} else if(action.type == 'setTalents') {
newState = {
...state,
character: {
...state.character,
talents: action.value
}
}
} else {
console.warn(`Unhandled action type: ${action.type}`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/talents/talents.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function({ talents, dispatch }) {
try {
const parsed = JSON.parse(talentsStr);
setJsonValid(true);
dispatch({ type: 'character.talents', value: parsed });
dispatch({ type: 'setRotation', value: parsed });
} catch(e) {
setJsonValid(false);
}
Expand Down

0 comments on commit 8148d28

Please sign in to comment.