Clean captions when handling the history reply

This commit is contained in:
Oswaldo Acauan 2017-02-14 16:05:49 +00:00
parent edae8ea1be
commit 59eb04418d

View File

@ -1,4 +1,5 @@
import _ from 'underscore';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
import { inReplyToHTML5Client } from '/imports/api/common/server/helpers';
@ -37,6 +38,14 @@ export default function handleCaptionHistory({ payload }) {
}
}
const selectorToRemove = {
meetingId,
locale,
'captionHistory.index': { $gt: (chunks.length - 1) },
};
Captions.remove(selectorToRemove);
chunks.forEach((captions, index) => {
let captionHistoryObject = {
locale,
@ -48,6 +57,7 @@ export default function handleCaptionHistory({ payload }) {
captionsAdded.push(addCaption(meetingId, locale, captionHistoryObject));
});
});
return captionsAdded;