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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import {
  3. RESET_SHARED_VIDEO_STATUS,
  4. SET_ALLOWED_URL_DOMAINS,
  5. SET_DISABLE_BUTTON,
  6. SET_SHARED_VIDEO_STATUS
  7. } from './actionTypes';
  8. import { DEFAULT_ALLOWED_URL_DOMAINS } from './constants';
  9. const initialState = {
  10. allowedUrlDomains: DEFAULT_ALLOWED_URL_DOMAINS
  11. };
  12. export interface ISharedVideoState {
  13. allowedUrlDomains: Array<string>;
  14. disabled?: boolean;
  15. muted?: boolean;
  16. ownerId?: string;
  17. status?: string;
  18. time?: number;
  19. videoUrl?: string;
  20. volume?: number;
  21. }
  22. /**
  23. * Reduces the Redux actions of the feature features/shared-video.
  24. */
  25. ReducerRegistry.register<ISharedVideoState>('features/shared-video',
  26. (state = initialState, action): ISharedVideoState => {
  27. const { videoUrl, status, time, ownerId, disabled, muted, volume } = action;
  28. switch (action.type) {
  29. case RESET_SHARED_VIDEO_STATUS:
  30. return {
  31. ...initialState,
  32. allowedUrlDomains: state.allowedUrlDomains
  33. };
  34. case SET_SHARED_VIDEO_STATUS:
  35. return {
  36. ...state,
  37. muted,
  38. ownerId,
  39. status,
  40. time,
  41. videoUrl,
  42. volume
  43. };
  44. case SET_DISABLE_BUTTON:
  45. return {
  46. ...state,
  47. disabled
  48. };
  49. case SET_ALLOWED_URL_DOMAINS: {
  50. return {
  51. ...state,
  52. allowedUrlDomains: action.allowedUrlDomains
  53. };
  54. }
  55. default:
  56. return state;
  57. }
  58. });