fix viewer crash when there is no presentation + some cleanup

This commit is contained in:
germanocaumo 2022-05-20 12:12:58 +00:00
parent 3a156ace07
commit dc56b969ed
11 changed files with 6 additions and 165 deletions

View File

@ -30,11 +30,9 @@ const process = () => {
};
export default function handleWhiteboardSend({ header, body }, meetingId) {
//console.log("!!!!!!!!!! handleWhiteboardSend!!!!!!!!!!: ");
const userId = header.userId;
const whiteboardId = body.whiteboardId;
const annotations = body.annotations;
//console.log(annotations);
check(userId, String);
check(whiteboardId, String);
@ -52,6 +50,4 @@ export default function handleWhiteboardSend({ header, body }, meetingId) {
Metrics.setAnnotationQueueLength(meetingId, annotationsQueue[meetingId].length);
}
if (!annotationsRecieverIsRunning) process();
//return addAnnotation(meetingId, whiteboardId, userId, annotation);
}

View File

@ -22,13 +22,6 @@ export default function deleteAnnotations(annotations, whiteboardId) {
annotationsIds: annotations,
};
console.log('$$$$$$$$$$$ shapes to remove $$$$$$$$$$$$$$$$$$$$$$')
console.log('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
console.log(annotations)
console.log('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
// shape.meetingId = meetingId;
//deleteShape(shape);
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method deleteAnnotation ${err.stack}`);

View File

@ -23,9 +23,6 @@ export default function sendAnnotationHelper(annotations, meetingId, requesterUs
annotations: whiteboardAnnotations,
};
//console.log("AEAFAEWFEWFWE")
//console.log(annotations)
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
});

View File

@ -5,7 +5,6 @@ import transferUser from './methods/transferUser';
import toggleLockSettings from './methods/toggleLockSettings';
import toggleWebcamsOnlyForModerator from './methods/toggleWebcamsOnlyForModerator';
import clearRandomlySelectedUser from './methods/clearRandomlySelectedUser';
import changeCurrentSlide from './methods/changeCurrentSlide';
import changeLayout from './methods/changeLayout';
Meteor.methods({
@ -16,5 +15,4 @@ Meteor.methods({
toggleWebcamsOnlyForModerator,
clearRandomlySelectedUser,
changeLayout,
changeCurrentSlide,
});

View File

@ -1,31 +0,0 @@
import Logger from '/imports/startup/server/logger';
import RedisPubSub from '/imports/startup/server/redis';
import { extractCredentials } from '/imports/api/common/server/helpers';
import { check } from 'meteor/check';
import setCurrentSlide from '../modifiers/setCurrentSlide';
export default function changeCurrentSlide(slideNum) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'BroadcastLayoutMsg';
console.log('$$$$$$$$$$$$$$$$$$$')
console.log(slideNum)
console.log('$$$$$$$$$$$$$$$$$$$')
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
setCurrentSlide(meetingId, slideNum);
// check(meetingId, String);
// check(requesterUserId, String);
// const payload = {
// layout,
// };
// RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
// Logger.error(`Exception while invoking method changeLayout ${err.stack}`);
}
}

View File

@ -1,25 +0,0 @@
import Logger from '/imports/startup/server/logger';
import Meetings from '/imports/api/meetings';
import { check } from 'meteor/check';
export default function setCurrentSlide(meetingId, slideNum) {
try {
const selector = {
meetingId,
};
const modifier = {
$set: {
activeSlide: slideNum,
},
};
const activeUpdate = Meetings.update(selector, modifier);
if (activeUpdate) {
Logger.info(`Meeting active slide changed for meeting=${meetingId}`);
}
} catch (err) {
Logger.error(`Exception while invoking method setCurrentSlide ${err.stack}`);
}
}

View File

@ -1,12 +1,3 @@
// import { Meteor } from 'meteor/meteor';
// import switchSlide from './methods/switchSlide';
// import zoomSlide from './methods/zoomSlide';
// Meteor.methods({
// switchSlide,
// zoomSlide,
// });
import { Meteor } from 'meteor/meteor';
import switchSlide from './methods/switchSlide';
import zoomSlide from './methods/zoomSlide';
@ -16,4 +7,4 @@ Meteor.methods({
switchSlide,
zoomSlide,
persistAsset,
});
});

View File

@ -32,7 +32,7 @@ class UserContent extends PureComponent {
return (
<Styled.Content data-test="userListContent">
{isChatEnabled() ? <UserMessagesContainer /> : null}
{/* {currentUser.role === ROLE_MODERATOR ? <UserCaptionsContainer /> : null} */}
{currentUser.role === ROLE_MODERATOR ? <UserCaptionsContainer /> : null}
<UserNotesContainer />
{showWaitingRoom && currentUser.role === ROLE_MODERATOR
? (

View File

@ -38,8 +38,6 @@ export default function Whiteboard(props) {
assets,
currentUser,
curPres,
curSlide,
changeCurrentSlide,
whiteboardId,
podId,
zoomSlide,
@ -60,14 +58,12 @@ export default function Whiteboard(props) {
assets,
});
//const [doc, setDoc] = React.useState(rDocument.current);
const [curPage, setCurPage] = React.useState({ id: "1" });
const [_assets, setAssets] = React.useState(assets);
const [command, setCommand] = React.useState("");
const [wbAccess, setWBAccess] = React.useState(props?.hasMultiUserAccess(props.whiteboardId, props.currentUser.userId));
const [selectedIds, setSelectedIds] = React.useState([]);
const [tldrawAPI, setTLDrawAPI] = React.useState(null);
const prevShapes = usePrevious(shapes);
const prevPage = usePrevious(curPage);
const prevSlidePosition = usePrevious(slidePosition);
const prevPageId = usePrevious(curPageId);
@ -179,8 +175,8 @@ export default function Whiteboard(props) {
}}
showPages={false}
showZoom={false}
showUI={isPresenter || hasWBAccess}
showMenu={false}
showUI={curPres ? (isPresenter || hasWBAccess) : true}
showMenu={curPres ? false : true}
showMultiplayerMenu={false}
readOnly={!isPresenter && !hasWBAccess}
onUndo={(e, s) => {
@ -254,7 +250,7 @@ export default function Whiteboard(props) {
const boundShapes = [];
if (pageBindings) {
Object.entries(pageBindings).map(([k,b]) => {
if (b.toId.includes(id), whiteboardId) {
if (b.toId.includes(id)) {
boundShapes.push(e.state.document.pages[e.getPage()?.id]?.shapes[b.fromId])
}
})

View File

@ -1,12 +1,10 @@
import Cursor from '/imports/ui/components/cursor/service';
import Cursor, { publishCursorUpdate } from '/imports/ui/components/cursor/service';
import Users from '/imports/api/users';
import { publishCursorUpdate } from '/imports/ui/components/cursor/service';
const getCurrentCursors = (whiteboardId) => {
const selector = { whiteboardId };
const filter = {};
const cursors = Cursor.find(selector, filter).fetch();
//console.log('CURSORS!!!!!!!!! : ',cursors);
return cursors.map(cursor => {
const { userId } = cursor;
const user = Users.findOne({ userId }, { fields: { name: 1, presenter: 1, userId: 1, role: 1 } });

View File

@ -1,6 +1,5 @@
import Users from '/imports/api/users';
import Captions from "/imports/api/captions";
import Meetings from "/imports/api/meetings";
import Auth from '/imports/ui/services/auth';
import WhiteboardMultiUser from '/imports/api/whiteboard-multi-user';
import addAnnotationQuery from '/imports/api/annotations/addAnnotation';
@ -8,7 +7,6 @@ import { Slides } from '/imports/api/slides';
import { makeCall } from '/imports/ui/services/api';
import PresentationService from '/imports/ui/components/presentation/service';
import logger from '/imports/startup/client/logger';
import { isEqual } from 'lodash';
const Annotations = new Mongo.Collection(null);
@ -17,7 +15,6 @@ const ANNOTATION_CONFIG = Meteor.settings.public.whiteboard.annotations;
const DRAW_START = ANNOTATION_CONFIG.status.start;
const DRAW_UPDATE = ANNOTATION_CONFIG.status.update;
const DRAW_END = ANNOTATION_CONFIG.status.end;
const ANNOTATION_TYPE_PENCIL = "pencil";
let annotationsStreamListener = null;
@ -30,63 +27,6 @@ function clearFakeAnnotations() {
Annotations.remove({ id: /-fake/g });
}
function handleAddedLiveSyncPreviewAnnotation({
meetingId, whiteboardId, userId, annotation,
}) {
const isOwn = Auth.meetingID === meetingId && Auth.userID === userId;
const query = addAnnotationQuery(meetingId, whiteboardId, userId, annotation);
if (!isOwn) {
Annotations.upsert(query.selector, query.modifier);
return;
}
const fakeAnnotation = Annotations.findOne({ id: `${annotation.id}-fake` });
let fakePoints;
if (fakeAnnotation) {
fakePoints = fakeAnnotation.annotationInfo.points;
const { points: lastPoints } = annotation.annotationInfo;
if (annotation.annotationType !== 'pencil') {
Annotations.update(fakeAnnotation._id, {
$set: {
position: annotation.position,
'annotationInfo.color': isEqual(fakePoints, lastPoints) || annotation.status === DRAW_END
? annotation.annotationInfo.color : fakeAnnotation.annotationInfo.color,
},
$inc: { version: 1 }, // TODO: Remove all this version stuff
});
return;
}
}
Annotations.upsert(query.selector, query.modifier, (err) => {
if (err) {
logger.error({
logCode: 'whiteboard_annotation_upsert_error',
extraInfo: { error: err },
}, 'Error on adding an annotation');
return;
}
// Remove fake annotation for pencil on draw end
if (annotation.status === DRAW_END) {
Annotations.remove({ id: `${annotation.id}-fake` });
return;
}
if (annotation.status === DRAW_START) {
Annotations.update(fakeAnnotation._id, {
$set: {
position: annotation.position - 1,
},
$inc: { version: 1 }, // TODO: Remove all this version stuff
});
}
});
}
function handleAddedAnnotation({
meetingId,
whiteboardId,
@ -156,20 +96,8 @@ export function initAnnotationsStreamListener() {
annotationsStreamListener.on("removed", handleRemovedAnnotation);
// <<<<<<< HEAD
// annotationsStreamListener.on('added', ({ annotations }) => {
// annotations.forEach((annotation) => {
// const tool = annotation.annotation.annotationType;
// if (tool === ANNOTATION_TYPE_TEXT) {
// handleAddedLiveSyncPreviewAnnotation(annotation);
// } else {
// handleAddedAnnotation(annotation);
// }
// });
// =======
annotationsStreamListener.on("added", ({ annotations }) => {
annotations.forEach((annotation) => handleAddedAnnotation(annotation));
// >>>>>>> embed Tldraw into BBB client
});
});
}