"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7305/react/features/base/flags/reducer.ts" (26 May 2023, 925 Bytes) of package /linux/misc/jitsi-meet-7305.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import _ from 'lodash';
    2 
    3 import ReducerRegistry from '../redux/ReducerRegistry';
    4 
    5 import { UPDATE_FLAGS } from './actionTypes';
    6 
    7 /**
    8  * Default state value for the feature flags.
    9  */
   10 const DEFAULT_STATE = {};
   11 
   12 export interface IFlagsState {
   13     flags?: Object;
   14 }
   15 
   16 /**
   17  * Reduces redux actions which handle feature flags.
   18  *
   19  * @param {State} state - The current redux state.
   20  * @param {Action} action - The redux action to reduce.
   21  * @param {string} action.type - The type of the redux action to reduce.
   22  * @returns {State} The next redux state that is the result of reducing the
   23  * specified action.
   24  */
   25 ReducerRegistry.register<IFlagsState>('features/base/flags', (state = DEFAULT_STATE, action): IFlagsState => {
   26     switch (action.type) {
   27     case UPDATE_FLAGS: {
   28         const newState = _.merge({}, state, action.flags);
   29 
   30         return _.isEqual(state, newState) ? state : newState;
   31     }
   32     }
   33 
   34     return state;
   35 });