2018-04-12 04:05:30 +08:00
|
|
|
import PresentationPods from '/imports/api/presentation-pods';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Slides from '/imports/api/slides';
|
2017-07-01 03:16:00 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
const getSlideData = (podId, presentationId) => {
|
|
|
|
// Get meetingId and userId
|
|
|
|
const meetingId = Auth.meetingID;
|
|
|
|
const userId = Auth.userID;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
// fetching the presentation pod in order to see who owns it
|
|
|
|
const selector = {
|
2017-06-03 03:25:02 +08:00
|
|
|
meetingId,
|
2018-04-12 04:05:30 +08:00
|
|
|
podId,
|
|
|
|
};
|
|
|
|
const pod = PresentationPods.findOne(selector);
|
|
|
|
const userIsPresenter = pod.currentPresenterId === userId;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
// Get total number of slides in this presentation
|
2016-08-03 06:55:20 +08:00
|
|
|
const numberOfSlides = Slides.find({
|
2017-06-03 03:25:02 +08:00
|
|
|
meetingId,
|
2018-04-12 04:05:30 +08:00
|
|
|
podId,
|
2017-06-03 03:25:02 +08:00
|
|
|
presentationId,
|
2016-08-03 06:55:20 +08:00
|
|
|
}).fetch().length;
|
|
|
|
|
|
|
|
return {
|
2017-06-03 03:25:02 +08:00
|
|
|
numberOfSlides,
|
2016-08-03 06:55:20 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
const previousSlide = (currentSlideNum, podId) => {
|
2016-08-06 02:39:24 +08:00
|
|
|
if (currentSlideNum > 1) {
|
2018-04-12 04:05:30 +08:00
|
|
|
makeCall('switchSlide', currentSlideNum - 1, podId);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
const nextSlide = (currentSlideNum, numberOfSlides, podId) => {
|
2016-08-06 02:39:24 +08:00
|
|
|
if (currentSlideNum < numberOfSlides) {
|
2018-04-12 04:05:30 +08:00
|
|
|
makeCall('switchSlide', currentSlideNum + 1, podId);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-08-30 04:24:44 +08:00
|
|
|
const zoomSlide = (currentSlideNum, podId, widthRatio, heightRatio, xOffset, yOffset) => {
|
|
|
|
makeCall('zoomSlide', currentSlideNum, podId, widthRatio, heightRatio, xOffset, yOffset);
|
2018-08-14 03:29:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
const skipToSlide = (requestedSlideNum, podId) => {
|
|
|
|
makeCall('switchSlide', requestedSlideNum, podId);
|
2016-08-06 02:39:24 +08:00
|
|
|
};
|
|
|
|
|
2016-08-03 06:55:20 +08:00
|
|
|
export default {
|
|
|
|
getSlideData,
|
2016-08-06 02:39:24 +08:00
|
|
|
nextSlide,
|
|
|
|
previousSlide,
|
|
|
|
skipToSlide,
|
2018-08-14 03:29:38 +08:00
|
|
|
zoomSlide,
|
2016-08-03 06:55:20 +08:00
|
|
|
};
|