Hi there,
I just upgraded the TS SDK from “0.0.1-beta.39” to “^6.2.0,” and something happens strangely when I want to switch between two communities.
In our React-Native application, we have a bottom tab navigation called “Community” that shows our global community.
Some users have more than one community; that’s why we put a “Communities List” screen inside of it.
When the user press on another community (Considering its name is CommunityB), the app pushes another “Community” screen on the navigation stack and loads the CommunityB’s posts.
It works properly till now, also when the user press on the “Back” button to close (or unmount) CommunityB and goes to another Community (Considering its name is CommunityC), the Amity TS SDK can load CommunityC’s posts.
The problem shows up here when the user wants to close the CommunityC and go back to the CommunityB; the SDK doesn’t load the CommunityB’s posts.
Actually, the TS SDK doesn’t do anything, and I can’t see any response from PostRepository.getPosts()
In this video, I show you what’s happening exactly. (Link)
Here is my onQueryPost
code:
const onQueryPosts = useCallback(
async ({reset = false}) => {
console.log({
CommunityName: screenParams.communityName,
CommunityId: screenParams.communityId,
});
const queryData: Amity.PostLiveCollection = {
targetType: 'community',
targetId: screenParams.communityId,
feedType: 'published',
includeDeleted: false,
sortBy: 'lastCreated',
limit: 10,
};
PostRepository.getPosts(
queryData,
({data, loading, hasNextPage, onNextPage, origin, ...resOptions}) => {
console.log(`Posts Number: ${data.length}`);
if (data.length > 0) {
setPosts((prevPosts) =>
reset ? [...data] : [...prevPosts, ...data],
);
} else if (!data && resOptions.error) {
logger(resOptions.error, 'onQueryPosts, Community Feed');
}
setPostQueryOptions({
loading,
hasNextPage,
onNextPage,
origin: origin as string,
});
if (loading === false) {
setIsRefreshing(false);
}
},
);
},
[isRefreshing, screenParams.communityId],
);