2018-09-24 06:57:03 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2018-09-24 06:20:20 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2018-09-24 06:57:03 +08:00
|
|
|
import Presentations from '/imports/api/presentations';
|
|
|
|
import PresentationAreaService from '/imports/ui/components/presentation/service';
|
2019-03-15 03:34:53 +08:00
|
|
|
import Poll from '/imports/ui/components/poll/component';
|
2019-09-07 04:28:02 +08:00
|
|
|
import Service from './service';
|
2018-09-24 06:57:03 +08:00
|
|
|
|
2020-07-20 22:34:46 +08:00
|
|
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
|
|
|
const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id;
|
|
|
|
|
2018-11-23 12:08:48 +08:00
|
|
|
const PollContainer = ({ ...props }) => <Poll {...props} />;
|
2018-09-24 06:20:20 +08:00
|
|
|
|
2019-03-09 04:46:25 +08:00
|
|
|
export default withTracker(() => {
|
2020-02-07 04:47:28 +08:00
|
|
|
Meteor.subscribe('current-poll');
|
2018-10-29 23:27:50 +08:00
|
|
|
|
2018-09-24 06:57:03 +08:00
|
|
|
const currentPresentation = Presentations.findOne({
|
|
|
|
current: true,
|
2019-08-22 20:05:06 +08:00
|
|
|
}, { fields: { podId: 1 } }) || {};
|
2018-09-24 06:57:03 +08:00
|
|
|
|
|
|
|
const currentSlide = PresentationAreaService.getCurrentSlide(currentPresentation.podId);
|
|
|
|
|
2020-07-20 22:34:46 +08:00
|
|
|
const pollId = currentSlide ? currentSlide.id : PUBLIC_CHAT_KEY;
|
|
|
|
|
2021-03-07 22:12:49 +08:00
|
|
|
const startPoll = (type, question = '', isMultipleResponse) => makeCall('startPoll', type, pollId, question, isMultipleResponse);
|
2020-07-20 22:34:46 +08:00
|
|
|
|
2021-03-08 01:11:57 +08:00
|
|
|
const startCustomPoll = (type, question = '', isMultipleResponse, answers) => makeCall('startPoll', type, pollId, question, isMultipleResponse, answers);
|
2018-09-24 06:20:20 +08:00
|
|
|
|
2020-07-20 22:34:46 +08:00
|
|
|
const stopPoll = () => makeCall('stopPoll');
|
2018-09-24 06:20:20 +08:00
|
|
|
|
|
|
|
return {
|
|
|
|
currentSlide,
|
2019-08-30 00:26:07 +08:00
|
|
|
amIPresenter: Service.amIPresenter(),
|
2018-11-01 03:13:19 +08:00
|
|
|
pollTypes: Service.pollTypes,
|
2018-09-24 06:20:20 +08:00
|
|
|
startPoll,
|
|
|
|
startCustomPoll,
|
2020-07-20 22:34:46 +08:00
|
|
|
stopPoll,
|
2018-11-01 03:13:19 +08:00
|
|
|
publishPoll: Service.publishPoll,
|
|
|
|
currentPoll: Service.currentPoll(),
|
2019-03-28 23:58:10 +08:00
|
|
|
resetPollPanel: Session.get('resetPollPanel') || false,
|
2019-05-23 02:00:44 +08:00
|
|
|
pollAnswerIds: Service.pollAnswerIds,
|
2019-06-28 00:46:14 +08:00
|
|
|
isMeteorConnected: Meteor.status().connected,
|
2018-09-24 06:20:20 +08:00
|
|
|
};
|
|
|
|
})(PollContainer);
|