Skip to content

Commit

Permalink
Fix incorrect modified state in custom list editor following save. (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-lee authored Oct 12, 2022
1 parent 2cb3714 commit acb6efa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

### v0.4.1

#### Fixed

- After an auto updating list is saved, the list status is now correctly updated, and the Save button is now correctly disabled.

### v0.4.0

#### Updated
Expand Down
17 changes: 17 additions & 0 deletions src/reducers/__tests__/customListEditor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,23 @@ describe("custom list editor reducer", () => {
expect(nextState).to.equal(state);
});

it("sets isSearchModified and isModified to false", () => {
const state = {
...initialState,
id: 42,
isSearchModified: true,
isModified: true,
};

const nextState = reducer(state, {
type: `${ActionCreator.CUSTOM_LISTS}_${ActionCreator.LOAD}`,
data: listData,
});

expect(nextState.isSearchModified).to.equal(false);
expect(nextState.isModified).to.equal(false);
});

context("when auto update is enabled", () => {
it("defaults the autoUpdate property to true for a new list", () => {
const state = {
Expand Down
29 changes: 15 additions & 14 deletions src/reducers/customListEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ const initialStateForList = (
draftState.searchParams.baseline.sort = order;
draftState.searchParams.current.sort = order;
}

draftState.isSearchModified = false;
}

draftState.error = error;
Expand Down Expand Up @@ -955,23 +957,22 @@ const handleCustomListEditorOpen = (
* to the id of a list that is present in the data.
* @returns The next state
*/
const handleCustomListsLoad = (
state: CustomListEditorState,
action
): CustomListEditorState => {
if (action.isAfterShare) {
// If this is a reload of custom list data following a share operation, we can ignore the
// action. The sharing state will be updated by the handler for the CUSTOM_LIST_SHARE_SUCCESS
// action.
const handleCustomListsLoad = validatedHandler(
(state: CustomListEditorState, action): CustomListEditorState => {
if (action.isAfterShare) {
// If this is a reload of custom list data following a share operation, we can ignore the
// action. The sharing state will be updated by the handler for the CUSTOM_LIST_SHARE_SUCCESS
// action.

return state;
}
return state;
}

const { id } = state;
const { data } = action;
const { id } = state;
const { data } = action;

return initialStateForList(id, data, state);
};
return initialStateForList(id, data, state);
}
);

/**
* Handle the CUSTOM_LIST_DETAILS_LOAD action. This action is fired when a call to the
Expand Down

0 comments on commit acb6efa

Please sign in to comment.