Comments
Here's an overview of how you can get started integrating comments into your applications
Each comment is identified by a unique commentId
, which is an immutable string. When creating a new comment, you do not need to specify your own commentId
, and you can leave it to SDK to generate. We also provide optimistic update on each comment. You will need to send a referenceId
which is a contentId
for current supported version. You need to use EkoCommentRepository
before starting any activity with comments, such as editing an operation and/or flagging a comment.
In the future we may support another
referenceType
and will be available in creation method.
There are 2 main methods in EkoCommentRepository
which is creating a comment as well as get a collection of comments. They all return a LiveCollection with the comment model.
Comment management methods are contained in EkoCommentRepository
class. Before being able to call any comment method, you must initialise a repository instance using the EkoClient
instance ,which you created on setup:
Create Comment
EkoCommentRepository
provides createComment()
method to create comment. You can provide referenceId
, parentId
and text
while creating a comment. parentId
is an optional parameter, useful for replying a comment. The concept is similar to the EkoMessage
where you can reply a message object with a parentId
. For now, only text
data is supported in the creation method.
Comments Query
EkoCommentRepository
provides getCommentCollection()
method to query for comments. The query returns a LiveCollection of all the matching comments available.
To query for replies to a specific comment. You can pass the commentId as the parentIdparentId = commentId
. To get parent level, pass parentId = null
. Omitting parentId
will get all comments on all levels.
View Comment
Currently EkoComment
has one data type TEXT
. Other types are coming soon.
Edit Comment
Comment editing options depend on EkoComment
data type.
On EkoComment.Data.Text
model, there is an edit()
method that initiates text data editing chain. The replacing text can be passed to text()
method.
To delete a comment, the delete()
method is available on the EkoComment
model.
Flag Comment
On EkoCommentFlagger
modelflag()
and unflag
methods are available.
The info such as flagCount: Int
and isFlaggedByMe: Boolean
are also available in the EkoComment
model via getFlagCount()
and isFlaggedByMe()
methods respectively.
Reactions
EkoComment
provides react()
method to help instantiate EkoReactor
model.
In EkoReactor
modeladdReaction()
and removeReaction()
methods are available.
EkoComment
model provides info such as the reactions reactionCount: Int
,myReactions: List<String>
, reactionMap: EkoReactionMap
via getReactionCount()
, getMyReactions()
, and getReactionMap()
methods respectively.
Last updated