2021-05-18 04:25:07 +08:00
|
|
|
import React, { useContext } from 'react';
|
2019-05-17 04:11:10 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
|
|
import { Session } from 'meteor/session';
|
|
|
|
import CaptionsService from '/imports/ui/components/captions/service';
|
2019-06-19 04:13:09 +08:00
|
|
|
import Pad from './component';
|
2019-08-30 00:26:07 +08:00
|
|
|
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';
|
2019-05-17 04:11:10 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const PadContainer = (props) => {
|
2021-08-05 19:03:24 +08:00
|
|
|
const layoutContext = useContext(LayoutContext);
|
|
|
|
const { layoutContextDispatch } = layoutContext;
|
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;
|
2019-05-17 04:11:10 +08:00
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
|
|
|
|
return (
|
2021-08-05 19:03:24 +08:00
|
|
|
<Pad {...{ layoutContextDispatch, ...props }}>
|
2021-05-18 04:25:07 +08:00
|
|
|
{children}
|
|
|
|
</Pad>
|
|
|
|
);
|
|
|
|
};
|
2019-05-17 04:11:10 +08:00
|
|
|
|
|
|
|
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 : '';
|
2019-06-14 10:18:36 +08:00
|
|
|
|
2019-05-17 04:11:10 +08:00
|
|
|
return {
|
|
|
|
locale,
|
2019-05-23 22:51:01 +08:00
|
|
|
name,
|
2019-05-17 04:11:10 +08:00
|
|
|
ownerId,
|
|
|
|
padId,
|
|
|
|
readOnlyPadId,
|
2019-08-30 00:26:07 +08:00
|
|
|
currentUserId: Auth.userID,
|
2019-05-22 03:21:46 +08:00
|
|
|
amIModerator: CaptionsService.amIModerator(),
|
2019-05-17 04:11:10 +08:00
|
|
|
};
|
|
|
|
})(PadContainer);
|