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 emoji reaction when chat paused #2623

Merged
merged 3 commits into from
Feb 29, 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
42 changes: 41 additions & 1 deletion packages/roomkit-react/src/Prebuilt/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ import React, { MutableRefObject, useCallback, useRef } from 'react';
import { useMedia } from 'react-use';
import { VariableSizeList } from 'react-window';
import { selectSessionStore, selectUnreadHMSMessagesCount } from '@100mslive/hms-video-store';
import { match } from 'ts-pattern';
import { selectHMSMessagesCount, useHMSActions, useHMSStore, useHMSVanillaStore } from '@100mslive/react-sdk';
import { ChevronDownIcon } from '@100mslive/react-icons';
import { Button } from '../../../Button';
import { Flex } from '../../../Layout';
import { Box, Flex } from '../../../Layout';
import { config as cssConfig } from '../../../Theme';
// @ts-ignore: No implicit any
import { EmojiReaction } from '../EmojiReaction';
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 { useLandscapeHLSStream, useMobileHLSStream } from '../../common/hooks';
import { SESSION_STORE_KEY } from '../../common/constants';

export const Chat = () => {
Expand All @@ -21,6 +25,9 @@ export const Chat = () => {
const vanillaStore = useHMSVanillaStore();
const { enabled: isChatEnabled = true } = useHMSStore(selectSessionStore(SESSION_STORE_KEY.CHAT_STATE)) || {};
const isMobile = useMedia(cssConfig.media.md);
const isMobileHLSStream = useMobileHLSStream();
const isLandscapeStream = useLandscapeHLSStream();

const scrollToBottom = useCallback(
(unreadCount = 0) => {
if (listRef.current && listRef.current.scrollToItem && unreadCount > 0) {
Expand All @@ -46,6 +53,7 @@ export const Chat = () => {
>
{isMobile && elements?.chat?.is_overlay ? null : <PinnedMessage />}
<ChatBody ref={listRef} scrollToBottom={scrollToBottom} />

<ChatPaused />
<ChatBlocked />
{isMobile && elements?.chat?.is_overlay ? <PinnedMessage /> : null}
Expand All @@ -54,6 +62,38 @@ export const Chat = () => {
<NewMessageIndicator scrollToBottom={scrollToBottom} listRef={listRef} />
</ChatFooter>
) : null}
{(isMobileHLSStream || isLandscapeStream) && (
raviteja83 marked this conversation as resolved.
Show resolved Hide resolved
<Box
css={{
position: 'absolute',
...match({ isLandscapeStream, isChatEnabled })
.with(
{
isLandscapeStream: true,
isChatEnabled: true,
},
() => ({ bottom: '$19', right: '$10' }),
)
.with(
{
isLandscapeStream: true,
isChatEnabled: false,
},
() => ({ bottom: '$20', right: '$10' }),
)
.with(
{
isLandscapeStream: false,
isChatEnabled: true,
},
() => ({ bottom: '$19', right: '$8' }),
)
.otherwise(() => ({})),
}}
>
<EmojiReaction />
</Box>
)}
</Flex>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { HMSException, selectLocalPeer, useAVToggle, useHMSActions, useHMSStore
import { EmojiIcon, PauseCircleIcon, SendIcon, VerticalMenuIcon } from '@100mslive/react-icons';
import { Box, config as cssConfig, Flex, IconButton as BaseIconButton, Popover, styled, Text } from '../../..';
import { IconButton } from '../../../IconButton';
// @ts-ignore: No implicit any
import { EmojiReaction } from '../EmojiReaction';
import { MoreSettings } from '../MoreSettings/MoreSettings';
import { RaiseHand } from '../RaiseHand';
// @ts-ignore: No implicit any
Expand Down Expand Up @@ -280,9 +278,6 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo
{noAVPermissions ? <RaiseHand css={{ bg: '$surface_default' }} /> : null}
<MoreSettings elements={elements} screenType={screenType} />
</Flex>
<Box css={{ position: 'absolute', bottom: '$16', right: 0 }}>
<EmojiReaction />
</Box>
</>
)}
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EmojiIcon } from '@100mslive/react-icons';
import { EmojiCard } from './Footer/EmojiCard';
// import { ToastManager } from './Toast/ToastManager';
import { Dropdown } from '../../Dropdown';
import { Box } from '../../Layout';
import { config as cssConfig } from '../../Theme';
import { Tooltip } from '../../Tooltip';
import IconButton from '../IconButton';
Expand All @@ -26,7 +27,6 @@ export const EmojiReaction = () => {
const [open, setOpen] = useState(false);
const isConnected = useHMSStore(selectIsConnectedToRoom);
useDropdownList({ open: open, name: 'EmojiReaction' });

// const hmsActions = useHMSActions();
const roles = useHMSStore(selectAvailableRoleNames);
const localPeerId = useHMSStore(selectLocalPeerID);
Expand Down Expand Up @@ -67,9 +67,11 @@ export const EmojiReaction = () => {
if (!isConnected) {
return null;
}
return (isMobile || isLandscape) && !(isLandscapeStream || isMobileHLSStream) ? (
<EmojiCard sendReaction={sendReaction} />
) : (

if ((isMobile || isLandscape) && !(isLandscapeStream || isMobileHLSStream)) {
return <EmojiCard sendReaction={sendReaction} />;
}
return (
<Dropdown.Root open={open} onOpenChange={setOpen}>
<Dropdown.Trigger asChild data-testid="emoji_reaction_btn">
<IconButton
Expand All @@ -78,11 +80,17 @@ export const EmojiReaction = () => {
}
>
<Tooltip title="Emoji reaction">
<EmojiIcon />
<Box>
<EmojiIcon />
</Box>
</Tooltip>
</IconButton>
</Dropdown.Trigger>
<Dropdown.Content sideOffset={5} align="center" css={{ p: '$8', bg: '$surface_default' }}>
<Dropdown.Content
sideOffset={5}
align={isMobileHLSStream || isLandscapeStream ? 'end' : 'center'}
css={{ p: '$8', bg: '$surface_default' }}
>
<EmojiCard sendReaction={sendReaction} />
</Dropdown.Content>
</Dropdown.Root>
Expand Down
Loading