I would like to get the total number of comments associated with a referenceID, but I do not see any docs pointing to it.
Currently, it seems we are able to get comments related to a Post (saw on iOS docs), however for my case, I am not using post. I just use the comment feature with referenceID.
Can someone point me to the correct way to get the total count of the comments, please?
Same as for the iOS SDK, on Web SDK you can access the total number of comments if they are attached to the Post.
It is not mentioned in Web SDK documentation yet. We will make sure to fix it soon.
However, in relation to your use case, I can not give an answer right now. I have reached out to the development team to provide the latest update on the API in the development and to double-check is there a way for you to achieve the desired outcome at the moment. We will get back to you withing tomorrow.
At the same time, if you can provide more information about your use case and an example of parameters you send when you create a comment - it might help the team to advise you with potential workarounds.
The Standalone Comment concept what you are using when you create a comment with referenceType: 'content' actually creates a post in the background with the content type. Shortly, Content Post identifies that the post belongs to an external source, and SDK does NOT keep the Post data. Or in other words, we can say that this Post is “virtual” and represents the entity of content in your system.
You can see these post entities by Amity Console as well:
As a conclusion of it - you can actually access this post from SDK side:
import { PostRepository } from 'eko-sdk';
let commentsCount = 0;
// Note, that here I am using 'pageID' - the value
// you set to referenceId argument when you create the comment
const postLiveObject = PostRepository.postForId('pageID');
postLiveObject.once('dataUpdated', postData => {
commentsCount = postData.commentsCount;
});
I hope it solves your use case.
P.S.: The behavior that I described above is not represented in documentation yet. I have opened a ticket to update the documentation.
Could you please kindly help pointing to the correct documentation with this issue as we are unable to get the post currently as @jing mentioned above.
Any suggestion or workound will be highly appreciated.
We found a bug which prevented the post “content” to be fetched from the sdk. A patch has already been issued and should be included in the next release.
I’ll update this question when the updated working code is released!
we create the post live object first and watch for the commentCount update in the dataUpdated event of the post live object and it seems not trigger once we made a comment.
Or we need to fetch new post live object everytime users made or remove comments?
if the comment is created from the same client than were you watch the post, the comment count should increase since it should be locally computed.
if the comment is created from a different client than were you watch the post, then you will need to re-fetch the post because currently we don’t support realtime events for social (community, posts, comments).
On your the forked sandbox though, i’m not sure on what changed.