2017-07-01 03:16:00 +08:00
|
|
|
import AuthSingleton from '/imports/ui/services/auth';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
|
|
|
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
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
const getSlideData = (params) => {
|
2017-07-25 05:04:49 +08:00
|
|
|
const { presentationId } = params;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
// Get userId and meetingId
|
2017-03-17 22:23:00 +08:00
|
|
|
const userId = AuthSingleton.userID;
|
|
|
|
const meetingId = AuthSingleton.meetingID;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
// Find the user object of this specific meeting and userid
|
2016-11-23 23:32:04 +08:00
|
|
|
const currentUser = Users.findOne({
|
2017-06-03 03:25:02 +08:00
|
|
|
meetingId,
|
|
|
|
userId,
|
2016-11-23 23:32:04 +08:00
|
|
|
});
|
|
|
|
|
2017-09-21 05:05:17 +08:00
|
|
|
const userIsPresenter = currentUser ? currentUser.presenter : false;
|
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
|
|
|
userIsPresenter,
|
|
|
|
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
|
|
|
};
|