Retrieve Comments
1. To retrieve comments in the frontend
To retreive all comments in the frontend, use the useCommentAnnotations()
hook. The hook will return an array that contains all current comments.
Whenever there is a change to the comments structure, the hook return value will be updated to the latest change.
The hook will automatically unsubscribe from the subscription when the component dismounts.
By default, useCommentAnnotations()
will return data for the current documentId
and location
.
If you pass in a documentId
as an argument, it will return all comments in the given documentId
.
If you pass in a documentId
as the first argument and a location
object as the second argument, it will return all comments in the given documentId
and location
.
2. To retrieve comments in the backend
For this you should use our Webhook service. Let’s say you want to be notified whenever a comment is added or updated, you can provide us an endpoint and we will send the comment data to that end point as and when there is an update. You can then process it further. Note that you cannot retrieve historical comments using this.
You can enable and configure webhook in your Velt Console as shown below. After you enable this, you need to provide an endpoint url. We will make a post request to that endpoint to send the comment data.
To read more about how to configure webhooks, check out the webhooks documentation.
3. Get Count of Unread CommentAnnotations On Current Document
You can get the number of CommentAnnotations
that have at least 1 unread Comment
on the current Document
by using the useUnreadCommentAnnotationCountOnCurrentDocument()
hook:
4. Get Count Of Unread Comments On Current Document
You can get the number of unread Comments
on the current Document
by using the useUnreadCommentCountOnCurrentDocument()
hook:
5. Get Count Of Unread CommentAnnotations By Location Id
You can get the number of CommentAnnotations
with at least 1 unread Comment
by Location Id
by using the useUnreadCommentAnnotationCountByLocationId()
hook:
6. Get Count Of Unread Comments By Location Id
You can get the number of unread Comments
by Location Id
by using the useUnreadCommentCountByLocationId()
hook:
7. Get Count Of Unread Comments By Annotation Id
You can get the number of unread Comments
by annotation id by using the useUnreadCommentCountByAnnotationId()
hook:
8. Get Selected Comments
- Get the currently selected comment annotations.
- This returns an array of
CommentAnnotation
objects.
Unsubscribe from the subscription when you’re done:
9. Get Comment Annotation by ID
- Retrieve a specific comment annotation by its ID.
- By default, it will return the comment annotation for the current
documentId
. - If you pass in a
documentId
, it will return the comment annotation for the givendocumentId
.
Using Hooks:
Using API:
To unsubscribe from the subscription:
Was this page helpful?