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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* @flow */
  2. // FIXME: Using '../config/actionTypes' instead of '../config' is a quick fix
  3. // for the dial-in info page. Importing '../config' results in JitsiMeetJS
  4. // undefined error (/base/config imports /app which import /lib-jitsi-meet/).
  5. import { SET_CONFIG } from '../config/actionTypes';
  6. import { MiddlewareRegistry } from '../redux';
  7. declare var APP: Object;
  8. /**
  9. * The redux middleware of the feature base/i18n.
  10. *
  11. * @param {Store} store - The redux store.
  12. * @returns {Function}
  13. * @private
  14. */
  15. MiddlewareRegistry.register(store => next => action => {
  16. switch (action.type) {
  17. case SET_CONFIG:
  18. return _setConfig(store, next, action);
  19. }
  20. return next(action);
  21. });
  22. /**
  23. * Notifies the feature base/i18n that the action SET_CONFIG is being dispatched
  24. * within a specific redux store.
  25. *
  26. * @param {Store} store - The redux store in which the specified action is being
  27. * dispatched.
  28. * @param {Dispatch} next - The redux dispatch function to dispatch the
  29. * specified action to the specified store.
  30. * @param {Action} action - The redux action SET_CONFIG which is being
  31. * dispatched in the specified store.
  32. * @private
  33. * @returns {Object} The new state that is the result of the reduction of the
  34. * specified action.
  35. */
  36. function _setConfig({ getState }, next, action) {
  37. const oldValue = getState()['features/base/config'];
  38. const result = next(action);
  39. const newValue = getState()['features/base/config'];
  40. if (oldValue !== newValue && typeof APP === 'object') {
  41. APP.translation.init();
  42. }
  43. return result;
  44. }