2016-08-03 06:55:20 +08:00
|
|
|
import AuthSingleton from '/imports/ui/services/auth/index.js';
|
|
|
|
import Users from '/imports/api/users';
|
|
|
|
import Slides from '/imports/api/slides';
|
2016-08-06 02:39:24 +08:00
|
|
|
import { callServer } from '/imports/ui/services/api/index.js';
|
2016-08-03 06:55:20 +08:00
|
|
|
|
|
|
|
let getSlideData = (params) => {
|
|
|
|
const { currentSlideNum, presentationId } = params;
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
// Get userId and meetingId
|
2016-08-03 06:55:20 +08:00
|
|
|
const userId = AuthSingleton.getCredentials().requesterUserId;
|
|
|
|
const meetingId = AuthSingleton.getCredentials().meetingId;
|
|
|
|
|
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({
|
2016-08-03 06:55:20 +08:00
|
|
|
meetingId: meetingId,
|
|
|
|
userId: userId,
|
2016-11-23 23:32:04 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
let userIsPresenter;
|
|
|
|
if (currentUser && currentUser.user) {
|
|
|
|
userIsPresenter = currentUser.user.presenter;
|
|
|
|
}
|
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({
|
|
|
|
meetingId: meetingId,
|
|
|
|
presentationId: presentationId,
|
|
|
|
}).fetch().length;
|
|
|
|
|
|
|
|
return {
|
2016-08-06 02:39:24 +08:00
|
|
|
userIsPresenter: userIsPresenter,
|
2016-08-03 06:55:20 +08:00
|
|
|
numberOfSlides: numberOfSlides,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
const previousSlide = (currentSlideNum) => {
|
|
|
|
if (currentSlideNum > 1) {
|
2016-08-06 04:13:48 +08:00
|
|
|
callServer('switchSlideMessage', currentSlideNum - 1);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const nextSlide = (currentSlideNum, numberOfSlides) => {
|
|
|
|
if (currentSlideNum < numberOfSlides) {
|
2016-08-06 04:13:48 +08:00
|
|
|
callServer('switchSlideMessage', currentSlideNum + 1);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const skipToSlide = (event) => {
|
2016-11-16 00:30:13 +08:00
|
|
|
const requestedSlideNum = parseInt(event.target.value);
|
2016-08-06 04:13:48 +08:00
|
|
|
callServer('switchSlideMessage', 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
|
|
|
};
|