Skip to content

Commit 82bee05

Browse files
authored
[CharInv] Preserve pre-find-and-replace status changes in goal history (#4041)
1 parent e658c44 commit 82bee05

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ export function uploadInventory() {
118118
validCharacters: charInvState.validCharacters,
119119
})
120120
);
121-
const changes = getState().goalsState.currentGoal.changes as CharInvChanges;
122-
dispatch(addCharInvChangesToGoal({ ...changes, charChanges }));
123-
await dispatch(asyncUpdateGoal());
121+
await dispatch(addCharChanges(charChanges));
124122
};
125123
}
126124

@@ -172,6 +170,20 @@ export function loadCharInvData() {
172170
};
173171
}
174172

173+
/** Returns a dispatch function to: in both frontend and backend, add to the current
174+
* goal's changes new character inventory status changes. */
175+
function addCharChanges(charChanges: CharacterChange[]) {
176+
return async (dispatch: StoreStateDispatch, getState: () => StoreState) => {
177+
const changes: CharInvChanges = {
178+
...defaultCharInvChanges,
179+
...getState().goalsState.currentGoal.changes,
180+
};
181+
changes.charChanges = [...changes.charChanges, ...charChanges];
182+
dispatch(addCharInvChangesToGoal(changes));
183+
await dispatch(asyncUpdateGoal());
184+
};
185+
}
186+
175187
/** Returns a dispatch function to: in both frontend and backend, add to the current
176188
* goal's changes the dictionary of words updated with the find-and-replace tool. */
177189
function addWordChanges(wordChanges: FindAndReplaceChange) {

0 commit comments

Comments
 (0)