@@ -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. */
177189function addWordChanges ( wordChanges : FindAndReplaceChange ) {
0 commit comments