2022-09-01 11:32:01 +03:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2018-03-06 16:28:19 -08:00
|
|
|
|
2024-08-26 11:53:54 -05:00
|
|
|
import {
|
|
|
|
|
RESET_SHARED_VIDEO_STATUS,
|
2024-08-26 14:49:34 -05:00
|
|
|
SET_ALLOWED_URL_DOMAINS,
|
2024-08-27 10:45:39 -05:00
|
|
|
SET_CONFIRM_SHOW_VIDEO,
|
2024-08-26 11:53:54 -05:00
|
|
|
SET_DISABLE_BUTTON,
|
2024-08-26 14:49:34 -05:00
|
|
|
SET_SHARED_VIDEO_STATUS
|
2024-08-26 11:53:54 -05:00
|
|
|
} from './actionTypes';
|
2024-08-26 14:49:34 -05:00
|
|
|
import { DEFAULT_ALLOWED_URL_DOMAINS } from './constants';
|
2021-04-16 12:43:34 +03:00
|
|
|
|
2024-08-26 14:49:34 -05:00
|
|
|
const initialState = {
|
|
|
|
|
allowedUrlDomains: DEFAULT_ALLOWED_URL_DOMAINS
|
|
|
|
|
};
|
2018-03-06 16:28:19 -08:00
|
|
|
|
2022-09-01 11:32:01 +03:00
|
|
|
export interface ISharedVideoState {
|
2024-08-26 14:49:34 -05:00
|
|
|
allowedUrlDomains: Array<string>;
|
2024-08-27 10:45:39 -05:00
|
|
|
confirmShowVideo?: boolean;
|
2022-09-01 11:32:01 +03:00
|
|
|
disabled?: boolean;
|
|
|
|
|
muted?: boolean;
|
|
|
|
|
ownerId?: string;
|
|
|
|
|
status?: string;
|
|
|
|
|
time?: number;
|
|
|
|
|
videoUrl?: string;
|
|
|
|
|
volume?: number;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-06 16:28:19 -08:00
|
|
|
/**
|
|
|
|
|
* Reduces the Redux actions of the feature features/shared-video.
|
|
|
|
|
*/
|
2022-09-05 12:05:07 +03:00
|
|
|
ReducerRegistry.register<ISharedVideoState>('features/shared-video',
|
|
|
|
|
(state = initialState, action): ISharedVideoState => {
|
2022-09-01 11:32:01 +03:00
|
|
|
const { videoUrl, status, time, ownerId, disabled, muted, volume } = action;
|
2021-03-03 16:37:38 +02:00
|
|
|
|
2018-03-06 16:28:19 -08:00
|
|
|
switch (action.type) {
|
2021-04-16 12:43:34 +03:00
|
|
|
case RESET_SHARED_VIDEO_STATUS:
|
2024-08-26 14:49:34 -05:00
|
|
|
return {
|
|
|
|
|
...initialState,
|
|
|
|
|
allowedUrlDomains: state.allowedUrlDomains
|
|
|
|
|
};
|
2024-08-27 10:45:39 -05:00
|
|
|
case SET_CONFIRM_SHOW_VIDEO: {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
confirmShowVideo: action.value
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-03-06 16:28:19 -08:00
|
|
|
case SET_SHARED_VIDEO_STATUS:
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
2021-04-16 12:43:34 +03:00
|
|
|
muted,
|
|
|
|
|
ownerId,
|
|
|
|
|
status,
|
|
|
|
|
time,
|
2022-09-01 11:32:01 +03:00
|
|
|
videoUrl,
|
|
|
|
|
volume
|
2021-03-03 16:37:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case SET_DISABLE_BUTTON:
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
disabled
|
2018-03-06 16:28:19 -08:00
|
|
|
};
|
|
|
|
|
|
2024-08-26 14:49:34 -05:00
|
|
|
case SET_ALLOWED_URL_DOMAINS: {
|
2024-08-26 12:32:46 +03:00
|
|
|
return {
|
|
|
|
|
...state,
|
2024-08-26 14:49:34 -05:00
|
|
|
allowedUrlDomains: action.allowedUrlDomains
|
2024-08-26 11:53:54 -05:00
|
|
|
};
|
2024-08-26 12:32:46 +03:00
|
|
|
}
|
|
|
|
|
|
2018-03-06 16:28:19 -08:00
|
|
|
default:
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
});
|