From 3243d0d0066863829370033b2b125291e70691ad Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Mon, 23 Dec 2024 19:45:45 +0530 Subject: [PATCH 1/2] comments: avoid comment conflict dialog on position change problem: when a user is editing comment and makes some changes to the document text which moves the comment, user used to get comment conflict dialog without any real changes to comment which confused users Signed-off-by: Pranam Lashkari Change-Id: Ifc6cbe51bc7caecb02a6ac099e6530dded45743b --- .../src/canvas/sections/CommentListSection.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/browser/src/canvas/sections/CommentListSection.ts b/browser/src/canvas/sections/CommentListSection.ts index 82b5181c0055..139934c5f78f 100644 --- a/browser/src/canvas/sections/CommentListSection.ts +++ b/browser/src/canvas/sections/CommentListSection.ts @@ -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; @@ -1455,10 +1456,32 @@ 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; + } + 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) { From ccf7bb33308556860eacf098f023bf137458d3bc Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Tue, 24 Dec 2024 12:08:32 +0530 Subject: [PATCH 2/2] annotation: avoid comment conflict warning when irrelevan avoid comment conflict dialog when changes are done by current user itself problem: when autosaved comments are still in edit mode and user undo the comment action user used to get warning "another user removed comment" Signed-off-by: Pranam Lashkari Change-Id: I8578443f6f4e31f441c9e8ce4c77ec276d9a5d6a --- browser/src/canvas/sections/CommentListSection.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/browser/src/canvas/sections/CommentListSection.ts b/browser/src/canvas/sections/CommentListSection.ts index 139934c5f78f..f5ecb3762b60 100644 --- a/browser/src/canvas/sections/CommentListSection.ts +++ b/browser/src/canvas/sections/CommentListSection.ts @@ -1477,6 +1477,10 @@ export class CommentSection extends app.definitions.canvasSectionObject { 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(); @@ -1484,7 +1488,8 @@ export class CommentSection extends app.definitions.canvasSectionObject { && !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; }