I am creating the post using LiveCollection amity create and getPost(subscribeCommunityTopic)but it does not show on the feed without reloading the app or refreshing the page. Also, the likes and comments are not being updated immediately. These also update after refreshing the page. Please help me sort these things out as I’m not getting live data while using the liveSubscription.
Hello @mustafa , Thank you for sharing the code and version details. To ensure optimal performance and access to the latest features and fixes, we recommend updating your SDK version. You can verify and update to the latest version using this link: https://docs.amity.co/amity-sdk/changelogs-and-versioning/ts.
I still have the live data fetching issues even after successfully updating the SDK version by following your provided link. Still, I’ve to reload the app to get likes, etc.
Do you think that something is missing?
Hello @mustafa , Here’s how you can address the issues you’re experiencing with the live updates for posts, likes, and comments. Please refer to the following code as a guideline:
const subscribePostTopic = useCallback((type: string, id: string) => {
if (isSubscribed) return;
if (type === 'user') {
let user = {} as Amity.User;
UserRepository.getUser(id, ({ data }) => {
user = data;
});
disposers.push(
subscribeTopic(getUserTopic(user, SubscriptionLevels.POST), () => {
// handle errors with event subscription here
})
);
isSubscribed = true;
return;
}
if (type === 'community') {
CommunityRepository.getCommunity(id, (data) => {
if (data.data) {
subscribeTopic(getCommunityTopic(data.data, SubscriptionLevels.POST));
}
});
}
}, []);
const getFeed = useCallback(() => {
const unsubscribe = PostRepository.getPosts(
{
targetId,
targetType,
sortBy: 'lastCreated',
limit: 10,
feedType: 'published',
},
(data) => {
setPostData(data);
subscribePostTopic(targetType, targetId);
}
);
setUnSubPageFunc(() => unsubscribe());
}, [subscribePostTopic, targetId, targetType]);
If you continue to experience issues, please feel free to reach out with any further questions.
It’s okay for live createPost, getPost and like reaction counter but in case of comment count and community following/unfollowing count, it needs to reload or refresh. Please help me to sort out this issue.
Hello @mustafa , For the community following/unfollowing count, could you please provide more details regarding the issue and capture a screenshot as well? This will help us better understand and assist you further.