fix: Race condition where inline comments could be removed, closes #6580

This commit is contained in:
Tom Moor
2024-04-17 22:39:32 -04:00
parent 573c372f09
commit e09826d1d1

View File

@@ -218,8 +218,8 @@ function Editor(props: Props, ref: React.RefObject<SharedEditor> | null) {
}, [localRef, onHeadingsChange]);
const updateComments = React.useCallback(() => {
if (onCreateCommentMark && onDeleteCommentMark) {
const commentMarks = localRef.current?.getComments();
if (onCreateCommentMark && onDeleteCommentMark && localRef.current) {
const commentMarks = localRef.current.getComments();
const commentIds = comments.orderedData.map((c) => c.id);
const commentMarkIds = commentMarks?.map((c) => c.id);
const newCommentIds = difference(
@@ -229,7 +229,7 @@ function Editor(props: Props, ref: React.RefObject<SharedEditor> | null) {
);
newCommentIds.forEach((commentId) => {
const mark = commentMarks?.find((c) => c.id === commentId);
const mark = commentMarks.find((c) => c.id === commentId);
if (mark) {
onCreateCommentMark(mark.id, mark.userId);
}