UNPKG

@playkit-js/playkit-js-ui

Version:

[![Build Status](https://github.com/kaltura/playkit-js-ui/actions/workflows/run_canary_full_flow.yaml/badge.svg)](https://github.com/kaltura/playkit-js-ui/actions/workflows/run_canary_full_flow.yaml) [![code style: prettier](https://img.shields.io/badge/c

68 lines (63 loc) 1.69 kB
/* eslint-disable @typescript-eslint/explicit-function-return-type */ import {mergeDeep} from '../utils/merge-deep'; import {UIOptionsObject} from '../types'; import {ConfigState} from '../types/reducers/config'; export const types = { UPDATE: 'config/UPDATE', UPDATE_COMPONENT: 'config/UPDATE_COMPONENT', RESET: 'config/RESET' }; export const initialState = { targetId: undefined as unknown as string, forceTouchUI: false, showCCButton: true, openMenuFromCCButton: false, settings: { showAudioMenu: true, showCaptionsMenu: true, showQualityMenu: true, showSpeedMenu: true, showAdvancedAudioDescToggle: false, showAdvancedCaptionsMenu: true }, hoverTimeout: 3000, tinySizeDisabled: false, components: { watermark: {} as any, seekbar: {} as any, vrStereo: {} as any, logo: {} as any, fullscreen: {} as any, sidePanels: {} as any } }; export default (state: ConfigState = initialState, action: any) => { switch (action.type) { case types.UPDATE: { const config = mergeDeep({}, state, action.config); return { ...state, ...config }; } case types.UPDATE_COMPONENT: { return { ...state, components: { ...state.components, [action.componentAlias]: mergeDeep({}, state.components![action.componentAlias], action.config) } }; } default: return state; } }; export const actions = { updateConfig: (config: any) => ({type: types.UPDATE, config}), updateComponentConfig: (componentAlias: string, config: UIOptionsObject) => ({ type: types.UPDATE_COMPONENT, componentAlias, config }) };