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: show elements when chat is paused or peer is blocked #2916

Merged
merged 2 commits into from
May 21, 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
32 changes: 26 additions & 6 deletions packages/roomkit-react/src/Prebuilt/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ import { Box, Flex } from '../../../Layout';
import { config as cssConfig } from '../../../Theme';
// @ts-ignore: No implicit any
import { EmojiReaction } from '../EmojiReaction';
import { MoreSettings } from '../MoreSettings/MoreSettings';
import { RaiseHand } from '../RaiseHand';
import { ChatBody } from './ChatBody';
import { ChatFooter } from './ChatFooter';
import { ChatBlocked, ChatPaused } from './ChatStates';
import { PinnedMessage } from './PinnedMessage';
import { useRoomLayoutConferencingScreen } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
import { useSidepaneResetOnLayoutUpdate } from '../AppData/useSidepaneResetOnLayoutUpdate';
import { useIsPeerBlacklisted } from '../hooks/useChatBlacklist';
import { useLandscapeHLSStream, useMobileHLSStream } from '../../common/hooks';
import { SESSION_STORE_KEY, SIDE_PANE_OPTIONS } from '../../common/constants';

export const Chat = () => {
const { elements } = useRoomLayoutConferencingScreen();
const { elements, screenType } = useRoomLayoutConferencingScreen();
const listRef = useRef<VariableSizeList | null>(null);
const hmsActions = useHMSActions();
const vanillaStore = useHMSVanillaStore();
Expand All @@ -29,6 +32,7 @@ export const Chat = () => {
const isMobileHLSStream = useMobileHLSStream();
const isLandscapeStream = useLandscapeHLSStream();
useSidepaneResetOnLayoutUpdate('chat', SIDE_PANE_OPTIONS.CHAT);
const isLocalPeerBlacklisted = useIsPeerBlacklisted({ local: true });

const scrollToBottom = useCallback(
(unreadCount = 0) => {
Expand Down Expand Up @@ -57,20 +61,27 @@ export const Chat = () => {
>
{isMobile && elements?.chat?.is_overlay && !streaming ? null : <PinnedMessage />}
<ChatBody ref={listRef} scrollToBottom={scrollToBottom} />

<ChatPaused />
<ChatBlocked />
<Flex align="center" css={{ w: '100%', gap: '$2' }}>
<ChatPaused />
<ChatBlocked />
{streaming && (!isChatEnabled || isLocalPeerBlacklisted) && (
<>
<RaiseHand css={{ bg: '$surface_default' }} />
<MoreSettings elements={elements} screenType={screenType} />
</>
)}
</Flex>
{isMobile && elements?.chat?.is_overlay && !streaming ? <PinnedMessage /> : null}
{isChatEnabled ? (
<ChatFooter onSend={scrollToBottom}>
<NewMessageIndicator scrollToBottom={scrollToBottom} listRef={listRef} />
</ChatFooter>
) : null}
{(isMobileHLSStream || isLandscapeStream) && (
{streaming && (
<Box
css={{
position: 'absolute',
...match({ isLandscapeStream, isMobileHLSStream, isChatEnabled })
...match({ isLandscapeStream, isMobileHLSStream, isChatEnabled, isLocalPeerBlacklisted })
.with(
{
isLandscapeStream: true,
Expand All @@ -96,13 +107,22 @@ export const Chat = () => {
{
isMobileHLSStream: true,
isChatEnabled: true,
isLocalPeerBlacklisted: false,
},
() => ({ bottom: '$17', right: '$8' }),
)
.with(
{
isLandscapeStream: false,
isChatEnabled: true,
isLocalPeerBlacklisted: true,
},
() => ({ bottom: '$18', right: '$8' }),
)
.with(
{
isMobileHLSStream: true,
isLocalPeerBlacklisted: true,
},
() => ({ bottom: '$20', right: '$8' }),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ChatPaused = () => {
<Flex
align="center"
justify="between"
css={{ borderRadius: '$1', bg: '$surface_default', p: '$4 $4 $4 $8', w: '100%' }}
css={{ borderRadius: '$1', bg: '$surface_default', p: '$2 $4 $2 $8', w: '100%' }}
>
<Box>
<Text variant="sm" css={{ fontWeight: '$semiBold', color: '$on_surface_high' }}>
Expand Down
Loading