You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.tsx 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from 'react';
  2. import { AnyAction } from 'redux';
  3. import { IStore } from '../app/types';
  4. import { APP_WILL_MOUNT } from '../base/app/actionTypes';
  5. import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
  6. import { showErrorNotification } from '../notifications/actions';
  7. import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
  8. // @ts-ignore
  9. import { OldElectronAPPNotificationDescription } from './components';
  10. import { isOldJitsiMeetElectronApp } from './functions';
  11. MiddlewareRegistry.register(store => next => action => {
  12. switch (action.type) {
  13. case APP_WILL_MOUNT:
  14. return _appWillMount(store, next, action);
  15. }
  16. return next(action);
  17. });
  18. /**
  19. * Notifies the feature that the action {@link APP_WILL_MOUNT} has being dispatched.
  20. *
  21. * @param {Store} store - The redux store in which the specified {@code action} is being dispatched.
  22. * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the specified {@code action}.
  23. * @param {Action} action - The redux action {@code APP_WILL_MOUNT} which is being dispatched.
  24. * @private
  25. * @returns {Object} The new state that is the result of the reduction of the specified {@code action}.
  26. */
  27. function _appWillMount(store: IStore, next: Function, action: AnyAction) {
  28. if (isOldJitsiMeetElectronApp()) {
  29. const { dispatch } = store;
  30. dispatch(showErrorNotification({
  31. titleKey: 'notify.OldElectronAPPTitle',
  32. description: <OldElectronAPPNotificationDescription />
  33. }, NOTIFICATION_TIMEOUT_TYPE.LONG));
  34. }
  35. return next(action);
  36. }