@amityco/ts-sdk 7.5.1-2bc2d560.0 → 7.5.1-3566b16.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 +1 -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/index.cjs.js +21 -9
- package/dist/index.esm.js +21 -9
- 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 +1 -1
- 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/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;
|
|
@@ -274,7 +274,7 @@ declare global {
|
|
|
274
274
|
callback: Amity.LiveCollectionCallback<Amity.Invitation>,
|
|
275
275
|
) => Amity.Unsubscriber;
|
|
276
276
|
getInvitation: () => Promise<Amity.Invitation | undefined>;
|
|
277
|
-
join: () => Promise<
|
|
277
|
+
join: () => Promise<Amity.JoinResult>;
|
|
278
278
|
getJoinRequests: (
|
|
279
279
|
params: QueryJoinRequest,
|
|
280
280
|
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
|
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>,
|