Skip to content

Commit

Permalink
fix: clean up vb state on reset
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed Nov 7, 2024
1 parent fcd2027 commit 693901c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/roomkit-react/src/Prebuilt/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { MutableRefObject, useEffect, useRef } from 'react';
import { HMSStatsStoreWrapper, HMSStoreWrapper, IHMSNotifications } from '@100mslive/hms-video-store';
import { HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
import { Layout, Logo, Screens, Theme, Typography } from '@100mslive/types-prebuilt';
import { match } from 'ts-pattern';
import {
Expand Down Expand Up @@ -49,7 +50,7 @@ import {
// @ts-ignore: No implicit Any
import { FeatureFlags } from './services/FeatureFlags';
// @ts-ignore: No implicit Any
import { DEFAULT_PORTAL_CONTAINER } from './common/constants';
import { APP_DATA, DEFAULT_PORTAL_CONTAINER } from './common/constants';

export type HMSPrebuiltOptions = {
userName?: string;
Expand Down Expand Up @@ -131,6 +132,7 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
// leave room when component unmounts
return () => {
VBHandler.reset();
reactiveStore?.current?.hmsActions.setAppData(APP_DATA.background, HMSVirtualBackgroundTypes.NONE);
reactiveStore?.current?.hmsActions.leave();
};
}, []);
Expand Down
2 changes: 2 additions & 0 deletions packages/roomkit-react/src/Prebuilt/AppStateContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useContext, useEffect } from 'react';
import { usePreviousDistinct } from 'react-use';
import { HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
import { match, P } from 'ts-pattern';
import { HMSRoomState, selectRoomState, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
import { VBHandler } from './components/VirtualBackground/VBHandler';
Expand Down Expand Up @@ -79,6 +80,7 @@ export const useAppStateManager = () => {
.otherwise(() => PrebuiltStates.MEETING);
});
VBHandler.reset();
hmsActions.setAppData(APP_DATA.background, HMSVirtualBackgroundTypes.NONE);
redirectToLeave(1000); // to clear toasts after 1 second
},
)
Expand Down

0 comments on commit 693901c

Please sign in to comment.