bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/polling/service.js

26 lines
520 B
JavaScript
Raw Normal View History

2017-04-26 21:47:44 +08:00
import { makeCall } from '/imports/ui/services/api';
import Polls from '/imports/api/polls';
2016-05-06 02:50:18 +08:00
2017-06-03 03:25:02 +08:00
const mapPolls = function () {
const poll = Polls.findOne({});
2016-05-06 02:50:18 +08:00
if (!poll) {
return { pollExists: false };
}
2017-07-25 20:26:45 +08:00
const amIRequester = poll.requester !== 'userId';
2016-05-06 02:50:18 +08:00
return {
poll: {
2017-07-25 20:26:45 +08:00
answers: poll.answers,
pollId: poll.id,
2016-05-06 02:50:18 +08:00
},
pollExists: true,
2017-06-03 03:25:02 +08:00
amIRequester,
handleVote(pollId, answerId) {
2017-04-26 21:47:44 +08:00
makeCall('publishVote', pollId, answerId.id);
2016-05-06 02:50:18 +08:00
},
};
};
export default { mapPolls };