Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

reducer.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {
  2. SET_AUDIO_INPUT_DEVICE,
  3. SET_VIDEO_INPUT_DEVICE,
  4. UPDATE_DEVICE_LIST
  5. } from './actionTypes';
  6. import { groupDevicesByKind } from './functions';
  7. import { ReducerRegistry } from '../redux';
  8. const DEFAULT_STATE = {
  9. audioInput: [],
  10. audioOutput: [],
  11. videoInput: []
  12. };
  13. /**
  14. * Listen for actions which changes the state of known and used devices.
  15. *
  16. * @param {Object} state - The Redux state of the feature features/base/devices.
  17. * @param {Object} action - Action object.
  18. * @param {string} action.type - Type of action.
  19. * @param {Array<MediaDeviceInfo>} action.devices - All available audio and
  20. * video devices.
  21. * @returns {Object}
  22. */
  23. ReducerRegistry.register(
  24. 'features/base/devices',
  25. (state = DEFAULT_STATE, action) => {
  26. switch (action.type) {
  27. case UPDATE_DEVICE_LIST: {
  28. const deviceList = groupDevicesByKind(action.devices);
  29. return {
  30. ...deviceList
  31. };
  32. }
  33. // TODO: Changing of current audio and video device id is currently
  34. // handled outside of react/redux. Fall through to default logic for
  35. // now.
  36. case SET_AUDIO_INPUT_DEVICE:
  37. case SET_VIDEO_INPUT_DEVICE:
  38. default:
  39. return state;
  40. }
  41. });