2023-04-28 05:31:11 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { layoutSelectInput, layoutDispatch } from '/imports/ui/components/layout/context';
|
2021-10-14 22:11:37 +08:00
|
|
|
import { injectIntl } from 'react-intl';
|
2023-07-18 19:54:36 +08:00
|
|
|
import ReactionsButton from './component';
|
2023-06-27 22:08:49 +08:00
|
|
|
import { SMALL_VIEWPORT_BREAKPOINT } from '/imports/ui/components/layout/enums';
|
2023-11-30 21:42:11 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-05-17 20:29:10 +08:00
|
|
|
import useSettings from '/imports/ui/services/settings/hooks/useSettings';
|
|
|
|
import { SETTINGS } from '/imports/ui/services/settings/enums';
|
2021-10-14 22:11:37 +08:00
|
|
|
|
2023-07-18 19:54:36 +08:00
|
|
|
const ReactionsButtonContainer = ({ ...props }) => {
|
2023-04-28 05:31:11 +08:00
|
|
|
const layoutContextDispatch = layoutDispatch();
|
|
|
|
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
|
2021-10-14 22:11:37 +08:00
|
|
|
const { sidebarContentPanel } = sidebarContent;
|
2023-06-27 22:08:49 +08:00
|
|
|
|
|
|
|
const { width: browserWidth } = layoutSelectInput((i) => i.browser);
|
|
|
|
const isMobile = browserWidth <= SMALL_VIEWPORT_BREAKPOINT;
|
|
|
|
|
2023-11-30 21:42:11 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
emoji: user.emoji,
|
|
|
|
raiseHand: user.raiseHand,
|
2024-04-24 01:56:23 +08:00
|
|
|
away: user.away,
|
|
|
|
voice: user.voice,
|
2024-04-25 02:45:28 +08:00
|
|
|
reaction: user.reaction,
|
2023-11-30 21:42:11 +08:00
|
|
|
}));
|
2024-04-25 02:45:28 +08:00
|
|
|
|
2023-11-30 21:42:11 +08:00
|
|
|
const currentUser = {
|
|
|
|
userId: Auth.userID,
|
|
|
|
emoji: currentUserData?.emoji,
|
|
|
|
raiseHand: currentUserData?.raiseHand,
|
2024-04-24 01:56:23 +08:00
|
|
|
away: currentUserData?.away,
|
|
|
|
muted: currentUserData?.voice?.muted || false,
|
2023-11-30 21:42:11 +08:00
|
|
|
};
|
|
|
|
|
2024-05-17 20:29:10 +08:00
|
|
|
const { autoCloseReactionsBar } = useSettings(SETTINGS.APPLICATION);
|
|
|
|
|
2021-10-14 22:11:37 +08:00
|
|
|
return (
|
2023-07-18 19:54:36 +08:00
|
|
|
<ReactionsButton {...{
|
2024-04-25 02:45:28 +08:00
|
|
|
currentUserReaction: currentUserData?.reaction?.reactionEmoji ?? 'none',
|
|
|
|
layoutContextDispatch,
|
|
|
|
sidebarContentPanel,
|
|
|
|
isMobile,
|
2024-05-17 20:29:10 +08:00
|
|
|
autoCloseReactionsBar,
|
2024-04-25 02:45:28 +08:00
|
|
|
...currentUser,
|
|
|
|
...props,
|
2022-09-27 02:38:45 +08:00
|
|
|
}}
|
|
|
|
/>
|
2021-10-14 22:11:37 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-05-17 20:29:10 +08:00
|
|
|
export default injectIntl(ReactionsButtonContainer);
|