Skip to content

Commit

Permalink
fix: poll toggle from notification
Browse files Browse the repository at this point in the history
  • Loading branch information
eswarclynn authored Oct 25, 2023
1 parent 97b04c4 commit b78d4ab
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,21 @@ export const useSidepaneToggle = sidepaneType => {
};

export const usePollViewToggle = () => {
const hmsActions = useHMSActions();
const { view, setPollState } = usePollViewState();
const isOpen = useSidepaneState() === SIDE_PANE_OPTIONS.POLLS;
const toggleSidepane = useSidepaneToggle(SIDE_PANE_OPTIONS.POLLS);

const togglePollView = useCallback(
id => {
id = typeof id === 'string' ? id : undefined;
const newView = id ? POLL_VIEWS.VOTE : isOpen && view ? null : POLL_VIEWS.CREATE_POLL_QUIZ;
setPollState({
[POLL_STATE.pollInView]: id,
[POLL_STATE.view]: id ? POLL_VIEWS.VOTE : isOpen && view ? null : POLL_VIEWS.CREATE_POLL_QUIZ,
[POLL_STATE.view]: newView,
});
if (!id) {
toggleSidepane();
}
hmsActions.setAppData(APP_DATA.sidePane, newView ? SIDE_PANE_OPTIONS.POLLS : '');
},
[view, setPollState, isOpen, toggleSidepane],
[hmsActions, view, setPollState, isOpen],
);

return togglePollView;
Expand Down

0 comments on commit b78d4ab

Please sign in to comment.