@amityco/ts-sdk 7.5.4-3506dd3.0 → 7.5.4-6dc7299.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/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -0
- package/dist/@types/domains/group.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.d.ts.map +1 -1
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/resumeSession.d.ts +32 -0
- package/dist/client/api/resumeSession.d.ts.map +1 -0
- package/dist/client/api/tests/resumeSession.test.d.ts +2 -0
- package/dist/client/api/tests/resumeSession.test.d.ts.map +1 -0
- package/dist/communityRepository/api/deleteCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts +2 -2
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +1 -1
- package/dist/index.cjs.js +224 -19
- package/dist/index.esm.js +223 -19
- package/dist/index.umd.js +4 -4
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelMemberLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/channelMemberLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/community.d.ts +2 -0
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/@types/domains/channel.ts +1 -0
- package/src/@types/domains/group.ts +2 -0
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +3 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.ts +2 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.ts +2 -2
- package/src/client/api/index.ts +1 -0
- package/src/client/api/resumeSession.ts +282 -0
- package/src/client/api/tests/resumeSession.test.ts +173 -0
- package/src/communityRepository/api/deleteCommunity.ts +2 -1
- package/src/communityRepository/api/getCommunity.ts +5 -7
- package/src/communityRepository/observers/getCommunity.ts +24 -12
- package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +1 -2
- package/src/utils/linkedObject/channelLinkedObject.ts +19 -0
- package/src/utils/linkedObject/channelMemberLinkedObject.ts +20 -0
- package/src/utils/linkedObject/index.ts +2 -0
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
onLocalCommunityJoin,
|
|
13
13
|
} from '../communityMembership/events';
|
|
14
14
|
import { convertEventPayload } from '~/utils/event';
|
|
15
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
15
16
|
|
|
16
17
|
/* begin_public_function
|
|
17
18
|
id: community.get
|
|
@@ -39,17 +40,28 @@ export const getCommunity = (
|
|
|
39
40
|
communityId: Amity.Community['communityId'],
|
|
40
41
|
callback: Amity.LiveObjectCallback<Amity.Community>,
|
|
41
42
|
): Amity.Unsubscriber => {
|
|
42
|
-
return liveObject(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
return liveObject(
|
|
44
|
+
communityId,
|
|
45
|
+
callback,
|
|
46
|
+
'communityId',
|
|
47
|
+
_getCommunity,
|
|
48
|
+
[
|
|
49
|
+
onCommunityUpdated,
|
|
50
|
+
onCommunityDeleted,
|
|
51
|
+
onCommunityJoined,
|
|
52
|
+
onCommunityLeft,
|
|
53
|
+
onLocalCommunityJoined,
|
|
54
|
+
onLocalCommunityLeft,
|
|
55
|
+
onCommunityUserBanned,
|
|
56
|
+
onCommunityUserUnbanned,
|
|
57
|
+
onCommunityUserChanged,
|
|
58
|
+
convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
|
|
59
|
+
],
|
|
60
|
+
{
|
|
61
|
+
callbackDataSelector: (data: Amity.InternalCommunity) => {
|
|
62
|
+
return LinkedObject.community(data);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
);
|
|
54
66
|
};
|
|
55
67
|
/* end_public_function */
|
package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PaginationController } from '~/core/liveCollection/PaginationController';
|
|
2
|
-
import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* TODO: handle cache receive cache option, and cache policy
|
|
@@ -10,7 +9,7 @@ export class JoinRequestsPaginationController extends PaginationController<
|
|
|
10
9
|
Amity.JoinRequestLiveCollection
|
|
11
10
|
> {
|
|
12
11
|
async getRequest(queryParams: Amity.JoinRequestLiveCollection, token: string | undefined) {
|
|
13
|
-
const { limit =
|
|
12
|
+
const { limit = 20, communityId, ...params } = queryParams;
|
|
14
13
|
const options = token ? { token } : { limit };
|
|
15
14
|
|
|
16
15
|
const { data: queryResponse } = await this.http.get<
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { markAsRead } from '~/channelRepository/internalApi/markAsRead';
|
|
2
2
|
import { shallowClone } from '../shallowClone';
|
|
3
|
+
import { queryCache } from '~/cache/api';
|
|
4
|
+
import { channelMemberLinkedObject } from './channelMemberLinkedObject';
|
|
3
5
|
|
|
4
6
|
export const channelLinkedObject = (channel: Amity.InternalChannel): Amity.Channel => {
|
|
7
|
+
let previewMembers: Amity.Membership<'channel'>[] = [];
|
|
8
|
+
|
|
9
|
+
if (channel.type === 'conversation') {
|
|
10
|
+
const channelUsers = queryCache<Amity.Membership<'channel'>>(['channelUsers', 'get']);
|
|
11
|
+
if (channelUsers && channelUsers?.length > 0) {
|
|
12
|
+
previewMembers = (
|
|
13
|
+
channelUsers?.filter(({ data }) => data.channelId === channel.channelId) ?? []
|
|
14
|
+
)
|
|
15
|
+
// sort in ascending order by userInternalId
|
|
16
|
+
.sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
|
|
17
|
+
// Select only first 4 members
|
|
18
|
+
.slice(0, 4)
|
|
19
|
+
.map(({ data }) => channelMemberLinkedObject(data));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
return shallowClone(channel, {
|
|
6
24
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
25
|
+
previewMembers,
|
|
7
26
|
});
|
|
8
27
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
2
|
+
import { userLinkedObject } from './userLinkedObject';
|
|
3
|
+
|
|
4
|
+
export const channelMemberLinkedObject = (
|
|
5
|
+
channelMember: Amity.Membership<'channel'>,
|
|
6
|
+
): Amity.Membership<'channel'> => {
|
|
7
|
+
const getUser = (): Amity.User | undefined => {
|
|
8
|
+
const cacheKey = ['user', 'get', channelMember.userId];
|
|
9
|
+
const internalUser = pullFromCache<Amity.InternalUser>(cacheKey)?.data;
|
|
10
|
+
|
|
11
|
+
return internalUser ? userLinkedObject(internalUser) : undefined;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
...channelMember,
|
|
16
|
+
get user() {
|
|
17
|
+
return getUser();
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -14,6 +14,7 @@ import { notificationTrayLinkedObject } from './notificationTrayLinkedObject';
|
|
|
14
14
|
import { communityLinkedObject } from './communityLinkedObject';
|
|
15
15
|
import { invitationLinkedObject } from './invitationLinkedObject';
|
|
16
16
|
import { joinRequestLinkedObject } from './joinRequestLinkedObject';
|
|
17
|
+
import { channelMemberLinkedObject } from './channelMemberLinkedObject';
|
|
17
18
|
|
|
18
19
|
export const LinkedObject = {
|
|
19
20
|
ad: adLinkedObject,
|
|
@@ -32,4 +33,5 @@ export const LinkedObject = {
|
|
|
32
33
|
community: communityLinkedObject,
|
|
33
34
|
invitation: invitationLinkedObject,
|
|
34
35
|
joinRequest: joinRequestLinkedObject,
|
|
36
|
+
channelMember: channelMemberLinkedObject,
|
|
35
37
|
};
|