Skip to content
Snippets Groups Projects
Commit df98f394 authored by Oleksandr Zhurbenko's avatar Oleksandr Zhurbenko
Browse files

Handle SyncGetPresentationPods

parent 69d8deda
No related branches found
No related tags found
No related merge requests found
import { check } from 'meteor/check';
import PresentationPods from '/imports/api/presentation-pods';
import removePresentationPod from '../modifiers/removePresentationPod';
import addPresentationPod from '../modifiers/addPresentationPod';
export default function handleSyncGetPresentationPods({ body }, meetingId) {
check(body, Object);
check(meetingId, String);
const { pods } = body;
check(pods, Array);
const presentationPodIds = pods.map(pod => pod.id);
const presentationPodsToRemove = PresentationPods.find({
meetingId,
podId: { $nin: presentationPodIds },
}).fetch();
presentationPodsToRemove.forEach(p => removePresentationPod(meetingId, p.podId));
pods.forEach((pod) => {
// this message has unique names of 'podId' and 'currentPresenterId'
const {
id: podId,
currentPresenter: currentPresenterId,
presentations,
} = pod;
addPresentationPod(meetingId, { podId, currentPresenterId }, presentations);
});
}
import { Match, check } from 'meteor/check';
import PresentationPods from '/imports/api/presentation-pods';
import Logger from '/imports/startup/server/logger';
import addPresentation from '/imports/api/presentations/server/modifiers/addPresentation';
export default function addPresentationPod(meetingId, pod, presentation = null /* ?? */) {
export default function addPresentationPod(meetingId, pod, presentations = undefined /* ?? */) {
check(meetingId, String);
check(presentation, Match.Maybe(Object));
check(presentations, Match.Maybe(Array));
check(pod, {
currentPresenterId: String,
podId: String,
......@@ -28,6 +29,11 @@ export default function addPresentationPod(meetingId, pod, presentation = null /
return Logger.error(`Adding presentation pod to the collection: ${err}`);
}
// presentations object is currently passed together with Sync message
if (presentations) {
presentations.forEach(presentation => addPresentation(meetingId, podId, presentation));
}
if (numChanged) {
return Logger.info(`Added presentation pod id=${podId} meeting=${meetingId}`);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment