@amityco/ts-sdk-react-native 6.14.1 → 6.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +6 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/live.d.ts +5 -3
- package/dist/@types/core/live.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +14 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts +2 -1
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/domains/analytics.d.ts +4 -1
- package/dist/@types/domains/analytics.d.ts.map +1 -1
- package/dist/@types/domains/category.d.ts +2 -1
- package/dist/@types/domains/category.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +3 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +1 -1
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +8 -3
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +15 -0
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/messagePreview.d.ts +1 -1
- package/dist/@types/domains/messagePreview.d.ts.map +1 -1
- package/dist/@types/domains/partials.d.ts +9 -0
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +3 -2
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/story.d.ts +126 -0
- package/dist/@types/domains/story.d.ts.map +1 -0
- package/dist/@types/domains/stream.d.ts +2 -1
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/domains/subChannel.d.ts +1 -1
- package/dist/@types/domains/subChannel.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/analytic/constant.d.ts +1 -0
- package/dist/analytic/constant.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +1 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +5 -0
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts +2 -0
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts.map +1 -1
- package/dist/categoryRepository/internalApi/queryCategories.d.ts +2 -2
- package/dist/categoryRepository/internalApi/queryCategories.d.ts.map +1 -1
- package/dist/categoryRepository/observers/getCategories.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +1 -1
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/liveCollection/ChannelMemberLiveCollectionController.d.ts +14 -0
- package/dist/channelRepository/channelMembership/observers/liveCollection/ChannelMemberLiveCollectionController.d.ts.map +1 -0
- package/dist/channelRepository/channelMembership/observers/liveCollection/ChannelMemberPaginationController.d.ts +13 -0
- package/dist/channelRepository/channelMembership/observers/liveCollection/ChannelMemberPaginationController.d.ts.map +1 -0
- package/dist/channelRepository/channelMembership/observers/liveCollection/ChannelMemberQueryStreamController.d.ts +14 -0
- package/dist/channelRepository/channelMembership/observers/liveCollection/ChannelMemberQueryStreamController.d.ts.map +1 -0
- package/dist/channelRepository/observers/getChannels.d.ts.map +1 -1
- package/dist/channelRepository/observers/liveCollection/ChannelLiveCollectionController.d.ts +19 -0
- package/dist/channelRepository/observers/liveCollection/ChannelLiveCollectionController.d.ts.map +1 -0
- package/dist/channelRepository/observers/liveCollection/ChannelPaginationController.d.ts +14 -0
- package/dist/channelRepository/observers/liveCollection/ChannelPaginationController.d.ts.map +1 -0
- package/dist/channelRepository/observers/liveCollection/ChannelPagnationNoPageController.d.ts +5 -0
- package/dist/channelRepository/observers/liveCollection/ChannelPagnationNoPageController.d.ts.map +1 -0
- package/dist/channelRepository/observers/liveCollection/ChannelQueryStreamController.d.ts +17 -0
- package/dist/channelRepository/observers/liveCollection/ChannelQueryStreamController.d.ts.map +1 -0
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts +1 -0
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/communityRepository/api/createCommunity.d.ts +1 -1
- package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/updateCommunity.d.ts +1 -1
- package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/queryCommunityMembers.d.ts +2 -7
- package/dist/communityRepository/communityMembership/api/queryCommunityMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities.d.ts.map +1 -1
- package/dist/communityRepository/utils/payload.d.ts +2 -1
- package/dist/communityRepository/utils/payload.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/liveCollection/LiveCollectionController.d.ts +3 -2
- package/dist/core/liveCollection/LiveCollectionController.d.ts.map +1 -1
- package/dist/core/liveCollection/PaginationNoPageController.d.ts +9 -0
- package/dist/core/liveCollection/PaginationNoPageController.d.ts.map +1 -0
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/query/sorting.d.ts +14 -0
- package/dist/core/query/sorting.d.ts.map +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +36 -2
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts +24 -6
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/index.cjs.js +7936 -7216
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +5842 -5121
- package/dist/index.umd.js +4 -4
- package/dist/marker/api/getChannelMarkers.d.ts +2 -5
- package/dist/marker/api/getChannelMarkers.d.ts.map +1 -1
- package/dist/marker/api/getMessageMarkers.d.ts +3 -4
- package/dist/marker/api/getMessageMarkers.d.ts.map +1 -1
- package/dist/marker/events/onMessageMarked.d.ts.map +1 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -47
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messageRepository/observers/liveCollection/MessageLiveCollectionController.d.ts.map +1 -1
- package/dist/messageRepository/observers/liveCollection/MessageQueryStreamController.d.ts +1 -1
- package/dist/messageRepository/observers/liveCollection/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/api/queryPosts.d.ts +1 -1
- package/dist/postRepository/api/queryPosts.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts.d.ts.map +1 -1
- package/dist/role/api/queryRoles.d.ts +9 -1
- package/dist/role/api/queryRoles.d.ts.map +1 -1
- package/dist/storyRepository/api/createImageStory.d.ts +17 -0
- package/dist/storyRepository/api/createImageStory.d.ts.map +1 -0
- package/dist/storyRepository/api/createVideoStory.d.ts +15 -0
- package/dist/storyRepository/api/createVideoStory.d.ts.map +1 -0
- package/dist/storyRepository/api/hardDeleteStory.d.ts +2 -0
- package/dist/storyRepository/api/hardDeleteStory.d.ts.map +1 -0
- package/dist/storyRepository/api/index.d.ts +5 -0
- package/dist/storyRepository/api/index.d.ts.map +1 -0
- package/dist/storyRepository/api/softDeleteStory.d.ts +2 -0
- package/dist/storyRepository/api/softDeleteStory.d.ts.map +1 -0
- package/dist/storyRepository/events/onStoryCreated.d.ts +2 -0
- package/dist/storyRepository/events/onStoryCreated.d.ts.map +1 -0
- package/dist/storyRepository/events/onStoryDeleted.d.ts +2 -0
- package/dist/storyRepository/events/onStoryDeleted.d.ts.map +1 -0
- package/dist/storyRepository/events/onStoryError.d.ts +2 -0
- package/dist/storyRepository/events/onStoryError.d.ts.map +1 -0
- package/dist/storyRepository/index.d.ts +3 -0
- package/dist/storyRepository/index.d.ts.map +1 -0
- package/dist/storyRepository/internalApi/createStory.d.ts +2 -0
- package/dist/storyRepository/internalApi/createStory.d.ts.map +1 -0
- package/dist/storyRepository/internalApi/deleteStory.d.ts +2 -0
- package/dist/storyRepository/internalApi/deleteStory.d.ts.map +1 -0
- package/dist/storyRepository/internalApi/getActiveStoriesByTarget.d.ts +2 -0
- package/dist/storyRepository/internalApi/getActiveStoriesByTarget.d.ts.map +1 -0
- package/dist/storyRepository/observers/getActiveStoriesByTarget.d.ts +2 -0
- package/dist/storyRepository/observers/getActiveStoriesByTarget.d.ts.map +1 -0
- package/dist/storyRepository/observers/index.d.ts +2 -0
- package/dist/storyRepository/observers/index.d.ts.map +1 -0
- package/dist/storyRepository/utils/convertRawToStory.d.ts +3 -0
- package/dist/storyRepository/utils/convertRawToStory.d.ts.map +1 -0
- package/dist/storyRepository/utils/convertStoryPayloadToRaw.d.ts +2 -0
- package/dist/storyRepository/utils/convertStoryPayloadToRaw.d.ts.map +1 -0
- package/dist/storyRepository/utils/createOptimisticEvent.d.ts +6 -0
- package/dist/storyRepository/utils/createOptimisticEvent.d.ts.map +1 -0
- package/dist/storyRepository/utils/getStoryCache.d.ts +5 -0
- package/dist/storyRepository/utils/getStoryCache.d.ts.map +1 -0
- package/dist/streamRepository/api/index.d.ts.map +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts +2 -0
- package/dist/streamRepository/api/queryStreams.d.ts.map +1 -1
- package/dist/streamRepository/internalApi/queryStreams.d.ts +16 -0
- package/dist/streamRepository/internalApi/queryStreams.d.ts.map +1 -0
- package/dist/streamRepository/observers/getStreams.d.ts +1 -1
- package/dist/streamRepository/observers/getStreams.d.ts.map +1 -1
- package/dist/subChannelRepository/observers/getSubChannels.d.ts.map +1 -1
- package/dist/subChannelRepository/observers/liveCollection/SubChannelLiveCollectionController.d.ts +14 -0
- package/dist/subChannelRepository/observers/liveCollection/SubChannelLiveCollectionController.d.ts.map +1 -0
- package/dist/subChannelRepository/observers/liveCollection/SubChannelPaginationController.d.ts +9 -0
- package/dist/subChannelRepository/observers/liveCollection/SubChannelPaginationController.d.ts.map +1 -0
- package/dist/subChannelRepository/observers/liveCollection/SubChannelQueryStreamController.d.ts +14 -0
- package/dist/subChannelRepository/observers/liveCollection/SubChannelQueryStreamController.d.ts.map +1 -0
- package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts +1 -0
- package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +5 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/storyLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/storyLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/dummy/channel.d.ts +9 -0
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +8 -1
- package/src/@types/core/live.ts +7 -4
- package/src/@types/core/model.ts +6 -0
- package/src/@types/core/payload.ts +19 -0
- package/src/@types/core/permissions.ts +1 -0
- package/src/@types/domains/analytics.ts +4 -1
- package/src/@types/domains/category.ts +2 -1
- package/src/@types/domains/channel.ts +4 -1
- package/src/@types/domains/comment.ts +1 -1
- package/src/@types/domains/community.ts +11 -5
- package/src/@types/domains/feed.ts +16 -0
- package/src/@types/domains/messagePreview.ts +1 -1
- package/src/@types/domains/partials.ts +12 -0
- package/src/@types/domains/post.ts +3 -2
- package/src/@types/domains/story.ts +150 -0
- package/src/@types/domains/stream.ts +2 -1
- package/src/@types/domains/subChannel.ts +1 -1
- package/src/@types/index.ts +1 -3
- package/src/analytic/constant.ts +2 -1
- package/src/analytic/service/analytic/AnalyticsEngine.ts +9 -0
- package/src/analytic/service/analytic/AnalyticsEventCapturer.ts +63 -10
- package/src/analytic/service/analytic/AnalyticsEventSyncer.ts +34 -4
- package/src/categoryRepository/internalApi/queryCategories.ts +25 -18
- package/src/categoryRepository/observers/getCategories.ts +4 -3
- package/src/channelRepository/api/createChannel.ts +7 -3
- package/src/channelRepository/channelMembership/observers/getMembers.ts +9 -123
- package/src/channelRepository/channelMembership/observers/liveCollection/ChannelMemberLiveCollectionController.ts +154 -0
- package/src/channelRepository/channelMembership/observers/liveCollection/ChannelMemberPaginationController.ts +28 -0
- package/src/channelRepository/channelMembership/observers/liveCollection/ChannelMemberQueryStreamController.ts +109 -0
- package/src/channelRepository/channelMembership/observers/tests/getMembers.test.ts +3 -1
- package/src/channelRepository/observers/getChannels.ts +10 -316
- package/src/channelRepository/observers/liveCollection/ChannelLiveCollectionController.ts +413 -0
- package/src/channelRepository/observers/liveCollection/ChannelPaginationController.ts +36 -0
- package/src/channelRepository/observers/liveCollection/ChannelPagnationNoPageController.ts +20 -0
- package/src/channelRepository/observers/liveCollection/ChannelQueryStreamController.ts +89 -0
- package/src/channelRepository/observers/tests/getChannel.test.ts +4 -1
- package/src/channelRepository/observers/tests/getChannels.test.ts +153 -40
- package/src/channelRepository/utils/prepareChannelPayload.ts +1 -1
- package/src/client/utils/markerSyncEngine.ts +1 -1
- package/src/communityRepository/api/createCommunity.ts +7 -6
- package/src/communityRepository/api/queryCommunities.ts +12 -14
- package/src/communityRepository/api/test/queryCommunity.test.ts +18 -12
- package/src/communityRepository/api/updateCommunity.ts +4 -3
- package/src/communityRepository/communityMembership/api/queryCommunityMembers.ts +26 -25
- package/src/communityRepository/communityMembership/observers/getMembers.ts +4 -3
- package/src/communityRepository/observers/getCommunities.ts +8 -5
- package/src/communityRepository/utils/payload.ts +7 -2
- package/src/core/liveCollection/LiveCollectionController.ts +19 -5
- package/src/core/liveCollection/PaginationNoPageController.ts +26 -0
- package/src/core/model/idResolvers.ts +2 -0
- package/src/core/model/index.ts +2 -0
- package/src/core/query/sorting.ts +18 -0
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +50 -8
- package/src/feedRepository/api/queryGlobalFeed.ts +56 -12
- package/src/index.ts +2 -1
- package/src/marker/api/getChannelMarkers.ts +6 -16
- package/src/marker/api/getMessageMarkers.ts +12 -20
- package/src/marker/api/tests/getChannelMarkers.test.ts +1 -11
- package/src/marker/api/tests/getMessageMarkers.test.ts +1 -11
- package/src/marker/events/onMessageMarked.ts +4 -5
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +9 -2
- package/src/messageRepository/observers/liveCollection/MessageLiveCollectionController.ts +1 -0
- package/src/messageRepository/observers/liveCollection/MessageQueryStreamController.ts +2 -1
- package/src/postRepository/api/queryPosts.ts +12 -10
- package/src/postRepository/observers/getPosts.ts +7 -4
- package/src/role/api/queryRoles.ts +25 -6
- package/src/storyRepository/api/createImageStory.ts +94 -0
- package/src/storyRepository/api/createVideoStory.ts +92 -0
- package/src/storyRepository/api/hardDeleteStory.ts +6 -0
- package/src/storyRepository/api/index.ts +4 -0
- package/src/storyRepository/api/softDeleteStory.ts +6 -0
- package/src/storyRepository/events/onStoryCreated.ts +14 -0
- package/src/storyRepository/events/onStoryDeleted.ts +14 -0
- package/src/storyRepository/events/onStoryError.ts +14 -0
- package/src/storyRepository/index.ts +2 -0
- package/src/storyRepository/internalApi/createStory.ts +26 -0
- package/src/storyRepository/internalApi/deleteStory.ts +35 -0
- package/src/storyRepository/internalApi/getActiveStoriesByTarget.ts +36 -0
- package/src/storyRepository/observers/getActiveStoriesByTarget.ts +163 -0
- package/src/storyRepository/observers/index.ts +1 -0
- package/src/storyRepository/utils/convertRawToStory.ts +16 -0
- package/src/storyRepository/utils/convertStoryPayloadToRaw.ts +43 -0
- package/src/storyRepository/utils/createOptimisticEvent.ts +63 -0
- package/src/storyRepository/utils/getStoryCache.ts +6 -0
- package/src/streamRepository/api/index.ts +1 -1
- package/src/streamRepository/api/queryStreams.ts +2 -0
- package/src/streamRepository/internalApi/queryStreams.ts +57 -0
- package/src/streamRepository/observers/getStreams.ts +6 -5
- package/src/subChannelRepository/observers/getSubChannels.ts +8 -228
- package/src/subChannelRepository/observers/liveCollection/SubChannelLiveCollectionController.ts +274 -0
- package/src/subChannelRepository/observers/liveCollection/SubChannelPaginationController.ts +35 -0
- package/src/subChannelRepository/observers/liveCollection/SubChannelQueryStreamController.ts +94 -0
- package/src/subChannelRepository/observers/tests/getSubChannels.test.ts +73 -45
- package/src/subChannelRepository/observers/tests/getSubChannelsWithMessagePreview.test.ts +58 -21
- package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +1 -1
- package/src/utils/constants.ts +5 -0
- package/src/utils/linkedObject/commentLinkedObject.ts +3 -1
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/postLinkedObject.ts +4 -2
- package/src/utils/linkedObject/storyLinkedObject.ts +83 -0
- package/src/utils/tests/dummy/channel.ts +14 -4
- package/dist/categoryRepository/api/queryCategories.d.ts +0 -32
- package/dist/categoryRepository/api/queryCategories.d.ts.map +0 -1
- package/src/categoryRepository/api/queryCategories.ts +0 -116
|
@@ -28,10 +28,12 @@ import {
|
|
|
28
28
|
channelLastActivity2,
|
|
29
29
|
channelLastActivity3,
|
|
30
30
|
channelDisplayName4,
|
|
31
|
+
channelQueryResponseWithoutPaging,
|
|
31
32
|
} from '~/utils/tests';
|
|
32
33
|
|
|
33
34
|
import { getChannels } from '../getChannels';
|
|
34
35
|
import * as getChannelMarkers from '../../../marker/api/getChannelMarkers';
|
|
36
|
+
import { getChannelMessagePreviewWithUser } from '~/messagePreview/utils';
|
|
35
37
|
|
|
36
38
|
const getSnapshot = (params?: Record<string, any>) => {
|
|
37
39
|
return {
|
|
@@ -82,11 +84,7 @@ describe('getChannels', () => {
|
|
|
82
84
|
);
|
|
83
85
|
});
|
|
84
86
|
|
|
85
|
-
test
|
|
86
|
-
/**
|
|
87
|
-
* skip this unit test because the behaviour is changed.
|
|
88
|
-
* when calling getChannels(), it will create a new instance of the channel collection.
|
|
89
|
-
*/
|
|
87
|
+
test('it should return data from cache first when call with the same query', async () => {
|
|
90
88
|
const callback = jest.fn();
|
|
91
89
|
client.http.get = jest.fn().mockResolvedValue(channelQueryResponse);
|
|
92
90
|
|
|
@@ -100,7 +98,10 @@ describe('getChannels', () => {
|
|
|
100
98
|
1,
|
|
101
99
|
expect.objectContaining(
|
|
102
100
|
getSnapshot({
|
|
103
|
-
data:
|
|
101
|
+
data: convertRawChannelPayload(channelQueryResponse.data).channels.map(
|
|
102
|
+
getChannelMessagePreviewWithUser,
|
|
103
|
+
),
|
|
104
|
+
loading: true,
|
|
104
105
|
}),
|
|
105
106
|
),
|
|
106
107
|
);
|
|
@@ -108,7 +109,9 @@ describe('getChannels', () => {
|
|
|
108
109
|
2,
|
|
109
110
|
expect.objectContaining(
|
|
110
111
|
getSnapshot({
|
|
111
|
-
data: convertRawChannelPayload(channelQueryResponse.data).channels
|
|
112
|
+
data: convertRawChannelPayload(channelQueryResponse.data).channels.map(
|
|
113
|
+
getChannelMessagePreviewWithUser,
|
|
114
|
+
),
|
|
112
115
|
loading: false,
|
|
113
116
|
}),
|
|
114
117
|
),
|
|
@@ -119,16 +122,19 @@ describe('getChannels', () => {
|
|
|
119
122
|
const rawDeletedChannel = generateRawChannel({
|
|
120
123
|
channelId: 'deleted-channel-id',
|
|
121
124
|
isDeleted: true,
|
|
125
|
+
type: 'conversation',
|
|
122
126
|
});
|
|
123
127
|
const deletedChannel = convertChannelFromRaw(rawDeletedChannel);
|
|
124
128
|
const rawTaggedChannel = generateRawChannel({
|
|
125
129
|
channelId: 'tagged-channel-id',
|
|
126
130
|
tags: ['tag1', 'tag2'],
|
|
131
|
+
type: 'conversation',
|
|
127
132
|
});
|
|
128
133
|
const taggedChannel = convertChannelFromRaw(rawTaggedChannel);
|
|
129
134
|
const rawTaggedChannel2 = generateRawChannel({
|
|
130
135
|
channelId: 'tagged-channel-id-2',
|
|
131
136
|
tags: ['tag2'],
|
|
137
|
+
type: 'conversation',
|
|
132
138
|
});
|
|
133
139
|
const taggedChannel2 = convertChannelFromRaw(rawTaggedChannel2);
|
|
134
140
|
|
|
@@ -159,10 +165,6 @@ describe('getChannels', () => {
|
|
|
159
165
|
{ ...taggedChannel2, messagePreview: null },
|
|
160
166
|
],
|
|
161
167
|
],
|
|
162
|
-
/**
|
|
163
|
-
* TODO: skip this test because the behaviour is changed.
|
|
164
|
-
* The member filter is not supported yet. SDK use filter member response from backend, so skip this test
|
|
165
|
-
*/
|
|
166
168
|
['member', { membership: 'member' }, [channel1]],
|
|
167
169
|
[
|
|
168
170
|
'not member',
|
|
@@ -309,7 +311,7 @@ describe('getChannels', () => {
|
|
|
309
311
|
expect.objectContaining(
|
|
310
312
|
getSnapshot({
|
|
311
313
|
loading: false,
|
|
312
|
-
data: expected.map(convertChannelFromRaw),
|
|
314
|
+
data: expected.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
313
315
|
}),
|
|
314
316
|
),
|
|
315
317
|
);
|
|
@@ -340,7 +342,7 @@ describe('getChannels', () => {
|
|
|
340
342
|
expect.objectContaining(
|
|
341
343
|
getSnapshot({
|
|
342
344
|
loading: false,
|
|
343
|
-
data: expected.map(convertChannelFromRaw),
|
|
345
|
+
data: expected.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
344
346
|
}),
|
|
345
347
|
),
|
|
346
348
|
);
|
|
@@ -351,12 +353,7 @@ describe('getChannels', () => {
|
|
|
351
353
|
test('when querying two channel collections using different parameters, the results from each collection remain distinct and do not overlap', async () => {
|
|
352
354
|
const callback = jest.fn();
|
|
353
355
|
const callback2 = jest.fn();
|
|
354
|
-
const callback1Response = [
|
|
355
|
-
channelDisplayName2,
|
|
356
|
-
channelDisplayName1,
|
|
357
|
-
channelDisplayName3,
|
|
358
|
-
channelDisplayName4,
|
|
359
|
-
];
|
|
356
|
+
const callback1Response = [channelDisplayName2, channelDisplayName1, channelDisplayName3];
|
|
360
357
|
const callback1Expected = [channelDisplayName1, channelDisplayName2, channelDisplayName3];
|
|
361
358
|
const callback2Response = [channelCreatedAt3, channelCreatedAt2, channelCreatedAt1];
|
|
362
359
|
|
|
@@ -395,7 +392,7 @@ describe('getChannels', () => {
|
|
|
395
392
|
expect.objectContaining(
|
|
396
393
|
getSnapshot({
|
|
397
394
|
loading: false,
|
|
398
|
-
data: callback1Expected.map(convertChannelFromRaw),
|
|
395
|
+
data: callback1Expected.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
399
396
|
}),
|
|
400
397
|
),
|
|
401
398
|
);
|
|
@@ -404,7 +401,7 @@ describe('getChannels', () => {
|
|
|
404
401
|
expect.objectContaining(
|
|
405
402
|
getSnapshot({
|
|
406
403
|
loading: false,
|
|
407
|
-
data: callback2Response.map(convertChannelFromRaw),
|
|
404
|
+
data: callback2Response.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
408
405
|
}),
|
|
409
406
|
),
|
|
410
407
|
);
|
|
@@ -417,7 +414,7 @@ describe('getChannels', () => {
|
|
|
417
414
|
expect.objectContaining(
|
|
418
415
|
getSnapshot({
|
|
419
416
|
loading: false,
|
|
420
|
-
data: callback1Expected.map(convertChannelFromRaw),
|
|
417
|
+
data: callback1Expected.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
421
418
|
}),
|
|
422
419
|
),
|
|
423
420
|
);
|
|
@@ -426,7 +423,7 @@ describe('getChannels', () => {
|
|
|
426
423
|
expect.objectContaining(
|
|
427
424
|
getSnapshot({
|
|
428
425
|
loading: false,
|
|
429
|
-
data: callback2Response.map(convertChannelFromRaw),
|
|
426
|
+
data: callback2Response.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
430
427
|
}),
|
|
431
428
|
),
|
|
432
429
|
);
|
|
@@ -439,7 +436,7 @@ describe('getChannels', () => {
|
|
|
439
436
|
expect.objectContaining(
|
|
440
437
|
getSnapshot({
|
|
441
438
|
loading: false,
|
|
442
|
-
data: callback1Expected.map(convertChannelFromRaw),
|
|
439
|
+
data: callback1Expected.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
443
440
|
}),
|
|
444
441
|
),
|
|
445
442
|
);
|
|
@@ -448,7 +445,7 @@ describe('getChannels', () => {
|
|
|
448
445
|
expect.objectContaining(
|
|
449
446
|
getSnapshot({
|
|
450
447
|
loading: false,
|
|
451
|
-
data: callback2Response.map(convertChannelFromRaw),
|
|
448
|
+
data: callback2Response.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
452
449
|
}),
|
|
453
450
|
),
|
|
454
451
|
);
|
|
@@ -503,7 +500,9 @@ describe('getChannels', () => {
|
|
|
503
500
|
channelUsers: [rawChannelUser],
|
|
504
501
|
files: [],
|
|
505
502
|
users: [user11],
|
|
506
|
-
|
|
503
|
+
paging: {
|
|
504
|
+
next: 'eyJza2lwIjowLCJsaW1pdCI6MTB9',
|
|
505
|
+
},
|
|
507
506
|
},
|
|
508
507
|
});
|
|
509
508
|
}
|
|
@@ -521,7 +520,10 @@ describe('getChannels', () => {
|
|
|
521
520
|
},
|
|
522
521
|
});
|
|
523
522
|
}
|
|
524
|
-
if (
|
|
523
|
+
if (
|
|
524
|
+
params?.params?.options?.token ===
|
|
525
|
+
'eyJsaW1pdCI6MiwiYmVmb3JlIjo2MzQ3MTYxNDQ5MTExMTAwMDAwMH0='
|
|
526
|
+
) {
|
|
525
527
|
return Promise.resolve({
|
|
526
528
|
data: {
|
|
527
529
|
channels: returnValue2Page3,
|
|
@@ -541,7 +543,9 @@ describe('getChannels', () => {
|
|
|
541
543
|
channelUsers: [rawChannelUser],
|
|
542
544
|
files: [],
|
|
543
545
|
users: [user11],
|
|
544
|
-
|
|
546
|
+
paging: {
|
|
547
|
+
next: 'eyJza2lwIjowLCJsaW1pdCI6MTB9',
|
|
548
|
+
},
|
|
545
549
|
},
|
|
546
550
|
});
|
|
547
551
|
});
|
|
@@ -551,7 +555,7 @@ describe('getChannels', () => {
|
|
|
551
555
|
|
|
552
556
|
expect(spyGet).toHaveBeenCalledWith('/api/v3/channels', {
|
|
553
557
|
params: {
|
|
554
|
-
options: {
|
|
558
|
+
options: { limit: 5 }, // default limit in SDK
|
|
555
559
|
},
|
|
556
560
|
});
|
|
557
561
|
|
|
@@ -570,7 +574,7 @@ describe('getChannels', () => {
|
|
|
570
574
|
|
|
571
575
|
expect(callback).lastCalledWith(
|
|
572
576
|
expect.objectContaining({
|
|
573
|
-
data: returnValue1Page1.map(convertChannelFromRaw),
|
|
577
|
+
data: returnValue1Page1.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
574
578
|
error: undefined,
|
|
575
579
|
loading: false,
|
|
576
580
|
}),
|
|
@@ -578,17 +582,18 @@ describe('getChannels', () => {
|
|
|
578
582
|
|
|
579
583
|
expect(callback2).lastCalledWith(
|
|
580
584
|
expect.objectContaining({
|
|
581
|
-
data: returnValue2Page1.map(convertChannelFromRaw),
|
|
585
|
+
data: returnValue2Page1.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
582
586
|
error: undefined,
|
|
583
587
|
loading: false,
|
|
584
588
|
}),
|
|
585
589
|
);
|
|
586
590
|
|
|
587
|
-
// get
|
|
591
|
+
// get page 2 for live collection #2
|
|
588
592
|
callback2.mock.lastCall[0].onNextPage();
|
|
589
593
|
|
|
590
594
|
await pause(100);
|
|
591
595
|
|
|
596
|
+
// get page 3 for live collection #2
|
|
592
597
|
callback2.mock.lastCall[0].onNextPage();
|
|
593
598
|
|
|
594
599
|
await pause(100);
|
|
@@ -596,7 +601,7 @@ describe('getChannels', () => {
|
|
|
596
601
|
expect(callback.mock.calls.length).toBeGreaterThan(1);
|
|
597
602
|
expect(callback).lastCalledWith(
|
|
598
603
|
expect.objectContaining({
|
|
599
|
-
data: returnValue1Page1.map(convertChannelFromRaw),
|
|
604
|
+
data: returnValue1Page1.map(convertChannelFromRaw).map(getChannelMessagePreviewWithUser),
|
|
600
605
|
error: undefined,
|
|
601
606
|
loading: false,
|
|
602
607
|
}),
|
|
@@ -605,15 +610,15 @@ describe('getChannels', () => {
|
|
|
605
610
|
expect(callback2.mock.calls.length).toBe(6);
|
|
606
611
|
expect(callback2).lastCalledWith(
|
|
607
612
|
expect.objectContaining({
|
|
608
|
-
data: [...returnValue2Page1, ...returnValue2Page2, ...returnValue2Page3]
|
|
609
|
-
convertChannelFromRaw
|
|
610
|
-
|
|
613
|
+
data: [...returnValue2Page1, ...returnValue2Page2, ...returnValue2Page3]
|
|
614
|
+
.map(convertChannelFromRaw)
|
|
615
|
+
.map(getChannelMessagePreviewWithUser),
|
|
611
616
|
error: undefined,
|
|
612
617
|
loading: false,
|
|
613
618
|
}),
|
|
614
619
|
);
|
|
615
620
|
|
|
616
|
-
// get
|
|
621
|
+
// get page 2 for live collection #1
|
|
617
622
|
|
|
618
623
|
callback.mock.lastCall[0].onNextPage();
|
|
619
624
|
|
|
@@ -621,7 +626,9 @@ describe('getChannels', () => {
|
|
|
621
626
|
|
|
622
627
|
expect(callback).lastCalledWith(
|
|
623
628
|
expect.objectContaining({
|
|
624
|
-
data: [...returnValue1Page1, ...returnValue1Page2]
|
|
629
|
+
data: [...returnValue1Page1, ...returnValue1Page2]
|
|
630
|
+
.map(convertChannelFromRaw)
|
|
631
|
+
.map(getChannelMessagePreviewWithUser),
|
|
625
632
|
error: undefined,
|
|
626
633
|
loading: false,
|
|
627
634
|
}),
|
|
@@ -672,6 +679,8 @@ describe('getChannels', () => {
|
|
|
672
679
|
describe('events', () => {
|
|
673
680
|
const rawNewChannel = generateRawChannel({ channelId: 'new-channel-id' });
|
|
674
681
|
|
|
682
|
+
const rawUpdatedChannel = { ...channelRaw1, updatedAt: new Date().toISOString() };
|
|
683
|
+
|
|
675
684
|
const cases: [string, keyof Amity.Events, Amity.RawChannel, Amity.Channel[]][] = [
|
|
676
685
|
[
|
|
677
686
|
'it should add new channel to collection onCreate',
|
|
@@ -688,8 +697,8 @@ describe('getChannels', () => {
|
|
|
688
697
|
[
|
|
689
698
|
'it should update channel in collection onUpdate',
|
|
690
699
|
'channel.updated',
|
|
691
|
-
|
|
692
|
-
[channel1, channel2],
|
|
700
|
+
rawUpdatedChannel,
|
|
701
|
+
[{ ...channel1, updatedAt: rawUpdatedChannel.updatedAt }, channel2],
|
|
693
702
|
],
|
|
694
703
|
[
|
|
695
704
|
'it should update channel in collection onMuted',
|
|
@@ -959,3 +968,107 @@ describe('getChannels', () => {
|
|
|
959
968
|
);
|
|
960
969
|
});
|
|
961
970
|
});
|
|
971
|
+
|
|
972
|
+
describe('getChannels by channelIds', () => {
|
|
973
|
+
jest.spyOn(getChannelMarkers, 'getChannelMarkers').mockResolvedValue({
|
|
974
|
+
data: [],
|
|
975
|
+
cachedAt: undefined,
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
beforeAll(connectClient);
|
|
979
|
+
afterAll(disconnectClient);
|
|
980
|
+
beforeEach(enableCache);
|
|
981
|
+
afterEach(disableCache);
|
|
982
|
+
|
|
983
|
+
test('it should return channel collection when query by channelIds', async () => {
|
|
984
|
+
const callback = jest.fn();
|
|
985
|
+
client.http.get = jest.fn().mockResolvedValue(channelQueryResponseWithoutPaging);
|
|
986
|
+
|
|
987
|
+
getChannels({}, callback);
|
|
988
|
+
await pause();
|
|
989
|
+
|
|
990
|
+
expect(callback).toHaveBeenCalledTimes(2);
|
|
991
|
+
expect(callback).toHaveBeenNthCalledWith(1, expect.objectContaining(getSnapshot()));
|
|
992
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
993
|
+
2,
|
|
994
|
+
expect.objectContaining(
|
|
995
|
+
getSnapshot({
|
|
996
|
+
data: convertRawChannelPayload(channelQueryResponse.data).channels.map(channel => {
|
|
997
|
+
return { ...channel, messagePreview: null };
|
|
998
|
+
}),
|
|
999
|
+
loading: false,
|
|
1000
|
+
}),
|
|
1001
|
+
),
|
|
1002
|
+
);
|
|
1003
|
+
});
|
|
1004
|
+
|
|
1005
|
+
describe('events', () => {
|
|
1006
|
+
const rawNewChannel = generateRawChannel({ channelId: 'new-channel-id' });
|
|
1007
|
+
|
|
1008
|
+
const rawUpdatedChannel = { ...channelRaw1, updatedAt: new Date().toISOString() };
|
|
1009
|
+
|
|
1010
|
+
const cases: [string, keyof Amity.Events, Amity.RawChannel, Amity.Channel[]][] = [
|
|
1011
|
+
[
|
|
1012
|
+
'it should not add new channel to collection onCreate',
|
|
1013
|
+
'channel.created',
|
|
1014
|
+
rawNewChannel,
|
|
1015
|
+
[channel1, channel2],
|
|
1016
|
+
],
|
|
1017
|
+
[
|
|
1018
|
+
'it should not add new channel to collection onJoin',
|
|
1019
|
+
'channel.joined',
|
|
1020
|
+
rawNewChannel,
|
|
1021
|
+
[channel1, channel2],
|
|
1022
|
+
],
|
|
1023
|
+
[
|
|
1024
|
+
'it should update channel in collection onUpdate',
|
|
1025
|
+
'channel.updated',
|
|
1026
|
+
rawUpdatedChannel,
|
|
1027
|
+
[{ ...channel1, updatedAt: rawUpdatedChannel.updatedAt }, channel2],
|
|
1028
|
+
],
|
|
1029
|
+
[
|
|
1030
|
+
'it should update channel in collection onMuted',
|
|
1031
|
+
'channel.setMuted',
|
|
1032
|
+
{ ...channelRaw1, isMuted: true },
|
|
1033
|
+
[{ ...channel1, isMuted: true }, channel2],
|
|
1034
|
+
],
|
|
1035
|
+
[
|
|
1036
|
+
'it should not remove channel from collection onDelete',
|
|
1037
|
+
'channel.deleted',
|
|
1038
|
+
{ ...channelRaw1, isDeleted: true },
|
|
1039
|
+
[channel1, channel2],
|
|
1040
|
+
],
|
|
1041
|
+
[
|
|
1042
|
+
'it should not remove channel from collection onLeft',
|
|
1043
|
+
'channel.left',
|
|
1044
|
+
{ ...channelRaw1, isDeleted: true },
|
|
1045
|
+
[channel1, channel2],
|
|
1046
|
+
],
|
|
1047
|
+
];
|
|
1048
|
+
|
|
1049
|
+
test.each(cases)('%s', async (test, event, rawChannel, expected) => {
|
|
1050
|
+
const callback = jest.fn();
|
|
1051
|
+
client.http.get = jest.fn().mockResolvedValue(channelQueryResponse);
|
|
1052
|
+
|
|
1053
|
+
getChannels({ channelIds: [channelRaw1._id, channelRaw2._id] }, callback);
|
|
1054
|
+
await pause();
|
|
1055
|
+
client.emitter.emit(event, {
|
|
1056
|
+
channels: [rawChannel],
|
|
1057
|
+
channelUsers: [rawChannelUser],
|
|
1058
|
+
users: [],
|
|
1059
|
+
files: [],
|
|
1060
|
+
});
|
|
1061
|
+
await pause();
|
|
1062
|
+
|
|
1063
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
1064
|
+
event === 'channel.updated' || event === 'channel.setMuted' ? 3 : 2,
|
|
1065
|
+
expect.objectContaining(
|
|
1066
|
+
getSnapshot({
|
|
1067
|
+
data: expected,
|
|
1068
|
+
loading: false,
|
|
1069
|
+
}),
|
|
1070
|
+
),
|
|
1071
|
+
);
|
|
1072
|
+
});
|
|
1073
|
+
});
|
|
1074
|
+
});
|
|
@@ -25,7 +25,7 @@ export function convertFromRaw(channel: Amity.RawChannel): Amity.InternalChannel
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const preUpdateChannelCache = (rawPayload: Amity.ChannelPayload) => {
|
|
28
|
+
export const preUpdateChannelCache = (rawPayload: Amity.ChannelPayload) => {
|
|
29
29
|
ingestInCache({
|
|
30
30
|
channels: rawPayload.channels.map(channel => convertFromRaw(channel)),
|
|
31
31
|
});
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
onChannelDeleted,
|
|
4
4
|
onChannelJoined,
|
|
5
5
|
onChannelLeft,
|
|
6
|
-
} from '~/channelRepository';
|
|
6
|
+
} from '~/channelRepository/events';
|
|
7
7
|
import { onUserMarkerSync } from '~/marker/events/onUserMarkerSync';
|
|
8
8
|
import { setIntervalTask } from '~/utils/timer';
|
|
9
9
|
import { getUserMarker } from '~/marker/api';
|
|
@@ -3,7 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
|
|
7
7
|
|
|
8
8
|
/* begin_public_function
|
|
9
9
|
id: community.create
|
|
@@ -33,11 +33,12 @@ export const createCommunity = async (
|
|
|
33
33
|
| 'postSetting'
|
|
34
34
|
| 'tags'
|
|
35
35
|
| 'metadata'
|
|
36
|
-
> &
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
> &
|
|
37
|
+
Amity.CommunityStorySettings & {
|
|
38
|
+
userIds?: string[];
|
|
39
|
+
categoryIds?: string[];
|
|
40
|
+
isUniqueDisplayName?: boolean;
|
|
41
|
+
},
|
|
41
42
|
): Promise<Amity.Cached<Amity.Community>> => {
|
|
42
43
|
const client = getActiveClient();
|
|
43
44
|
client.log('user/createCommunity', bundle);
|
|
@@ -25,14 +25,21 @@ import { prepareCommunityPayload } from '../utils';
|
|
|
25
25
|
*/
|
|
26
26
|
export const queryCommunities = async (
|
|
27
27
|
query?: Amity.QueryCommunities,
|
|
28
|
-
): Promise<Amity.Cached<Amity.
|
|
28
|
+
): Promise<Amity.Cached<Amity.PageToken<Amity.Community>>> => {
|
|
29
29
|
const client = getActiveClient();
|
|
30
30
|
client.log('channel/queryCommunities', query);
|
|
31
31
|
|
|
32
32
|
// safe decapsulation
|
|
33
|
-
const { page =
|
|
33
|
+
const { page, limit = 10, ...params } = query ?? {};
|
|
34
34
|
const { displayName, membership, includeDeleted, ...restParams } = params ?? {};
|
|
35
35
|
|
|
36
|
+
const options = (() => {
|
|
37
|
+
if (page) return { token: page };
|
|
38
|
+
if (limit) return { limit };
|
|
39
|
+
|
|
40
|
+
return undefined;
|
|
41
|
+
})();
|
|
42
|
+
|
|
36
43
|
// API-FIX: parameters should be querystring.
|
|
37
44
|
// API-FIX: backend doesn't answer Amity.Response
|
|
38
45
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
@@ -44,9 +51,7 @@ export const queryCommunities = async (
|
|
|
44
51
|
isDeleted: inferIsDeleted(includeDeleted),
|
|
45
52
|
keyword: displayName,
|
|
46
53
|
filter: membership,
|
|
47
|
-
options
|
|
48
|
-
token: toToken(page, 'skiplimit'),
|
|
49
|
-
},
|
|
54
|
+
options,
|
|
50
55
|
},
|
|
51
56
|
},
|
|
52
57
|
);
|
|
@@ -60,16 +65,9 @@ export const queryCommunities = async (
|
|
|
60
65
|
if (client.cache) {
|
|
61
66
|
ingestInCache(unpackedPayload, { cachedAt });
|
|
62
67
|
|
|
63
|
-
const cacheKey = [
|
|
64
|
-
'community',
|
|
65
|
-
'query',
|
|
66
|
-
{ ...params, options: { ...page } } as Amity.Serializable,
|
|
67
|
-
];
|
|
68
|
+
const cacheKey = ['community', 'query', { ...params, options } as Amity.Serializable];
|
|
68
69
|
pushToCache(cacheKey, { communities: communities.map(getResolver('community')), paging });
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
const prevPage = toPage(paging.previous);
|
|
73
|
-
|
|
74
|
-
return { data: communities, cachedAt, prevPage, nextPage };
|
|
72
|
+
return { data: communities, cachedAt, paging };
|
|
75
73
|
};
|
|
@@ -14,9 +14,11 @@ const pagingToken = {
|
|
|
14
14
|
const communitiesToQuery = [community11];
|
|
15
15
|
const communityIdsToQuery = communitiesToQuery.map(community => community.communityId);
|
|
16
16
|
const communityUsersToQuery = [communityUser11];
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
const queryCriteriaWithoutQueryToken = { displayName: communities[0].displayName, limit: 10 };
|
|
18
|
+
const queryCriteriaWithQueryToken = {
|
|
19
|
+
...queryCriteriaWithoutQueryToken,
|
|
20
|
+
page: pagingToken.next,
|
|
21
|
+
};
|
|
20
22
|
|
|
21
23
|
const resolvedGetValue = {
|
|
22
24
|
data: {
|
|
@@ -34,11 +36,10 @@ describe('queryCommunities', () => {
|
|
|
34
36
|
test('should return fetched communities with correct paging', async () => {
|
|
35
37
|
client.http.get = jest.fn().mockResolvedValueOnce(resolvedGetValue);
|
|
36
38
|
|
|
37
|
-
await expect(queryCommunities(
|
|
39
|
+
await expect(queryCommunities(queryCriteriaWithoutQueryToken)).resolves.toEqual(
|
|
38
40
|
expect.objectContaining({
|
|
39
41
|
data: communitiesToQuery,
|
|
40
|
-
|
|
41
|
-
nextPage: { before: 55, limit: 10 },
|
|
42
|
+
paging: pagingToken,
|
|
42
43
|
}),
|
|
43
44
|
);
|
|
44
45
|
});
|
|
@@ -47,12 +48,17 @@ describe('queryCommunities', () => {
|
|
|
47
48
|
enableCache();
|
|
48
49
|
client.http.get = jest.fn().mockResolvedValue(resolvedGetValue);
|
|
49
50
|
|
|
50
|
-
await queryCommunities(
|
|
51
|
+
await queryCommunities(queryCriteriaWithQueryToken);
|
|
52
|
+
|
|
53
|
+
const { page, limit, ...params } = queryCriteriaWithQueryToken;
|
|
51
54
|
|
|
52
55
|
const recieved = pullFromCache([
|
|
53
56
|
'community',
|
|
54
57
|
'query',
|
|
55
|
-
{
|
|
58
|
+
{
|
|
59
|
+
...params,
|
|
60
|
+
options: { token: queryCriteriaWithQueryToken.page },
|
|
61
|
+
},
|
|
56
62
|
])?.data;
|
|
57
63
|
|
|
58
64
|
expect(recieved).toEqual({
|
|
@@ -66,14 +72,14 @@ describe('queryCommunities', () => {
|
|
|
66
72
|
test('should throw an error if request fails', async () => {
|
|
67
73
|
client.http.get = jest.fn().mockRejectedValueOnce(new Error('error'));
|
|
68
74
|
|
|
69
|
-
await expect(queryCommunities(
|
|
75
|
+
await expect(queryCommunities(queryCriteriaWithQueryToken)).rejects.toThrow('error');
|
|
70
76
|
});
|
|
71
77
|
|
|
72
78
|
test('it should set isDeleted to undefined if includeDeleted is true', async () => {
|
|
73
79
|
const mockFn = jest.fn();
|
|
74
80
|
client.http.get = mockFn.mockResolvedValue(resolvedGetValue);
|
|
75
81
|
|
|
76
|
-
await queryCommunities({ ...
|
|
82
|
+
await queryCommunities({ ...queryCriteriaWithoutQueryToken, includeDeleted: true });
|
|
77
83
|
|
|
78
84
|
expect(mockFn.mock.lastCall).toHaveLength(2);
|
|
79
85
|
expect(mockFn.mock.lastCall[1].params.isDeleted).toBeUndefined();
|
|
@@ -83,7 +89,7 @@ describe('queryCommunities', () => {
|
|
|
83
89
|
const mockFn = jest.fn();
|
|
84
90
|
client.http.get = mockFn.mockResolvedValue(resolvedGetValue);
|
|
85
91
|
|
|
86
|
-
await queryCommunities({ ...
|
|
92
|
+
await queryCommunities({ ...queryCriteriaWithoutQueryToken, includeDeleted: false });
|
|
87
93
|
|
|
88
94
|
expect(mockFn.mock.lastCall).toHaveLength(2);
|
|
89
95
|
expect(mockFn.mock.lastCall[1].params.isDeleted).toBe(false);
|
|
@@ -93,7 +99,7 @@ describe('queryCommunities', () => {
|
|
|
93
99
|
const mockFn = jest.fn();
|
|
94
100
|
client.http.get = mockFn.mockResolvedValue(resolvedGetValue);
|
|
95
101
|
|
|
96
|
-
await queryCommunities(
|
|
102
|
+
await queryCommunities(queryCriteriaWithoutQueryToken);
|
|
97
103
|
|
|
98
104
|
expect(mockFn.mock.lastCall).toHaveLength(2);
|
|
99
105
|
expect(mockFn.mock.lastCall[1].params.isDeleted).toBe(false);
|
|
@@ -3,7 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
|
|
7
7
|
|
|
8
8
|
/* begin_public_function
|
|
9
9
|
id: community.update
|
|
@@ -27,8 +27,9 @@ export const updateCommunity = async (
|
|
|
27
27
|
communityId: Amity.Community['communityId'],
|
|
28
28
|
patch: Patch<
|
|
29
29
|
Amity.Community,
|
|
30
|
-
'displayName' | '
|
|
31
|
-
|
|
30
|
+
'displayName' | 'avatarFileId' | 'description' | 'postSetting' | 'tags' | 'metadata'
|
|
31
|
+
> &
|
|
32
|
+
Amity.CommunityStorySettings,
|
|
32
33
|
): Promise<Amity.Cached<Amity.Community>> => {
|
|
33
34
|
const client = getActiveClient();
|
|
34
35
|
client.log('community/updateCommunity', communityId, patch);
|