aboutsummaryrefslogtreecommitdiffstats
path: root/ui/imports/ui/reducers/search-interested-parties.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/imports/ui/reducers/search-interested-parties.js')
-rw-r--r--ui/imports/ui/reducers/search-interested-parties.js68
1 files changed, 0 insertions, 68 deletions
diff --git a/ui/imports/ui/reducers/search-interested-parties.js b/ui/imports/ui/reducers/search-interested-parties.js
deleted file mode 100644
index f4963d2..0000000
--- a/ui/imports/ui/reducers/search-interested-parties.js
+++ /dev/null
@@ -1,68 +0,0 @@
-import * as R from 'ramda';
-
-import * as actions from '/imports/ui/actions/search-interested-parties';
-
-const defaultState = {
- listeners: [],
- searchTerm: null,
- searchAutoCompleteTerm: null,
- searchAutoCompleteFutureId: null
-};
-
-function reducer(state = defaultState, action) {
- let newListeners;
-
- switch (action.type) {
- case actions.ADD_SEARCH_INTERESTED_PARTY:
- newListeners = R.unionWith(
- R.eqBy(R.prop('action')),
- state.listeners,
- [{ action: action.payload.listener }]);
- return R.assoc('listeners', newListeners, state);
-
- case actions.REMOVE_SEARCH_INTERESTED_PARTY:
- newListeners = R.differenceWith(
- R.eqBy(R.prop('action')),
- state.listeners,
- [{ action:action.payload.listener }]);
- return R.assoc('listeners', newListeners, state);
-
- case actions.SET_SEARCH_TERM:
- asyncCall(() => {
- notifyListeners(action.payload.searchTerm, state.listeners);
- });
- return R.assoc('searchTerm', action.payload.searchTerm, state);
-
- case actions.SET_SEARCH_AUTO_COMPLETE_TERM:
- return R.assoc('searchAutoCompleteTerm', action.payload.searchTerm, state);
-
- case actions.RESET_SEARCH_AUTO_COMPLETE_FUTURE:
- if (! R.isNil(state.searchAutoCompleteFutureId)) {
- clearTimeout(state.searchAutoCompleteFutureId);
- }
- return R.assoc('searchAutoCompleteFutureId', null, state);
-
- case actions.SET_SEARCH_AUTO_COMPLETE_FUTURE:
- if (! R.isNil(state.searchAutoCompleteFutureId)) {
- clearTimeout(state.searchAutoCompleteFutureId);
- }
- return R.assoc('searchAutoCompleteFutureId', action.payload.futureId, state);
-
- default:
- return state;
- }
-}
-
-function asyncCall(fnObject) {
- setTimeout(() => {
- fnObject.call(null);
- }, 0);
-}
-
-function notifyListeners(searchTerm, listeners) {
- R.forEach((listenerItem) => {
- listenerItem.action.call(null, searchTerm);
- }, listeners);
-}
-
-export const searchInterestedParties = reducer;