How can we listen comment added, updated and deleted events in custom view?

I want to refresh my custom view once Comment got added or edited or deleted.

Parents
  • Hi ,

    Created new thread and copy/paste your response below.

    ================

    • Hi Harshad,

      You can't subscribe to an event through the Integration API; but you can potentially listen for changes and intuitively deduct when comments are added/removed.

      Start by subscribing to the ActiveDocumentChanged event on the EditorController.

      Then subscribe to the ActiveSegmentChanged, ContentChanged events when active document changes.

      Manage a collection on the document to identify the list of comments associated with each of the segmentPairs (read when the document is loaded).  Call this CollectionA

      Note: when you add a comment to the segment, the content changed event is fired. Understanding this, you would only need to get the current list of comments for the active segment pair and then compare it against a comments for the segment mentioned in CollectionA that you are managing on the document.

      private void ActiveDocument_ContentChanged(object sender, DocumentContentEventArgs e)
      {

      [...]

           var segmentSourceComments = segmentPair.Source.GetComments();
           var segmentTargetComments = segmentPair.Target.GetComments();
           var segmentParagraphComments = segmentPair.GetParagraphUnitProperties().Comments;

          // Compare list of comments listed here against what was initially read in CollectionA
          // Identify what was added or removed
          // if different, do something!
          // update CollectionA with the new list of comments for the SegmentPair (if different)

      [...]

      }

      similarly, perform same check in the ActiveSegmentChanged; to cover cases where the content structure of the segment didn't change; I'd need to check but might be that if the scope of the comment is at the paragraph level, then the ContentChanged is not fired!

      ===================

Reply
  • Hi ,

    Created new thread and copy/paste your response below.

    ================

    • Hi Harshad,

      You can't subscribe to an event through the Integration API; but you can potentially listen for changes and intuitively deduct when comments are added/removed.

      Start by subscribing to the ActiveDocumentChanged event on the EditorController.

      Then subscribe to the ActiveSegmentChanged, ContentChanged events when active document changes.

      Manage a collection on the document to identify the list of comments associated with each of the segmentPairs (read when the document is loaded).  Call this CollectionA

      Note: when you add a comment to the segment, the content changed event is fired. Understanding this, you would only need to get the current list of comments for the active segment pair and then compare it against a comments for the segment mentioned in CollectionA that you are managing on the document.

      private void ActiveDocument_ContentChanged(object sender, DocumentContentEventArgs e)
      {

      [...]

           var segmentSourceComments = segmentPair.Source.GetComments();
           var segmentTargetComments = segmentPair.Target.GetComments();
           var segmentParagraphComments = segmentPair.GetParagraphUnitProperties().Comments;

          // Compare list of comments listed here against what was initially read in CollectionA
          // Identify what was added or removed
          // if different, do something!
          // update CollectionA with the new list of comments for the SegmentPair (if different)

      [...]

      }

      similarly, perform same check in the ActiveSegmentChanged; to cover cases where the content structure of the segment didn't change; I'd need to check but might be that if the scope of the comment is at the paragraph level, then the ContentChanged is not fired!

      ===================

Children