2017-07-01 03:16:00 +08:00
|
|
|
import AuthSingleton 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-10 02:48:21 +08:00
|
|
|
const getSlideData = (presentationId) => {
|
2016-08-06 02:39:24 +08:00
|
|
|
// Get userId and meetingId
|
2017-03-17 22:23:00 +08:00
|
|
|
const meetingId = AuthSingleton.meetingID;
|
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,
|
|
|
|
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
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
const previousSlide = (currentSlideNum) => {
|
|
|
|
if (currentSlideNum > 1) {
|
2017-07-25 05:04:49 +08:00
|
|
|
makeCall('switchSlide', currentSlideNum - 1);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const nextSlide = (currentSlideNum, numberOfSlides) => {
|
|
|
|
if (currentSlideNum < numberOfSlides) {
|
2017-07-25 05:04:49 +08:00
|
|
|
makeCall('switchSlide', currentSlideNum + 1);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const skipToSlide = (event) => {
|
2017-07-25 05:04:49 +08:00
|
|
|
const requestedSlideNum = parseInt(event.target.value, 10);
|
|
|
|
makeCall('switchSlide', requestedSlideNum);
|
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,
|
2016-08-03 06:55:20 +08:00
|
|
|
};
|