Skip to content

Commit

Permalink
fix: flag for vb
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed Jul 31, 2024
1 parent 65f3927 commit f175228
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/hms-video-store/src/interfaces/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export interface HMSRoom {
* @alpha
*/
isEffectsEnabled?: boolean;
/**
* @alpha
*/
isVBEnabled?: boolean;
/**
* @alpha
*/
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/reactive-store/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class SDKToHMS {
peerCount: sdkRoom.peerCount,
isLargeRoom: sdkRoom.large_room_optimization,
isEffectsEnabled: sdkRoom.isEffectsEnabled,
isVBEnabled: sdkRoom.isVBEnabled,
effectsKey: sdkRoom.effectsKey,
isHipaaEnabled: sdkRoom.isHipaaEnabled,
isNoiseCancellationEnabled: sdkRoom.isNoiseCancellationEnabled,
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/schema/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface HMSRoom {
peerCount?: number;
isLargeRoom?: boolean;
isEffectsEnabled?: boolean;
isVBEnabled?: boolean;
effectsKey?: string;
isHipaaEnabled?: boolean;
isNoiseCancellationEnabled?: boolean;
Expand Down
4 changes: 4 additions & 0 deletions packages/hms-video-store/src/sdk/models/HMSRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default class Room implements HMSRoom {
* @alpha
*/
isEffectsEnabled?: boolean;
/**
* @alpha
*/
isVBEnabled?: boolean;
/**
* @alpha
*/
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/selectors/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ export const selectSessionId = createSelector(selectRoom, room => room.sessionId
export const selectRoomStartTime = createSelector(selectRoom, room => room.startedAt);
export const selectIsLargeRoom = createSelector(selectRoom, room => !!room.isLargeRoom);
export const selectIsEffectsEnabled = createSelector(selectRoom, room => !!room.isEffectsEnabled);
export const selectIsVBEnabled = createSelector(selectRoom, room => !!room.isVBEnabled);
export const selectEffectsKey = createSelector(selectRoom, room => room.effectsKey);

export const selectTemplateAppData = (store: HMSStore) => store.templateAppData;
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/signal/init/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export enum InitFlags {
FLAG_DISABLE_VIDEO_TRACK_AUTO_UNSUBSCRIBE = 'disableVideoTrackAutoUnsubscribe',
FLAG_WHITEBOARD_ENABLED = 'whiteboardEnabled',
FLAG_EFFECTS_SDK_ENABLED = 'effectsSDKEnabled',
FLAG_VB_ENABLED = 'vb',
FLAG_HIPAA_ENABLED = 'hipaa',
FLAG_NOISE_CANCELLATION = 'noiseCancellation',
FLAG_SCALE_SCREENSHARE_BASED_ON_PIXELS = 'scaleScreenshareBasedOnPixels',
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ export default class HMSTransport {
if (room) {
room.effectsKey = this.initConfig.config.vb?.effectsKey;
room.isEffectsEnabled = this.isFlagEnabled(InitFlags.FLAG_EFFECTS_SDK_ENABLED);
room.isVBEnabled = this.isFlagEnabled(InitFlags.FLAG_VB_ENABLED);
room.isHipaaEnabled = this.isFlagEnabled(InitFlags.FLAG_HIPAA_ENABLED);
room.isNoiseCancellationEnabled = this.isFlagEnabled(InitFlags.FLAG_NOISE_CANCELLATION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
HMSRoomState,
selectAppData,
selectIsLocalVideoEnabled,
selectIsVBEnabled,
selectLocalPeer,
selectRoomState,
selectVideoTrackByID,
Expand Down Expand Up @@ -253,6 +254,7 @@ export const PreviewTile = ({ name, error }: { name: string; error?: boolean })

export const PreviewControls = ({ hideSettings, vbEnabled }: { hideSettings: boolean; vbEnabled: boolean }) => {
const isMobile = useMedia(cssConfig.media.md);
const isVBEnabledForUser = useHMSStore(selectIsVBEnabled);
return (
<Flex
justify={hideSettings && isMobile ? 'center' : 'between'}
Expand All @@ -263,7 +265,7 @@ export const PreviewControls = ({ hideSettings, vbEnabled }: { hideSettings: boo
>
<Flex css={{ gap: '$4' }}>
<AudioVideoToggle />
{vbEnabled ? <VBToggle /> : null}
{vbEnabled && isVBEnabledForUser ? <VBToggle /> : null}
</Flex>
<Flex align="center" gap="1">
{isMobile && <NoiseCancellation iconOnly />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from 'react';
import { selectAppData, selectIsEffectsEnabled, selectIsLocalVideoEnabled, useHMSStore } from '@100mslive/react-sdk';
import {
selectAppData,
selectIsEffectsEnabled,
selectIsLocalVideoEnabled,
selectIsVBEnabled,
useHMSStore,
} from '@100mslive/react-sdk';
import { VirtualBackgroundIcon } from '@100mslive/react-icons';
import { Loading } from '../../../Loading';
import { Tooltip } from '../../../Tooltip';
Expand All @@ -12,10 +18,11 @@ export const VBToggle = () => {
const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
const isVBOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.VB);
const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
const isVBEnabled = useHMSStore(selectIsVBEnabled);
const isEffectsEnabled = useHMSStore(selectIsEffectsEnabled);
const loadingEffects = useHMSStore(selectAppData(APP_DATA.loadingEffects));

if (!isVideoOn || (!isEffectsEnabled && isSafari)) {
if (!isVideoOn || (!isEffectsEnabled && isSafari) || !isVBEnabled) {
return null;
}

Expand Down

0 comments on commit f175228

Please sign in to comment.