Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annotation: avoid comment conflict warning when irrelevan #10799

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion browser/src/canvas/sections/CommentListSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ export class CommentSection extends app.definitions.canvasSectionObject {
this.onACKComment(obj);
}


public handleCommentConflict(obj: any, editComment: Comment) {
if (document.getElementById(this.map.uiManager.generateModalId('comments-update')))
return;
Expand Down Expand Up @@ -1455,13 +1456,40 @@ export class CommentSection extends app.definitions.canvasSectionObject {
);
}

public checkIfOnlyAnchorPosChanged(obj: any, editComment: Comment): boolean {
if (obj.comment.action !== 'Modify')
return false;

var newComment = obj.comment;
var editCommentData = editComment.sectionProperties.data;

if (newComment.author !== editCommentData.author
|| newComment.dateTime !== editCommentData.dateTime
|| newComment.html !== editCommentData.html
|| newComment.layoutStatus !== editCommentData.layoutStatus.toString()
|| newComment.parentId !== editCommentData.parentId
|| newComment.resolved !== editCommentData.resolved
|| newComment.textRange !== editCommentData.textRange)
return false;

if (newComment.anchorPos.replaceAll(" ", '') !== editCommentData.anchorPos.toString())
return true;
return false;
}

private actionPerformedByCurrentUser(obj: any): boolean {
return obj.comment.author === this.map._viewInfo[this.map._docLayer._editorId].username;
}

public onACKComment (obj: any): void {
var id;
const anyEdit = Comment.isAnyEdit();
if (anyEdit
&& !this.checkIfOnlyAnchorPosChanged(obj, anyEdit)
&& !anyEdit.sectionProperties.selfRemoved
&& anyEdit.sectionProperties.data.id === obj.comment.id
&& CommentSection.autoSavedComment !== anyEdit) {
&& CommentSection.autoSavedComment !== anyEdit
&& !this.actionPerformedByCurrentUser(obj)) {
this.handleCommentConflict(obj, anyEdit);
return;
}
Expand Down
Loading