index.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. const createReducer = (handlers: { [key: string]: any }) => (
  6. state: Record<string, any>,
  7. action: { type: string }
  8. ): any => {
  9. if (!Object.prototype.hasOwnProperty.call(handlers, action.type)) {
  10. return state;
  11. }
  12. return handlers[action.type](state, action);
  13. };
  14. export default createReducer({
  15. [types.TOGGLE_DISPLAY_MODE]: mainActions.toggleDisplayMode,
  16. [types.SET_NAVBAR]: mainActions.setNavbarState,
  17. [types.SET_SIDEBAR]: mainActions.setSidebarState,
  18. [types.SET_TOOL]: mainActions.setTool,
  19. [types.SET_INFO]: mainActions.setInfo,
  20. [types.SET_LOADING]: mainActions.setLoading,
  21. [types.SET_CURRENT_PAGE]: pdfActions.setCurrentPage,
  22. [types.SET_TOTAL_PAGE]: pdfActions.setTotalPage,
  23. [types.SET_PDF]: pdfActions.setPdf,
  24. [types.SET_PROGRESS]: pdfActions.setProgress,
  25. [types.SET_VIEWPORT]: pdfActions.setViewport,
  26. [types.CHANGE_SCALE]: pdfActions.changeScale,
  27. [types.CHANGE_ROTATE]: pdfActions.changeRotate,
  28. [types.ADD_ANNOTS]: pdfActions.addAnnotation,
  29. [types.UPDATE_ANNOTS]: pdfActions.updateAnnotation,
  30. [types.UPDATE_WATERMARK]: pdfActions.updateWatermark,
  31. [types.SET_TEXT_DIV]: pdfActions.setTextDivs,
  32. [types.SET_QUERY_STRING]: searchActions.setQueryString,
  33. [types.SET_CURRENT_INDEX]: searchActions.setCurrentIndex,
  34. [types.SET_MATCHES_MAP]: searchActions.setMatchesMap,
  35. });