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

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