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.js 984B

123456789101112131415161718192021222324252627282930313233343536
  1. // @flow
  2. import { UPDATE_DEVICE_LIST } from '../base/devices';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. declare var APP: Object;
  5. /**
  6. * Implements the middleware of the feature device-selection.
  7. *
  8. * @param {Store} store - Redux store.
  9. * @returns {Function}
  10. */
  11. // eslint-disable-next-line no-unused-vars
  12. MiddlewareRegistry.register(store => next => action => {
  13. const result = next(action);
  14. if (action.type === UPDATE_DEVICE_LIST) {
  15. const state = store.getState();
  16. const { popupDialogData } = state['features/device-selection'];
  17. const { availableDevices } = state['features/base/devices'] || {};
  18. if (popupDialogData) {
  19. popupDialogData.transport.sendEvent({
  20. name: 'deviceListChanged',
  21. devices: availableDevices
  22. });
  23. }
  24. if (typeof APP !== 'undefined') {
  25. APP.API.notifyDeviceListChanged(availableDevices);
  26. }
  27. }
  28. return result;
  29. });