snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
31
react/features/base/flags/functions.ts
Normal file
31
react/features/base/flags/functions.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { getAppProp } from '../app/functions';
|
||||
import { IStateful } from '../app/types';
|
||||
import { toState } from '../redux/functions';
|
||||
|
||||
/**
|
||||
* Gets the value of a specific feature flag.
|
||||
*
|
||||
* @param {Function|Object} stateful - The redux store or {@code getState}
|
||||
* function.
|
||||
* @param {string} flag - The name of the React {@code Component} prop of
|
||||
* the currently mounted {@code App} to get.
|
||||
* @param {*} defaultValue - A default value for the flag, in case it's not defined.
|
||||
* @returns {*} The value of the specified React {@code Component} prop of the
|
||||
* currently mounted {@code App}.
|
||||
*/
|
||||
export function getFeatureFlag(stateful: IStateful, flag: string, defaultValue?: boolean | string) {
|
||||
const state = toState(stateful)['features/base/flags'];
|
||||
|
||||
if (state) {
|
||||
const value = state[flag as keyof typeof state];
|
||||
|
||||
if (typeof value !== 'undefined') {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe the value hasn't made it to the redux store yet, check the app props.
|
||||
const flags = getAppProp(stateful, 'flags') || {};
|
||||
|
||||
return flags[flag] || defaultValue;
|
||||
}
|
||||
Reference in New Issue
Block a user