bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/polling/container.jsx
germanocaumo c213b88451 refactor(poll): improve poll types code
this also fixes certain poll type detection for other languages than english,
so that the correct poll type is sent in the events (they were being detected as custom)
2021-05-26 17:52:55 +00:00

44 lines
1.2 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { withTracker } from 'meteor/react-meteor-data';
import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import PollingService from './service';
import PollService from '/imports/ui/components/poll/service';
import PollingComponent from './component';
const propTypes = {
pollExists: PropTypes.bool.isRequired,
};
const POLLING_ENABLED = Meteor.settings.public.poll.enabled;
const PollingContainer = ({ pollExists, ...props }) => {
const currentUser = Users.findOne({ userId: Auth.userID }, { fields: { presenter: 1 } });
const showPolling = pollExists && !currentUser.presenter && POLLING_ENABLED;
if (showPolling) {
return (
<PollingComponent {...props} />
);
}
return null;
};
PollingContainer.propTypes = propTypes;
export default withTracker(() => {
const {
pollExists, handleVote, poll, handleTypedVote,
} = PollingService.mapPolls();
return ({
pollExists,
handleVote,
handleTypedVote,
poll,
pollAnswerIds: PollService.pollAnswerIds,
pollTypes: PollService.pollTypes,
isMeteorConnected: Meteor.status().connected,
});
})(PollingContainer);