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.

reducer.ts 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import { UPDATE_LOCAL_TRACKS_DURATION } from './actionTypes';
  3. /**
  4. * Initial state.
  5. */
  6. const DEFAULT_STATE = {
  7. localTracksDuration: {
  8. audio: {
  9. startedTime: -1,
  10. value: 0
  11. },
  12. video: {
  13. camera: {
  14. startedTime: -1,
  15. value: 0
  16. },
  17. desktop: {
  18. startedTime: -1,
  19. value: 0
  20. }
  21. },
  22. conference: {
  23. startedTime: -1,
  24. value: 0
  25. }
  26. }
  27. };
  28. interface Value {
  29. startedTime: number,
  30. value: number
  31. }
  32. export interface IAnalyticsState {
  33. localTracksDuration: {
  34. audio: Value,
  35. conference: Value,
  36. video: {
  37. camera: Value,
  38. desktop: Value
  39. }
  40. }
  41. }
  42. /**
  43. * Listen for actions which changes the state of the analytics feature.
  44. *
  45. * @param {Object} state - The Redux state of the feature features/analytics.
  46. * @param {Object} action - Action object.
  47. * @param {string} action.type - Type of action.
  48. * @returns {Object}
  49. */
  50. ReducerRegistry.register('features/analytics', (state: IAnalyticsState = DEFAULT_STATE, action: any) => {
  51. switch (action.type) {
  52. case UPDATE_LOCAL_TRACKS_DURATION:
  53. return {
  54. ...state,
  55. localTracksDuration: action.localTracksDuration
  56. };
  57. default:
  58. return state;
  59. }
  60. });