2017-10-12 10:00:28 +08:00
|
|
|
import WhiteboardMultiUser from '/imports/api/whiteboard-multi-user/';
|
2018-04-10 13:24:04 +08:00
|
|
|
import PresentationPods from '/imports/api/presentation-pods';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Presentations from '/imports/api/presentations';
|
|
|
|
import Slides from '/imports/api/slides';
|
|
|
|
import Users from '/imports/api/users';
|
2016-11-12 03:02:46 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
|
2018-04-10 13:24:04 +08:00
|
|
|
const getCurrentPresentation = podId => Presentations.findOne({
|
|
|
|
podId,
|
2017-07-25 02:46:53 +08:00
|
|
|
current: true,
|
2016-11-12 03:02:46 +08:00
|
|
|
});
|
|
|
|
|
2018-04-10 13:24:04 +08:00
|
|
|
const getCurrentSlide = (podId) => {
|
|
|
|
const currentPresentation = getCurrentPresentation(podId);
|
2016-11-12 03:02:46 +08:00
|
|
|
|
|
|
|
if (!currentPresentation) {
|
|
|
|
return null;
|
2016-05-31 06:07:02 +08:00
|
|
|
}
|
|
|
|
|
2017-09-19 08:18:20 +08:00
|
|
|
return Slides.findOne(
|
|
|
|
{
|
2018-04-10 13:24:04 +08:00
|
|
|
podId,
|
2017-09-19 08:18:20 +08:00
|
|
|
presentationId: currentPresentation.id,
|
|
|
|
current: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fields: {
|
|
|
|
meetingId: 0,
|
|
|
|
thumbUri: 0,
|
|
|
|
swfUri: 0,
|
|
|
|
txtUri: 0,
|
|
|
|
svgUri: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
2016-11-12 03:02:46 +08:00
|
|
|
};
|
2016-07-16 04:45:54 +08:00
|
|
|
|
2018-04-10 13:24:04 +08:00
|
|
|
const isPresenter = (podId) => {
|
|
|
|
// a main presenter in the meeting always owns a default pod
|
|
|
|
if (podId === 'DEFAULT_PRESENTATION_POD') {
|
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID });
|
|
|
|
return currentUser ? currentUser.presenter : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if a pod is not default, then we check whether this user owns a current pod
|
|
|
|
const selector = {
|
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
podId,
|
|
|
|
};
|
|
|
|
const pod = PresentationPods.findOne(selector);
|
|
|
|
return pod.currentPresenterId === Auth.userID;
|
2016-11-22 23:46:08 +08:00
|
|
|
};
|
2016-11-12 03:02:46 +08:00
|
|
|
|
2018-04-10 07:18:49 +08:00
|
|
|
const getMultiUserStatus = (whiteboardId) => {
|
|
|
|
const data = WhiteboardMultiUser.findOne({ meetingId: Auth.meetingID, whiteboardId });
|
2017-09-21 05:05:17 +08:00
|
|
|
return data ? data.multiUser : false;
|
2017-08-09 04:55:38 +08:00
|
|
|
};
|
|
|
|
|
2016-05-31 06:07:02 +08:00
|
|
|
export default {
|
2016-11-12 03:02:46 +08:00
|
|
|
getCurrentPresentation,
|
|
|
|
getCurrentSlide,
|
|
|
|
isPresenter,
|
2017-08-09 04:55:38 +08:00
|
|
|
getMultiUserStatus,
|
2016-05-31 06:07:02 +08:00
|
|
|
};
|