[ts-sdk] PostRepository.getPosts - subscribe to comments

Hi Amity-Team,

I am in the process of migrating a React-native app (0.71) from the ts-sdk 0.0.1 to version 6.2.0.

And I have a problem with the liveCollection returned from PostRepository.

My Code looks like this:

	CommunityRepository.getCommunity(config.communityId, community => {
			const communityTopic = getCommunityTopic(
				community.data,
				SubscriptionLevels.POST_AND_COMMENT,
			);
			const topicUnsub = subscribeTopic(communityTopic, e => {
				e && console.error(e);
			});

			PostRepository.getPosts(
				{ targetId: config.communityId, targetType: 'community' },
				updatedPosts => {
					console.log(JSON.stringify(updatedPosts));
				},
			);
		});

So I am subscribing for post and comment updates and the console.log statement is written everytime I create a Post or add an reaction. So far so good.

In the Log I see:

Subscribed to topic 61..71/social/community/6...f9/post/#

What’s not working is comments. The SubscriptionLevels.POST_AND_COMMENT suggests that it should also work for those right?

When I use CommentRepository.getComments for a single Post it works but I have to create subscriptions for every single post in the community.

Is there something I am doing wrong here? Or whats the correct way to register for new Posts, Comments and Reactions is a community?

Thx

Hey @Avo,

Your code looks correct, I’ll raise a ticket and look into it. Thank you for raising this issue and also for providing the all the necessary info. Much appreciated.

Thanks,
Cijin

Hey @Avo ,

Update on this, I’ve checked that you do receive RTE events for both comments and post.

Just to clarify, you would need to call CommentRepository.getComments but subscribing to each post is not neccessary.

I’ll leave the ticket open though, till you confirm it’s working. Maybe I can update the docs for clarification.

Cijin

Thx for your feedback.

I believe the problem is caused by the fact that I was creating the comments witch client running on the old sdk version.
It works fine when I create comments with the new code.
So the subscription works correctly for my own comments.

I will retest this with two different users, but I think its solved for now.

Hey @Avo,

Awesome, thank you so much for the update.
Let me know if you have further question.

Cijin :slight_smile: