diff --git a/browser/src/canvas/sections/CommentListSection.ts b/browser/src/canvas/sections/CommentListSection.ts index 0b386dba8..1c96f4c12 100644 --- a/browser/src/canvas/sections/CommentListSection.ts +++ b/browser/src/canvas/sections/CommentListSection.ts @@ -1216,6 +1216,25 @@ export class CommentSection extends app.definitions.canvasSectionObject { public onACKComment (obj: any): void { var id; + const anyEdit = Comment.isAnyEdit(); + if (anyEdit && anyEdit.sectionProperties.data.id === obj.comment.id) { + if (document.getElementById(this.map.uiManager.generateModalId('comments-update'))) + return; + this.map.uiManager.showYesNoButton( + 'comments-update', + _('Comments updated'), + _('Another user has updated the comment. Would you like to overwrite those changes?'), + _('Overwrite'), + _('Update'), + null, + () => { + this.clearAutoSaveStatus(); + anyEdit.onCancelClick(null); + this.onACKComment(obj); + }, false + ); + return; + } var changetrack = obj.redline ? true : false; var dataroot = changetrack ? 'redline' : 'comment'; if (changetrack) { diff --git a/browser/src/canvas/sections/CommentSection.ts b/browser/src/canvas/sections/CommentSection.ts index e68ffadba..77bccb5f7 100644 --- a/browser/src/canvas/sections/CommentSection.ts +++ b/browser/src/canvas/sections/CommentSection.ts @@ -1033,11 +1033,11 @@ export class Comment extends app.definitions.canvasSectionObject { (this.sectionProperties.nodeReply && this.sectionProperties.nodeReply.style.display !== 'none')); } - public static isAnyEdit (): boolean { + public static isAnyEdit (): Comment { var section = app.sectionContainer && app.sectionContainer instanceof CanvasSectionContainer ? app.sectionContainer.getSectionWithName(L.CSections.CommentList.name) : null; if (!section) { - return false; + return null; } var commentList = section.sectionProperties.commentList; @@ -1047,9 +1047,9 @@ export class Comment extends app.definitions.canvasSectionObject { if (!commentList[i].pendingInit && ((modifyNode && modifyNode.style.display !== 'none') || (replyNode && replyNode.style.display !== 'none'))) - return true; + return commentList[i]; } - return false; + return null; } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types