@amityco/ts-sdk 7.5.1-37cf937.0 → 7.5.1-3d3fd19.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 +1 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +4 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/invitation.d.ts +6 -1
- package/dist/@types/domains/invitation.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getTotalChannelsUnread.d.ts.map +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.d.ts.map +1 -1
- package/dist/index.cjs.js +29 -15
- package/dist/index.esm.js +29 -15
- package/dist/index.umd.js +1 -1
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +1 -1
- package/src/@types/domains/community.ts +10 -3
- package/src/@types/domains/invitation.ts +5 -1
- package/src/channelRepository/observers/getChannel.ts +11 -1
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +10 -1
- package/src/channelRepository/observers/getTotalChannelsUnread.ts +3 -1
- package/src/channelRepository/utils/prepareChannelPayload.ts +6 -1
- package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +1 -1
- package/src/communityRepository/api/queryCommunities.ts +1 -0
- package/src/communityRepository/observers/getCommunities/CommunitiesPaginationController.ts +1 -0
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.ts +6 -1
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.ts +6 -1
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.ts +1 -0
- package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts +1 -1
- package/src/messageRepository/events/onMessageCreated.ts +1 -1
- package/src/utils/linkedObject/communityLinkedObject.ts +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communityLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/communityLinkedObject.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB,cAAe,MAAM,iBAAiB,KAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"communityLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/communityLinkedObject.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB,cAAe,MAAM,iBAAiB,KAAG,MAAM,SAgDhF,CAAC"}
|
package/package.json
CHANGED
|
@@ -238,7 +238,7 @@ declare global {
|
|
|
238
238
|
|
|
239
239
|
'local.subChannelUnread.updated': Amity.SubChannelUnreadInfo;
|
|
240
240
|
'local.channelUnreadInfo.updated': Amity.ChannelUnreadInfo;
|
|
241
|
-
'local.channelUnread.updated': Amity.ChannelUnread;
|
|
241
|
+
'local.channelUnread.updated': Amity.ChannelUnread[];
|
|
242
242
|
|
|
243
243
|
'local.story.created': Amity.StoryPayload;
|
|
244
244
|
'local.story.updated': Amity.StoryPayload;
|
|
@@ -122,6 +122,7 @@ declare global {
|
|
|
122
122
|
sortBy?: Amity.CommunitySortBy | Amity.CommunitySortByEnum;
|
|
123
123
|
page?: string;
|
|
124
124
|
limit?: number;
|
|
125
|
+
includeDiscoverablePrivateCommunity?: boolean;
|
|
125
126
|
};
|
|
126
127
|
|
|
127
128
|
type QueryJoinCommunity = {
|
|
@@ -171,8 +172,14 @@ declare global {
|
|
|
171
172
|
|
|
172
173
|
type CommunityLiveCollection = Amity.LiveCollectionParams<Omit<QueryCommunities, 'page'>>;
|
|
173
174
|
|
|
174
|
-
type RecommendedCommunityLiveCollection = Amity.LiveCollectionParams<{
|
|
175
|
-
|
|
175
|
+
type RecommendedCommunityLiveCollection = Amity.LiveCollectionParams<{
|
|
176
|
+
limit?: number;
|
|
177
|
+
includeDiscoverablePrivateCommunity?: boolean;
|
|
178
|
+
}>;
|
|
179
|
+
type TrendingCommunityLiveCollection = Amity.LiveCollectionParams<{
|
|
180
|
+
limit?: number;
|
|
181
|
+
includeDiscoverablePrivateCommunity?: boolean;
|
|
182
|
+
}>;
|
|
176
183
|
|
|
177
184
|
type JoinRequestLiveCollection = Amity.LiveCollectionParams<QueryJoinRequest>;
|
|
178
185
|
|
|
@@ -274,7 +281,7 @@ declare global {
|
|
|
274
281
|
callback: Amity.LiveCollectionCallback<Amity.Invitation>,
|
|
275
282
|
) => Amity.Unsubscriber;
|
|
276
283
|
getInvitation: () => Promise<Amity.Invitation | undefined>;
|
|
277
|
-
join: () => Promise<
|
|
284
|
+
join: () => Promise<Amity.JoinResult>;
|
|
278
285
|
getJoinRequests: (
|
|
279
286
|
params: QueryJoinRequest,
|
|
280
287
|
callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
|
|
@@ -33,6 +33,9 @@ declare global {
|
|
|
33
33
|
|
|
34
34
|
type InvitationSortBy = InvitationSortByEnum;
|
|
35
35
|
|
|
36
|
+
type InvitationDomain<T extends Amity.InvitationTargetType = Amity.InvitationTargetType> =
|
|
37
|
+
T extends 'community' ? { communityId: string } : { communityId?: string };
|
|
38
|
+
|
|
36
39
|
type RawInvitation = {
|
|
37
40
|
_id: string;
|
|
38
41
|
networkId: string;
|
|
@@ -50,7 +53,8 @@ declare global {
|
|
|
50
53
|
inviterUserId: string;
|
|
51
54
|
inviterUserInternalId: string;
|
|
52
55
|
inviterUserPublicId: string;
|
|
53
|
-
} & Amity.Timestamps
|
|
56
|
+
} & Amity.Timestamps &
|
|
57
|
+
Amity.InvitationDomain<Amity.InvitationTargetType>;
|
|
54
58
|
|
|
55
59
|
type InternalInvitation = Omit<RawInvitation, 'createdBy'> & {
|
|
56
60
|
createdById: string;
|
|
@@ -297,7 +297,17 @@ export const getChannel = (
|
|
|
297
297
|
),
|
|
298
298
|
convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
|
|
299
299
|
convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
300
|
-
convertEventPayload(
|
|
300
|
+
convertEventPayload(
|
|
301
|
+
(callback: Amity.Listener<Amity.ChannelUnread>) => {
|
|
302
|
+
const processPayload = (payloads: Amity.ChannelUnread[]) => {
|
|
303
|
+
payloads.forEach(callback);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return onChannelUnreadUpdatedLocal(processPayload);
|
|
307
|
+
},
|
|
308
|
+
'channelId',
|
|
309
|
+
'channel',
|
|
310
|
+
),
|
|
301
311
|
],
|
|
302
312
|
{
|
|
303
313
|
forceDispatch: true,
|
|
@@ -572,7 +572,16 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
572
572
|
action: Amity.ChannelActionType.OnUpdate,
|
|
573
573
|
},
|
|
574
574
|
{
|
|
575
|
-
fn: convertEventPayload(
|
|
575
|
+
fn: convertEventPayload(
|
|
576
|
+
(callback: Amity.Listener<Amity.ChannelUnread>) => {
|
|
577
|
+
const processPayload = (payloads: Amity.ChannelUnread[]) => {
|
|
578
|
+
payloads.forEach(callback);
|
|
579
|
+
};
|
|
580
|
+
return onChannelUnreadUpdatedLocal(processPayload);
|
|
581
|
+
},
|
|
582
|
+
'channelId',
|
|
583
|
+
'channel',
|
|
584
|
+
),
|
|
576
585
|
action: Amity.ChannelActionType.OnUpdate,
|
|
577
586
|
},
|
|
578
587
|
];
|
|
@@ -82,7 +82,9 @@ export const getTotalChannelsUnread = (
|
|
|
82
82
|
});
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const realtimeRouter = (
|
|
85
|
+
const realtimeRouter = (_: Amity.ChannelUnread[]) => {
|
|
86
|
+
const { data: userUnread } = _getTotalChannelsUnread();
|
|
87
|
+
|
|
86
88
|
if (isEqual(model, userUnread)) return;
|
|
87
89
|
|
|
88
90
|
dispatcher({
|
|
@@ -7,6 +7,7 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
7
7
|
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
8
8
|
import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
|
|
9
9
|
import { pushToCache } from '~/cache/api';
|
|
10
|
+
import { fireEvent } from '~/core/events';
|
|
10
11
|
|
|
11
12
|
export const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
12
13
|
export const isUnreadCountSupport = ({ type }: Pick<Amity.RawChannel, 'type'>) =>
|
|
@@ -56,6 +57,8 @@ const updateChannelUnread = ({
|
|
|
56
57
|
channels: Amity.RawChannel[];
|
|
57
58
|
channelUsers: Amity.RawMembership<'channel'>[];
|
|
58
59
|
}) => {
|
|
60
|
+
const channelsUnread: Amity.ChannelUnread[] = [];
|
|
61
|
+
|
|
59
62
|
for (let i = 0; i < channels.length; i += 1) {
|
|
60
63
|
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
61
64
|
const channelUser = channelUsers.find(
|
|
@@ -84,9 +87,11 @@ const updateChannelUnread = ({
|
|
|
84
87
|
isMentioned,
|
|
85
88
|
isDeleted: channels[i].isDeleted || false,
|
|
86
89
|
};
|
|
87
|
-
|
|
88
90
|
pushToCache(cacheKey, cacheChannelUnread);
|
|
91
|
+
|
|
92
|
+
channelsUnread.push(cacheChannelUnread);
|
|
89
93
|
}
|
|
94
|
+
fireEvent('local.channelUnread.updated', channelsUnread);
|
|
90
95
|
};
|
|
91
96
|
|
|
92
97
|
export const prepareChannelPayload = async (
|
|
@@ -167,7 +167,7 @@ export class MessageReadReceiptSyncEngine {
|
|
|
167
167
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
168
168
|
|
|
169
169
|
pushToCache(cacheKey, channelUnread);
|
|
170
|
-
fireEvent('local.channelUnread.updated', channelUnread);
|
|
170
|
+
fireEvent('local.channelUnread.updated', [channelUnread]);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
// Step 2: Enqueue the read receipt
|
|
@@ -21,6 +21,7 @@ export class CommunitiesPaginationController extends PaginationController<
|
|
|
21
21
|
...params,
|
|
22
22
|
isDeleted: inferIsDeleted(params.includeDeleted),
|
|
23
23
|
filter: params.membership,
|
|
24
|
+
includeDiscoverablePrivateCommunity: params.includeDiscoverablePrivateCommunity ?? true,
|
|
24
25
|
options,
|
|
25
26
|
},
|
|
26
27
|
},
|
|
@@ -14,7 +14,11 @@ export class RecommendedCommunitiesPaginationController extends PaginationContro
|
|
|
14
14
|
queryParams: Amity.RecommendedCommunityLiveCollection,
|
|
15
15
|
token: string | undefined,
|
|
16
16
|
) {
|
|
17
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
limit = COLLECTION_DEFAULT_PAGINATION_LIMIT,
|
|
19
|
+
includeDiscoverablePrivateCommunity,
|
|
20
|
+
...params
|
|
21
|
+
} = queryParams;
|
|
18
22
|
const options = token ? { token } : { limit };
|
|
19
23
|
|
|
20
24
|
const { data: queryResponse } = await this.http.get<Amity.CommunityPayload & Amity.Pagination>(
|
|
@@ -23,6 +27,7 @@ export class RecommendedCommunitiesPaginationController extends PaginationContro
|
|
|
23
27
|
params: {
|
|
24
28
|
...params,
|
|
25
29
|
options,
|
|
30
|
+
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity ?? true,
|
|
26
31
|
},
|
|
27
32
|
},
|
|
28
33
|
);
|
|
@@ -11,7 +11,11 @@ export class TrendingCommunitiesPaginationController extends PaginationControlle
|
|
|
11
11
|
Amity.TrendingCommunityLiveCollection
|
|
12
12
|
> {
|
|
13
13
|
async getRequest(queryParams: Amity.TrendingCommunityLiveCollection, token: string | undefined) {
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
limit = COLLECTION_DEFAULT_PAGINATION_LIMIT,
|
|
16
|
+
includeDiscoverablePrivateCommunity,
|
|
17
|
+
...params
|
|
18
|
+
} = queryParams;
|
|
15
19
|
const options = token ? { token } : { limit };
|
|
16
20
|
|
|
17
21
|
const { data: queryResponse } = await this.http.get<Amity.CommunityPayload & Amity.Pagination>(
|
|
@@ -20,6 +24,7 @@ export class TrendingCommunitiesPaginationController extends PaginationControlle
|
|
|
20
24
|
params: {
|
|
21
25
|
...params,
|
|
22
26
|
options,
|
|
27
|
+
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity ?? true,
|
|
23
28
|
},
|
|
24
29
|
},
|
|
25
30
|
);
|
|
@@ -29,6 +29,7 @@ export class SemanticSearchCommunityPaginationController extends PaginationContr
|
|
|
29
29
|
...params,
|
|
30
30
|
filter: communityMembershipStatus ?? AmityCommunityMemberStatusFilter.ALL,
|
|
31
31
|
options,
|
|
32
|
+
includeDiscoverablePrivateCommunity: params.includeDiscoverablePrivateCommunity ?? true,
|
|
32
33
|
},
|
|
33
34
|
});
|
|
34
35
|
return queryResponse;
|
package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts
CHANGED
|
@@ -15,7 +15,7 @@ export class MyInvitationsPaginationController extends PaginationController<
|
|
|
15
15
|
{ params: { ...params, options } },
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
-
await getCommunityByIds(data.invitations.map(invitation => invitation.
|
|
18
|
+
await getCommunityByIds(data.invitations.map(invitation => invitation.communityId));
|
|
19
19
|
|
|
20
20
|
return data;
|
|
21
21
|
}
|
|
@@ -80,7 +80,7 @@ export const onMessageCreatedMqtt = (
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
|
|
83
|
-
fireEvent('local.channelUnread.updated', updatedChannelUnread);
|
|
83
|
+
fireEvent('local.channelUnread.updated', [updatedChannelUnread]);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -35,9 +35,8 @@ export const communityLinkedObject = (community: Amity.InternalCommunity): Amity
|
|
|
35
35
|
const { data } = await getInvitation('community', community.communityId);
|
|
36
36
|
return data;
|
|
37
37
|
},
|
|
38
|
-
join: async () =>
|
|
39
|
-
|
|
40
|
-
},
|
|
38
|
+
join: async () => joinRequest(community.communityId),
|
|
39
|
+
|
|
41
40
|
getJoinRequests: (
|
|
42
41
|
params: Omit<Amity.QueryJoinRequest, 'communityId'>,
|
|
43
42
|
callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
|