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

reducer.ts 1.7KB

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