For the most part the changes are taking the "static propTypes" declaration off of components and declaring them as Flow types. Sometimes to support flow some method signatures had to be added. There are some exceptions in which more had to be done to tame the beast: - AbstractVideoTrack: put in additional truthy checks for videoTrack. - Video: add truthy checks for the _videoElement ref. - shouldRenderVideoTrack function: Some component could pass null for the videoTrack argument and Flow wanted that called out explicitly. - DisplayName: Add a truthy check for the input ref before acting on it. - NumbersList: Move array checks inline for Flow to comprehend array methods could be called. Add type checks in the Object.entries loop as the value is assumed to be a mixed type by Flow. - AbstractToolbarButton: add additional truthy check for passed in type.
68 lines
2.2 KiB
JavaScript
68 lines
2.2 KiB
JavaScript
/* @flow */
|
|
|
|
import { toState } from '../redux';
|
|
|
|
import { VIDEO_MUTISM_AUTHORITY } from './constants';
|
|
|
|
/**
|
|
* Determines whether video is currently muted by the audio-only authority.
|
|
*
|
|
* @param {Function|Object} stateful - The redux store, state, or
|
|
* {@code getState} function.
|
|
* @returns {boolean}
|
|
*/
|
|
export function isVideoMutedByAudioOnly(stateful: Function | Object) {
|
|
return (
|
|
_isVideoMutedByAuthority(stateful, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY));
|
|
}
|
|
|
|
/**
|
|
* Determines whether video is currently muted by a specific
|
|
* {@code VIDEO_MUTISM_AUTHORITY}.
|
|
*
|
|
* @param {Function|Object} stateful - The redux store, state, or
|
|
* {@code getState} function.
|
|
* @param {number} videoMutismAuthority - The {@code VIDEO_MUTISM_AUTHORITY}
|
|
* which is to be checked whether it has muted video.
|
|
* @returns {boolean} If video is currently muted by the specified
|
|
* {@code videoMutismAuthority}, then {@code true}; otherwise, {@code false}.
|
|
*/
|
|
function _isVideoMutedByAuthority(
|
|
stateful: Function | Object,
|
|
videoMutismAuthority: number) {
|
|
const { muted } = toState(stateful)['features/base/media'].video;
|
|
|
|
// eslint-disable-next-line no-bitwise
|
|
return Boolean(muted & videoMutismAuthority);
|
|
}
|
|
|
|
/**
|
|
* Determines whether video is currently muted by the user authority.
|
|
*
|
|
* @param {Function|Object} stateful - The redux store, state, or
|
|
* {@code getState} function.
|
|
* @returns {boolean}
|
|
*/
|
|
export function isVideoMutedByUser(stateful: Function | Object) {
|
|
return _isVideoMutedByAuthority(stateful, VIDEO_MUTISM_AUTHORITY.USER);
|
|
}
|
|
|
|
/**
|
|
* Determines whether a specific videoTrack should be rendered.
|
|
*
|
|
* @param {Track} videoTrack - The video track which is to be rendered.
|
|
* @param {boolean} waitForVideoStarted - True if the specified videoTrack
|
|
* should be rendered only after its associated video has started;
|
|
* otherwise, false.
|
|
* @returns {boolean} True if the specified videoTrack should be renderd;
|
|
* otherwise, false.
|
|
*/
|
|
export function shouldRenderVideoTrack(
|
|
videoTrack: ?{ muted: boolean, videoStarted: boolean },
|
|
waitForVideoStarted: boolean) {
|
|
return (
|
|
videoTrack
|
|
&& !videoTrack.muted
|
|
&& (!waitForVideoStarted || videoTrack.videoStarted));
|
|
}
|