Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ export function uploadInventory() {
validCharacters: charInvState.validCharacters,
})
);
const changes = getState().goalsState.currentGoal.changes as CharInvChanges;
dispatch(addCharInvChangesToGoal({ ...changes, charChanges }));
await dispatch(asyncUpdateGoal());
await dispatch(addCharChanges(charChanges));
};
}

Expand Down Expand Up @@ -172,6 +170,20 @@ export function loadCharInvData() {
};
}

/** Returns a dispatch function to: in both frontend and backend, add to the current
* goal's changes new character inventory status changes. */
function addCharChanges(charChanges: CharacterChange[]) {
return async (dispatch: StoreStateDispatch, getState: () => StoreState) => {
const changes: CharInvChanges = {
...defaultCharInvChanges,
...getState().goalsState.currentGoal.changes,
};
changes.charChanges = [...changes.charChanges, ...charChanges];
dispatch(addCharInvChangesToGoal(changes));
await dispatch(asyncUpdateGoal());
};
}

/** Returns a dispatch function to: in both frontend and backend, add to the current
* goal's changes the dictionary of words updated with the find-and-replace tool. */
function addWordChanges(wordChanges: FindAndReplaceChange) {
Expand Down
Loading