From d621d051e757643d150ed673c3bf2dbfb2b96592 Mon Sep 17 00:00:00 2001 From: Ravi theja Date: Wed, 28 Feb 2024 18:53:27 +0530 Subject: [PATCH] fix: poll close, mweb options crash --- .../components/AppData/useSidepane.js | 32 +++++++++++++------ .../SplitComponents/MwebOptions.tsx | 3 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/AppData/useSidepane.js b/packages/roomkit-react/src/Prebuilt/components/AppData/useSidepane.js index 204d48aa7a..c7ca47ff13 100644 --- a/packages/roomkit-react/src/Prebuilt/components/AppData/useSidepane.js +++ b/packages/roomkit-react/src/Prebuilt/components/AppData/useSidepane.js @@ -46,27 +46,39 @@ export const usePollViewToggle = () => { const togglePollView = useCallback( id => { - const newView = match({ id, isOpen, view }) + match({ id, isOpen, view }) .with( { id: P.string, }, - () => POLL_VIEWS.VOTE, + () => { + setPollState({ + [POLL_STATE.pollInView]: id, + [POLL_STATE.view]: POLL_VIEWS.VOTE, + }); + hmsActions.setAppData(APP_DATA.sidePane, SIDE_PANE_OPTIONS.POLLS); + }, ) .with( { isOpen: true, view: P.when(view => !!view), }, - () => null, + () => { + setPollState({ + [POLL_STATE.pollInView]: undefined, + [POLL_STATE.view]: null, + }); + hmsActions.setAppData(APP_DATA.sidePane, ''); + }, ) - .otherwise(() => POLL_VIEWS.CREATE_POLL_QUIZ); - - setPollState({ - [POLL_STATE.pollInView]: id, - [POLL_STATE.view]: newView, - }); - hmsActions.setAppData(APP_DATA.sidePane, newView ? SIDE_PANE_OPTIONS.POLLS : ''); + .otherwise(() => { + setPollState({ + [POLL_STATE.pollInView]: undefined, + [POLL_STATE.view]: POLL_VIEWS.CREATE_POLL_QUIZ, + }); + hmsActions.setAppData(APP_DATA.sidePane, SIDE_PANE_OPTIONS.POLLS); + }); }, [hmsActions, view, setPollState, isOpen], ); diff --git a/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx b/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx index c81a4c2ac6..9121f3eb23 100644 --- a/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx @@ -291,7 +291,8 @@ export const MwebOptions = ({ {match({ isBrowserRecordingOn, isRecordingLoading }) .with({ isBrowserRecordingOn: true, isRecordingLoading: false }, () => 'Recording On') .with({ isRecordingLoading: true }, () => 'Starting Recording') - .with({ isRecordingLoading: false }, () => 'Start Recording')} + .with({ isRecordingLoading: false }, () => 'Start Recording') + .otherwise(() => null)} ) : null}