I want to refresh my custom view once Comment got added or edited or deleted.
I want to refresh my custom view once Comment got added or edited or deleted.
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!
===================
Thanks for your input.
Please find point wise reply for given input below.
#1) ActiveDocument_ContentChanged:-
#2) var segmentSourceComments = segmentPair.Source.GetComments(); AND var segmentTargetComments = segmentPair.Target.GetComments();:
#3) var segmentParagraphComments = segmentPair.GetParagraphUnitProperties().Comments;:
I have managed to get all comments (Scope comment and Range comment). Here ActiveDocument_ContentChanged is called only in few scenarios (i.e. First time Add & Delete) so only half usable ;-)
Thanks,
-harshad
Hi Harshad,
yeah, I'd need to do as you're doing now and run through the scenarios/workflows.
Interesting that the contentChanged event is not fired when you edit a comment within the segment range scope, I would have expected the property change event to fire.
If I were developing this feature, I'd concentrate on catching all other cases in the ActiveSegmentChanged and perform the same comparison against CollectionA that you are managing on the document to identify changes.
In the meantime, I have added this to the list of API enhancements to expose an event that permits 3rd party developers to subscribe to comments changed. I'm not able to give you a time line when these enhancements will be available yet though.
Thank you for your all input and support,
P.
Thanks for adding this features in list of API enhancements.Once feature get implemented and become public then how one can know its available?
Once should able to subscribe Add_Comment, Delete_Comment, Edit_Comment of Comment Window. OR only one event say Comment_listener_event where base on ENUM one can able to find its added, deleted or edited.
Regards,
-Harshad
Thanks for adding this features in list of API enhancements.Once feature get implemented and become public then how one can know its available?
This information will be available in the release notes for Studio/GroupShare. So if you review the updates when they come out you will be able to see whether there has been any planned updates to the APIs.
As Paul, pointed out, this will be available in the release notes.
Once available, I would expect to see one event with eventArgs to denote the type of change (i.e. added, changed, deleted) + possibly other data such as the comment data. TBC