Simply updating data in the Slides collection instead of removing and adding whole objects

This commit is contained in:
Oleksandr Zhurbenko 2016-01-21 10:29:18 -08:00
parent 8d18271579
commit f287f5f4cb

View File

@ -13,11 +13,15 @@ this.displayThisSlide = function(meetingId, newSlideId, slideObject) {
"slide.current": false
}
});
// for the new slide: remove the version which came with presentation_shared_message from the Collection
// to avoid using old data (this message contains everything we need for the new slide)
removeSlideFromCollection(meetingId, newSlideId);
// add the new slide to the collection
return addSlideToCollection(meetingId, presentationId, slideObject);
Meteor.Slides.update({
presentationId: presentationId,
"slide.id": newSlideId
}, {
$set: {
"slide.current": true
}
});
};
this.addSlideToCollection = function(meetingId, presentationId, slideObject) {
@ -48,23 +52,6 @@ this.addSlideToCollection = function(meetingId, presentationId, slideObject) {
}
};
this.removeSlideFromCollection = function(meetingId, slideId) {
let id;
if((meetingId != null) && (slideId != null) && (Meteor.Slides.findOne({
meetingId: meetingId,
"slide.id": slideId
}) != null)) {
id = Meteor.Slides.findOne({
meetingId: meetingId,
"slide.id": slideId
});
if(id != null) {
Meteor.Slides.remove(id._id);
return Meteor.log.info(`----removed slide[${slideId}] from ${meetingId}`);
}
}
};
// called on server start and meeting end
this.clearSlidesCollection = function(meetingId) {
if(meetingId != null) {