bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/captions/pad/container.jsx

62 lines
1.5 KiB
React
Raw Normal View History

2021-05-18 04:25:07 +08:00
import React, { useContext } from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import { Session } from 'meteor/session';
import CaptionsService from '/imports/ui/components/captions/service';
import Pad from './component';
import Auth from '/imports/ui/services/auth';
2021-08-05 19:03:24 +08:00
import LayoutContext from '../../layout/context';
2021-05-18 04:25:07 +08:00
import { ACTIONS, PANELS } from '../../layout/enums';
2021-05-18 04:25:07 +08:00
const PadContainer = (props) => {
2021-08-05 19:03:24 +08:00
const layoutContext = useContext(LayoutContext);
2021-08-19 20:59:50 +08:00
const { layoutContextDispatch, layoutContextState } = layoutContext;
const { input } = layoutContextState;
const { cameraDock } = input;
const { isResizing } = cameraDock;
2021-05-18 04:25:07 +08:00
const {
amIModerator,
children,
} = props;
if (!amIModerator) {
2021-08-05 19:03:24 +08:00
layoutContextDispatch({
2021-05-18 04:25:07 +08:00
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
value: false,
});
2021-08-05 19:03:24 +08:00
layoutContextDispatch({
2021-05-18 04:25:07 +08:00
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
value: PANELS.NONE,
});
return null;
}
2021-05-18 04:25:07 +08:00
return (
2021-08-19 20:59:50 +08:00
<Pad {...{ layoutContextDispatch, isResizing, ...props }}>
2021-05-18 04:25:07 +08:00
{children}
</Pad>
);
};
export default withTracker(() => {
const locale = Session.get('captionsLocale');
const caption = CaptionsService.getCaptions(locale);
const {
padId,
ownerId,
readOnlyPadId,
} = caption;
2019-05-23 22:51:01 +08:00
const { name } = caption ? caption.locale : '';
return {
locale,
2019-05-23 22:51:01 +08:00
name,
ownerId,
padId,
readOnlyPadId,
currentUserId: Auth.userID,
amIModerator: CaptionsService.amIModerator(),
};
})(PadContainer);