Skip to content

Commit

Permalink
fix: vb not applying on rejoin
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 authored Jan 5, 2024
1 parent 208feb5 commit 2616c7f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/hms-virtual-background/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/roomkit-react/src/Prebuilt/AppStateContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext, useEffect } from 'react';
import { usePreviousDistinct } from 'react-use';
import { HMSRoomState, selectRoomState, useHMSStore } from '@100mslive/react-sdk';
import { VBHandler } from './components/VirtualBackground/VBHandler';
import { useRoomLayout } from './provider/roomLayoutProvider';
import { useRedirectToLeave } from './components/hooks/useRedirectToLeave';
import {
Expand Down Expand Up @@ -60,6 +61,7 @@ export const useAppStateManager = () => {
) {
const goTo = isPreviewScreenEnabled ? PrebuiltStates.PREVIEW : PrebuiltStates.MEETING;
setActiveState(isLeaveScreenEnabled ? PrebuiltStates.LEAVE : goTo);
VBHandler.reset();
redirectToLeave(1000); // to clear toasts after 1 second
} else if (!prevRoomState && roomState === HMSRoomState.Disconnected) {
setActiveState(isPreviewScreenEnabled ? PrebuiltStates.PREVIEW : PrebuiltStates.MEETING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export class VBPlugin {
await this.hmsPlugin?.setBackground(HMSVirtualBackgroundTypes.NONE, HMSVirtualBackgroundTypes.NONE);
}
};

reset = () => {
this.effectsPlugin = undefined;
this.hmsPlugin = undefined;
};
}

export const VBHandler = new VBPlugin();
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
const showVideoTile = isVideoOn && isLargeRoom && !inPreview;

useEffect(() => {
if (!track?.id) {
return;
}
if (!isPluginAdded) {
let vbObject = VBHandler.getVBObject();
if (!vbObject) {
Expand All @@ -68,7 +71,7 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
}
}
}
}, [hmsActions, role, isPluginAdded, isEffectsEnabled, effectsKey]);
}, [hmsActions, role, isPluginAdded, isEffectsEnabled, effectsKey, track?.id]);

useEffect(() => {
if (!isVideoOn) {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8787,7 +8787,7 @@ ee-first@1.1.1:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==

effects-sdk@^2.5.3:
effects-sdk@2.6.8:
version "2.6.8"
resolved "https://registry.yarnpkg.com/effects-sdk/-/effects-sdk-2.6.8.tgz#ab34f9c83ce28d6b2d5db9fe522611db697009d4"
integrity sha512-zNJxruPxmbyTc+T43PBmCqQ4m//FvSr90DzYnuWu7r8C78tle9Ile35xmFfNBuKixbEt0ul4IDAmpqQkO3IrcQ==
Expand Down

0 comments on commit 2616c7f

Please sign in to comment.