bigbluebutton-Github/bigbluebutton-html5/imports/api/annotations/addAnnotation.js
germanocaumo 835cf4f753 fix(whiteboard): diff shape update + shape permission +
Several improvements to tldraw whiteboard:
 - Only send the shape diff on shape updates (reduce a lot the message traffic)
 - Shape permissions (don't allow others to select/edit unless you are presenter/moderator)
  - This required some changes in akka model
 - Tldraw state patch changes to improve stability with fast updates (fix several crashes)
2022-10-21 14:05:31 +00:00

37 lines
704 B
JavaScript
Executable File

import { check } from 'meteor/check';
import _ from "lodash";
export default function addAnnotation(meetingId, whiteboardId, userId, annotation, Annotations) {
check(meetingId, String);
check(whiteboardId, String);
check(annotation, Object);
const {
id, wbId,
} = annotation;
let { annotationInfo } = annotation;
const selector = {
meetingId,
id,
};
const oldAnnotation = Annotations.findOne(selector);
if (oldAnnotation) {
annotationInfo = _.merge(oldAnnotation.annotationInfo, annotationInfo)
}
const modifier = {
$set: {
whiteboardId,
meetingId,
id,
annotationInfo,
wbId,
},
};
return { selector, modifier };
}