index.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import * as mainActions from './main';
  2. import * as pdfActions from './pdf';
  3. import * as searchActions from './search';
  4. import * as types from '../constants/actionTypes';
  5. import { StateType } from '../store';
  6. const createReducer = (handlers: Record<string, ReducerFuncType>) => (
  7. state: StateType,
  8. action: DispatchObjType,
  9. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  10. ): any => {
  11. if (!Object.prototype.hasOwnProperty.call(handlers, action.type)) {
  12. return state;
  13. }
  14. return handlers[action.type](state, action);
  15. };
  16. export default createReducer({
  17. [types.TOGGLE_DISPLAY_MODE]: mainActions.toggleDisplayMode,
  18. [types.SET_NAVBAR]: mainActions.setNavbarState,
  19. [types.SET_SIDEBAR]: mainActions.setSidebarState,
  20. [types.SET_TOOL]: mainActions.setTool,
  21. [types.SET_INFO]: mainActions.setInfo,
  22. [types.SET_LOADING]: mainActions.setLoading,
  23. [types.SET_CURRENT_PAGE]: pdfActions.setCurrentPage,
  24. [types.SET_TOTAL_PAGE]: pdfActions.setTotalPage,
  25. [types.SET_PDF]: pdfActions.setPdf,
  26. [types.SET_PROGRESS]: pdfActions.setProgress,
  27. [types.SET_VIEWPORT]: pdfActions.setViewport,
  28. [types.CHANGE_SCALE]: pdfActions.changeScale,
  29. [types.CHANGE_ROTATE]: pdfActions.changeRotate,
  30. [types.ADD_ANNOTS]: pdfActions.addAnnotation,
  31. [types.UPDATE_ANNOTS]: pdfActions.updateAnnotation,
  32. [types.UPDATE_WATERMARK]: pdfActions.updateWatermark,
  33. [types.SET_QUERY_STRING]: searchActions.setQueryString,
  34. [types.SET_CURRENT_INDEX]: searchActions.setCurrentIndex,
  35. [types.SET_MATCHES_MAP]: searchActions.setMatchesMap,
  36. });