Skip to content

Commit

Permalink
Improve search reducer by adding the batching property in the search …
Browse files Browse the repository at this point in the history
…store
  • Loading branch information
sneridagh committed Jul 11, 2018
1 parent b071f68 commit 07c20f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* Replace DraftJS Toolbar plugin H1/H2 buttons for H2/H3 ones @sneridagh
* Sync i18n translations @sneridagh
* Fix CSS .input class scope intrusion on the project introduced by the AnchorLink plugin fork @sneridagh
* Improve search reducer by adding the batching property in the search store.

## 0.5.0 (2018-03-23)

Expand Down
6 changes: 6 additions & 0 deletions src/reducers/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const initialState = {
total: 0,
loaded: false,
loading: false,
batching: {},
};

/**
Expand All @@ -34,6 +35,8 @@ export default function search(state = initialState, action = {}) {
error: null,
loading: true,
loaded: false,
batching: {},
total: 0,
};
case `${SEARCH_CONTENT}_SUCCESS`:
return {
Expand All @@ -46,6 +49,7 @@ export default function search(state = initialState, action = {}) {
total: action.result.items_total,
loaded: true,
loading: false,
...action.result.batching,
};
case `${SEARCH_CONTENT}_FAIL`:
return {
Expand All @@ -55,6 +59,7 @@ export default function search(state = initialState, action = {}) {
total: 0,
loading: false,
loaded: false,
batching: {},
};
case RESET_SEARCH_CONTENT:
return {
Expand All @@ -64,6 +69,7 @@ export default function search(state = initialState, action = {}) {
total: 0,
loading: false,
loaded: false,
batching: {},
};
default:
return state;
Expand Down
6 changes: 6 additions & 0 deletions src/reducers/search/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Search reducer', () => {
total: 0,
loaded: false,
loading: false,
batching: {},
});
});

Expand All @@ -27,6 +28,7 @@ describe('Search reducer', () => {
total: 0,
loaded: false,
loading: true,
batching: {},
});
});

Expand All @@ -42,6 +44,7 @@ describe('Search reducer', () => {
},
],
items_total: 1,
batching: {},
},
}),
).toEqual({
Expand All @@ -55,6 +58,7 @@ describe('Search reducer', () => {
total: 1,
loaded: true,
loading: false,
batching: {},
});
});

Expand All @@ -70,6 +74,7 @@ describe('Search reducer', () => {
total: 0,
loaded: false,
loading: false,
batching: {},
});
});

Expand All @@ -84,6 +89,7 @@ describe('Search reducer', () => {
total: 0,
loaded: false,
loading: false,
batching: {},
});
});
});

0 comments on commit 07c20f5

Please sign in to comment.