Permalink
Browse files

Fix a pair of bugs with pilot selection and editing

Fixed bug where editing one pilot and selecting another would apply
edits instead of canceling them completely

Fixed bug where deleting the selected pilot didn't clear out the
currentPilot field.
  • Loading branch information...
markerikson committed Jul 16, 2017
1 parent 70208ea commit 08af9489fcdfe136b384044cb55bd337895b2410
Showing with 8 additions and 4 deletions.
  1. +1 −1 src/features/pilots/pilotsActions.js
  2. +7 −3 src/features/pilots/pilotsReducer.js
@@ -18,7 +18,7 @@ export function selectPilot(pilotID) {
const isEditing = selectIsEditingPilot(state);
if(isEditing) {
dispatch(stopEditingPilot())
dispatch(cancelEditingPilot())
}
dispatch({
@@ -45,10 +45,14 @@ export function stopEditingPilot(state, payload) {
export function stopEditingIfDeleted(state, payload) {
const {itemType, itemID} = payload;
const {isEditing, currentPilot} = state;
const {currentPilot} = state;
if(isEditing && itemType === "Pilot" && itemID === currentPilot) {
return stopEditingPilot(state, payload);
if(itemType === "Pilot" && itemID === currentPilot) {
return {
...state,
isEditing : false,
currentPilot : null
}
}
return state;

0 comments on commit 08af948

Please sign in to comment.