Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chat showing even when disabled on role change #2645

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export const Chat = () => {
[hmsActions, vanillaStore],
);

if (!elements?.chat) {
return null;
}

return (
<Flex
direction="column"
Expand Down
18 changes: 14 additions & 4 deletions packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useFullscreen, useMedia, usePrevious, useToggle } from 'react-use';
import { HLSPlaybackState, HMSHLSPlayer, HMSHLSPlayerEvents } from '@100mslive/hls-player';
import screenfull from 'screenfull';
import { match, P } from 'ts-pattern';
import {
HLSPlaylistType,
HMSNotificationTypes,
Expand Down Expand Up @@ -47,11 +48,20 @@ const ToggleChat = () => {
const toggleChat = useSidepaneToggle(SIDE_PANE_OPTIONS.CHAT);
const showChat = !!elements?.chat;
const isMobile = useMedia(config.media.md);
const hmsActions = useHMSActions();

useEffect(() => {
if (!sidepane && isMobile && showChat) {
toggleChat();
}
}, [sidepane, isMobile, toggleChat, showChat]);
match({ sidepane, isMobile, showChat })
.with({ isMobile: true, showChat: true, sidepane: P.when(value => !value) }, () => {
toggleChat();
})
.with({ showChat: false, isMobile: true, sidepane: SIDE_PANE_OPTIONS.CHAT }, () => {
hmsActions.setAppData(APP_DATA.sidePane, '');
})
.otherwise(() => {
//do nothing
});
}, [sidepane, isMobile, toggleChat, showChat, hmsActions]);
return null;
};
const HLSView = () => {
Expand Down
Loading