Mention in Comments
You can mention users in comments and replies. Just type the @ symbol before the user display name. Typing @ also activates the mention search so you can select from the search result the display name of the users that you want to mention.
AmityComment
contains new properties related to mention feature:
metadata Dictionary which can contain any information about the current comment/reply. Our default structure to represent mentions is inside the metadata property. You can use any structure to represent mentions. There is a helper class which can transform metadata into mentions and vice versa -
AmityMentionMapper
. This class uses our custom structure of representing mentions in comments.mentionees Array of
AmityMentionees
objects. The type in mention for a comment/reply can be onlyuser
.
How mention works
You are free to define your own structure to represent mentions. To do this, use the metadata
property of AmityComment
and store mentions in metadata property.
To help you in this task, the SDK also provides the pre-defined mention structure. You can use our own mention structure by using these classes:
AmityMention
stores the auxiliary data; attached in a post metadata.AmityMentionMapper
A helper class to transformAmityMention
into metadata; or to extractAmityMention
from metadata.
The following example demonstrate how AmityMentionMapper
and AmityMention
works in a comment.
The function getAttributedString
uses AmityMentionMapper
to extract AmityMention
from metadata, and return the highlighted text.
Create a mention in comment/reply
To create a comment/reply with mentions, this is the method in AmityCommentRepository
:
To update a comment/reply with mentions, this is the method in AmityCommentEditor
:
Below is a sample code to create a comment/reply with mentions:
Update a comment/reply with mention
To update a comment or comment reply with mentions, use below sample code:
Last updated