bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/polling/container.jsx

39 lines
1.1 KiB
React
Raw Normal View History

2016-05-06 02:50:18 +08:00
import React from 'react';
import PropTypes from 'prop-types';
import { withTracker } from 'meteor/react-meteor-data';
2018-10-10 23:49:58 +08:00
import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
2017-10-06 20:50:01 +08:00
import PollingService from './service';
2019-05-23 02:00:44 +08:00
import Service from '/imports/ui/components/poll/service';
import PollingComponent from './component';
2016-05-06 02:50:18 +08:00
const propTypes = {
pollExists: PropTypes.bool.isRequired,
2017-10-06 20:50:01 +08:00
};
2019-07-02 22:54:37 +08:00
const POLLING_ENABLED = Meteor.settings.public.poll.enabled;
const PollingContainer = ({ pollExists, ...props }) => {
2018-10-10 23:49:58 +08:00
const currentUser = Users.findOne({ userId: Auth.userID });
2019-07-02 22:54:37 +08:00
const showPolling = pollExists && !currentUser.presenter && POLLING_ENABLED;
if (showPolling) {
return (
<PollingComponent {...props} />
);
}
return null;
};
PollingContainer.propTypes = propTypes;
export default withTracker(() => {
2019-05-23 02:00:44 +08:00
const { pollExists, handleVote, poll } = PollingService.mapPolls();
return ({
pollExists,
handleVote,
poll,
pollAnswerIds: Service.pollAnswerIds,
isMeteorConnected: Meteor.status().connected,
2019-05-23 02:00:44 +08:00
});
})(PollingContainer);