@amityco/ts-sdk 7.4.1-9b7bc08.0 → 7.4.1-9fe8bb83.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 +3 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +3 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +11 -4
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +10 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +8 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/invitation.d.ts +72 -0
- package/dist/@types/domains/invitation.d.ts.map +1 -0
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/communityRepository/api/createCommunity.d.ts +2 -2
- package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
- package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
- package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
- package/dist/communityRepository/events/utils.d.ts +1 -1
- package/dist/communityRepository/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
- package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
- package/dist/communityRepository/utils/payload.d.ts +1 -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/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +2939 -2421
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2322 -1805
- package/dist/index.umd.js +4 -4
- package/dist/invitationRepository/events/index.d.ts +4 -0
- package/dist/invitationRepository/events/index.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +1 -0
- package/dist/invitationRepository/index.d.ts +2 -0
- package/dist/invitationRepository/index.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/cancelInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/cancelInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/createInvitations.d.ts +21 -0
- package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/index.d.ts +5 -0
- package/dist/invitationRepository/internalApi/index.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +14 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +5 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +15 -0
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts +6 -0
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations.d.ts +12 -0
- package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/utils/index.d.ts +2 -0
- package/dist/invitationRepository/utils/index.d.ts.map +1 -0
- package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +2 -0
- package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +1 -0
- package/dist/messageRepository/api/flagMessage.d.ts +3 -2
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
- package/dist/utils/linkedObject/communityLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +2 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/dummy/post.d.ts +3 -3
- package/package.json +1 -1
- package/src/@types/core/events.ts +4 -0
- package/src/@types/core/model.ts +5 -1
- package/src/@types/core/payload.ts +13 -4
- package/src/@types/domains/client.ts +12 -0
- package/src/@types/domains/community.ts +16 -1
- package/src/@types/domains/invitation.ts +92 -0
- package/src/@types/index.ts +2 -0
- package/src/communityRepository/api/createCommunity.ts +5 -2
- package/src/communityRepository/api/getCommunities.ts +2 -1
- package/src/communityRepository/api/getCommunity.ts +4 -1
- package/src/communityRepository/api/getRecommendedCommunities.ts +2 -1
- package/src/communityRepository/api/getTrendingCommunities.ts +2 -1
- package/src/communityRepository/api/queryCommunities.ts +6 -1
- package/src/communityRepository/api/updateCommunity.ts +13 -3
- package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onUserDeleted.ts +3 -1
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +8 -2
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +8 -2
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
- package/src/communityRepository/events/onCommunityCreated.ts +1 -1
- package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
- package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
- package/src/communityRepository/events/utils.ts +1 -1
- package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
- package/src/communityRepository/utils/communityWithMembership.ts +8 -4
- package/src/communityRepository/utils/payload.ts +1 -1
- package/src/core/liveCollection/PaginationController.ts +1 -1
- package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
- package/src/core/model/idResolvers.ts +2 -0
- package/src/core/model/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/invitationRepository/events/index.ts +3 -0
- package/src/invitationRepository/events/onLocalInvitationCreated.ts +33 -0
- package/src/invitationRepository/events/onLocalInvitationDeleted.ts +33 -0
- package/src/invitationRepository/events/onLocalInvitationUpdated.ts +33 -0
- package/src/invitationRepository/index.ts +1 -0
- package/src/invitationRepository/internalApi/acceptInvitation.ts +45 -0
- package/src/invitationRepository/internalApi/cancelInvitation.ts +44 -0
- package/src/invitationRepository/internalApi/createInvitations.ts +52 -0
- package/src/invitationRepository/internalApi/index.ts +4 -0
- package/src/invitationRepository/internalApi/rejectInvitation.ts +45 -0
- package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +148 -0
- package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +19 -0
- package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +97 -0
- package/src/invitationRepository/observers/getInvitations/enums.ts +5 -0
- package/src/invitationRepository/observers/getInvitations.ts +44 -0
- package/src/invitationRepository/utils/index.ts +1 -0
- package/src/invitationRepository/utils/prepareInvitationPayload.ts +11 -0
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
- package/src/messageRepository/api/flagMessage.ts +19 -2
- package/src/utils/linkedObject/communityLinkedObject.ts +29 -0
- package/src/utils/linkedObject/index.ts +4 -0
- package/src/utils/linkedObject/invitationLinkedObject.ts +44 -0
package/src/@types/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
1
2
|
import { getActiveClient } from '~/client/api';
|
|
2
3
|
|
|
3
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
@@ -11,7 +12,7 @@ import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
|
|
|
11
12
|
/**
|
|
12
13
|
* ```js
|
|
13
14
|
* import { createCommunity } from '@amityco/ts-sdk'
|
|
14
|
-
* const created = await createCommunity({ communityId: 'foobar', displayName: 'foobar' })
|
|
15
|
+
* const created = await createCommunity({ communityId: 'foobar', displayName: 'foobar', isDiscoverable: true, requiresJoinApproval: false })
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
17
18
|
* Creates an {@link Amity.Community}
|
|
@@ -33,6 +34,8 @@ export const createCommunity = async (
|
|
|
33
34
|
| 'postSetting'
|
|
34
35
|
| 'tags'
|
|
35
36
|
| 'metadata'
|
|
37
|
+
| 'isDiscoverable'
|
|
38
|
+
| 'requiresJoinApproval'
|
|
36
39
|
> &
|
|
37
40
|
Amity.CommunityStorySettings & {
|
|
38
41
|
userIds?: string[];
|
|
@@ -60,7 +63,7 @@ export const createCommunity = async (
|
|
|
60
63
|
|
|
61
64
|
const { communities } = data;
|
|
62
65
|
return {
|
|
63
|
-
data: communities[0],
|
|
66
|
+
data: LinkedObject.community(communities[0]),
|
|
64
67
|
cachedAt,
|
|
65
68
|
};
|
|
66
69
|
};
|
|
@@ -5,6 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
|
|
7
7
|
import { prepareCommunityPayload } from '../utils';
|
|
8
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* ```js
|
|
@@ -43,7 +44,7 @@ export const getCommunities = async (
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
return {
|
|
46
|
-
data: data.communities,
|
|
47
|
+
data: data.communities.map(community => LinkedObject.community(community)),
|
|
47
48
|
cachedAt,
|
|
48
49
|
};
|
|
49
50
|
};
|
|
@@ -5,6 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
|
|
7
7
|
import { prepareCommunityPayload } from '../utils';
|
|
8
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* ```js
|
|
@@ -42,7 +43,9 @@ export const getCommunity = async (
|
|
|
42
43
|
const { communities } = data;
|
|
43
44
|
|
|
44
45
|
return {
|
|
45
|
-
data:
|
|
46
|
+
data: LinkedObject.community(
|
|
47
|
+
communities.find(community => community.communityId === communityId)!,
|
|
48
|
+
),
|
|
46
49
|
cachedAt,
|
|
47
50
|
};
|
|
48
51
|
};
|
|
@@ -4,6 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
|
|
5
5
|
import { prepareCommunityPayload } from '../utils';
|
|
6
6
|
import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
|
|
7
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
7
8
|
|
|
8
9
|
/* begin_public_function
|
|
9
10
|
id: community.query.recommended_communities
|
|
@@ -47,5 +48,5 @@ export const getRecommendedCommunities = async (
|
|
|
47
48
|
ingestInCache(data, { cachedAt });
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
return { data: communities, cachedAt };
|
|
51
|
+
return { data: communities.map(community => LinkedObject.community(community)), cachedAt };
|
|
51
52
|
};
|
|
@@ -4,6 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
|
|
5
5
|
import { prepareCommunityPayload } from '../utils';
|
|
6
6
|
import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
|
|
7
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* ```js
|
|
@@ -44,5 +45,5 @@ export const getTrendingCommunities = async (
|
|
|
44
45
|
ingestInCache(data, { cachedAt });
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
return { data: communities, cachedAt };
|
|
48
|
+
return { data: communities.map(community => LinkedObject.community(community)), cachedAt };
|
|
48
49
|
};
|
|
@@ -6,6 +6,7 @@ import { getResolver } from '~/core/model';
|
|
|
6
6
|
import { inferIsDeleted } from '~/utils/inferIsDeleted';
|
|
7
7
|
import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
|
|
8
8
|
import { prepareCommunityPayload } from '../utils';
|
|
9
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* ```js
|
|
@@ -68,5 +69,9 @@ export const queryCommunities = async (
|
|
|
68
69
|
saveCommunityUsers(data.communities, data.communityUsers);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
data: communities.map(community => LinkedObject.community(community)),
|
|
74
|
+
cachedAt,
|
|
75
|
+
paging,
|
|
76
|
+
};
|
|
72
77
|
};
|
|
@@ -5,6 +5,7 @@ import { fireEvent } from '~/core/events';
|
|
|
5
5
|
|
|
6
6
|
import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
|
|
7
7
|
import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
|
|
8
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
8
9
|
|
|
9
10
|
/* begin_public_function
|
|
10
11
|
id: community.update
|
|
@@ -12,7 +13,7 @@ import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
|
|
|
12
13
|
/**
|
|
13
14
|
* ```js
|
|
14
15
|
* import { updateCommunity } from '@amityco/ts-sdk'
|
|
15
|
-
* const updated = await updateCommunity(communityId, { displayName: 'foobar' })
|
|
16
|
+
* const updated = await updateCommunity(communityId, { displayName: 'foobar', isDiscoverable: true, requiresJoinApproval: false })
|
|
16
17
|
* ```
|
|
17
18
|
*
|
|
18
19
|
* Updates an {@link Amity.Community}
|
|
@@ -28,7 +29,14 @@ export const updateCommunity = async (
|
|
|
28
29
|
communityId: Amity.Community['communityId'],
|
|
29
30
|
patch: Patch<
|
|
30
31
|
Amity.Community,
|
|
31
|
-
|
|
32
|
+
| 'displayName'
|
|
33
|
+
| 'avatarFileId'
|
|
34
|
+
| 'description'
|
|
35
|
+
| 'postSetting'
|
|
36
|
+
| 'tags'
|
|
37
|
+
| 'metadata'
|
|
38
|
+
| 'isDiscoverable'
|
|
39
|
+
| 'requiresJoinApproval'
|
|
32
40
|
> &
|
|
33
41
|
Amity.CommunityStorySettings,
|
|
34
42
|
): Promise<Amity.Cached<Amity.Community>> => {
|
|
@@ -53,7 +61,9 @@ export const updateCommunity = async (
|
|
|
53
61
|
const { communities } = data;
|
|
54
62
|
|
|
55
63
|
return {
|
|
56
|
-
data:
|
|
64
|
+
data: LinkedObject.community(
|
|
65
|
+
communities.find(community => community.communityId === communityId)!,
|
|
66
|
+
),
|
|
57
67
|
cachedAt,
|
|
58
68
|
};
|
|
59
69
|
};
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityJoined = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.joined', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityLeft = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.left', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityUserAdded = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.userAdded', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityUserBanned = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.userBanned', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityUserChanged = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, members: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.userChanged', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityUserRemoved = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.userRemoved', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityUserRoleAdded = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.roleAdded', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityUserRoleRemoved = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.roleRemoved', callback);
|
|
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onCommunityUserUnbanned = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createCommunityMemberEventSubscriber('community.userUnbanned', callback);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLocalCommunityMemberEventSubscriber } from './utils';
|
|
2
2
|
|
|
3
3
|
export const onLocalCommunityJoined = (
|
|
4
|
-
callback: (community: Amity.
|
|
4
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
5
5
|
) => createLocalCommunityMemberEventSubscriber('local.community.joined', callback);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLocalCommunityMemberEventSubscriber } from './utils';
|
|
2
2
|
|
|
3
3
|
export const onLocalCommunityLeft = (
|
|
4
|
-
callback: (community: Amity.
|
|
4
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
5
5
|
) => createLocalCommunityMemberEventSubscriber('local.community.left', callback);
|
|
@@ -16,5 +16,5 @@ import { createLocalCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onLocalCommunityUserAdded = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createLocalCommunityMemberEventSubscriber('local.community.userAdded', callback);
|
|
@@ -16,5 +16,5 @@ import { createLocalCommunityMemberEventSubscriber } from './utils';
|
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
18
|
export const onLocalCommunityUserRemoved = (
|
|
19
|
-
callback: (community: Amity.
|
|
19
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
20
20
|
) => createLocalCommunityMemberEventSubscriber('local.community.userRemoved', callback);
|
|
@@ -22,7 +22,9 @@ import { getResolver } from '~/core/model';
|
|
|
22
22
|
*/
|
|
23
23
|
export const onUserDeleted =
|
|
24
24
|
(communityId: string) =>
|
|
25
|
-
(
|
|
25
|
+
(
|
|
26
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
27
|
+
) => {
|
|
26
28
|
const client = getActiveClient();
|
|
27
29
|
|
|
28
30
|
const filter = (payload: Amity.UserPayload) => {
|
|
@@ -53,7 +53,7 @@ function getEventRelatedMember(
|
|
|
53
53
|
|
|
54
54
|
export const createCommunityMemberEventSubscriber = (
|
|
55
55
|
event: keyof Amity.MqttCommunityUserEvents,
|
|
56
|
-
callback: (community: Amity.
|
|
56
|
+
callback: (community: Amity.InternalCommunity, members: Amity.Membership<'community'>[]) => void,
|
|
57
57
|
) => {
|
|
58
58
|
const client = getActiveClient();
|
|
59
59
|
|
|
@@ -102,7 +102,7 @@ export const createCommunityMemberEventSubscriber = (
|
|
|
102
102
|
|
|
103
103
|
export const createLocalCommunityMemberEventSubscriber = (
|
|
104
104
|
event: keyof Amity.LocalCommunityEvents,
|
|
105
|
-
callback: (community: Amity.
|
|
105
|
+
callback: (community: Amity.InternalCommunity, members: Amity.Membership<'community'>[]) => void,
|
|
106
106
|
) => {
|
|
107
107
|
const client = getActiveClient();
|
|
108
108
|
|
|
@@ -70,7 +70,10 @@ export class CommunityMembersQueryStreamController extends QueryStreamController
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
reactor(action: EnumCommunityMemberActions) {
|
|
73
|
-
return (
|
|
73
|
+
return (
|
|
74
|
+
community: Amity.InternalCommunity,
|
|
75
|
+
communityMembers: Amity.Membership<'community'>[],
|
|
76
|
+
) => {
|
|
74
77
|
const collection = pullFromCache<Amity.CommunityMemberLiveCollectionCache>(
|
|
75
78
|
this.cacheKey,
|
|
76
79
|
)?.data;
|
|
@@ -97,7 +100,10 @@ export class CommunityMembersQueryStreamController extends QueryStreamController
|
|
|
97
100
|
subscribeRTE(
|
|
98
101
|
createSubscriber: {
|
|
99
102
|
fn: (
|
|
100
|
-
reactor: (
|
|
103
|
+
reactor: (
|
|
104
|
+
channel: Amity.InternalCommunity,
|
|
105
|
+
communityUser: Amity.Membership<'community'>[],
|
|
106
|
+
) => void,
|
|
101
107
|
) => Amity.Unsubscriber;
|
|
102
108
|
action: EnumCommunityMemberActions;
|
|
103
109
|
}[],
|
|
@@ -70,7 +70,10 @@ export class SearchCommunityMembersQueryStreamController extends QueryStreamCont
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
reactor(action: EnumCommunityMemberActions) {
|
|
73
|
-
return (
|
|
73
|
+
return (
|
|
74
|
+
community: Amity.InternalCommunity,
|
|
75
|
+
communityMembers: Amity.Membership<'community'>[],
|
|
76
|
+
) => {
|
|
74
77
|
const collection = pullFromCache<Amity.SearchCommunityMemberLiveCollectionCache>(
|
|
75
78
|
this.cacheKey,
|
|
76
79
|
)?.data;
|
|
@@ -95,7 +98,10 @@ export class SearchCommunityMembersQueryStreamController extends QueryStreamCont
|
|
|
95
98
|
subscribeRTE(
|
|
96
99
|
createSubscriber: {
|
|
97
100
|
fn: (
|
|
98
|
-
reactor: (
|
|
101
|
+
reactor: (
|
|
102
|
+
channel: Amity.InternalCommunity,
|
|
103
|
+
communityUser: Amity.Membership<'community'>[],
|
|
104
|
+
) => void,
|
|
99
105
|
) => Amity.Unsubscriber;
|
|
100
106
|
action: EnumCommunityMemberActions;
|
|
101
107
|
}[],
|
|
@@ -17,7 +17,7 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
17
17
|
* @category Community Events
|
|
18
18
|
*/
|
|
19
19
|
export const onLocalCommunityRoleAdded = (
|
|
20
|
-
callback: (community: Amity.
|
|
20
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
21
21
|
): Amity.Unsubscriber => {
|
|
22
22
|
const client = getActiveClient();
|
|
23
23
|
|
|
@@ -17,7 +17,7 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
17
17
|
* @category Community Events
|
|
18
18
|
*/
|
|
19
19
|
export const onLocalCommunityRoleRemoved = (
|
|
20
|
-
callback: (community: Amity.
|
|
20
|
+
callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
|
|
21
21
|
): Amity.Unsubscriber => {
|
|
22
22
|
const client = getActiveClient();
|
|
23
23
|
|
|
@@ -15,5 +15,5 @@ import { createCommunityEventSubscriber } from './utils';
|
|
|
15
15
|
*
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommunityCreated = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onCommunityCreated = (callback: Amity.Listener<Amity.InternalCommunity>) =>
|
|
19
19
|
createCommunityEventSubscriber('community.created', callback);
|
|
@@ -15,5 +15,5 @@ import { createCommunityEventSubscriber } from './utils';
|
|
|
15
15
|
*
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommunityDeleted = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onCommunityDeleted = (callback: Amity.Listener<Amity.InternalCommunity>) =>
|
|
19
19
|
createCommunityEventSubscriber('community.deleted', callback);
|
|
@@ -15,5 +15,5 @@ import { createCommunityEventSubscriber } from './utils';
|
|
|
15
15
|
*
|
|
16
16
|
* @category Community Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommunityUpdated = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onCommunityUpdated = (callback: Amity.Listener<Amity.InternalCommunity>) =>
|
|
19
19
|
createCommunityEventSubscriber('community.updated', callback);
|
|
@@ -7,7 +7,7 @@ import { prepareCommunityPayload } from '../utils';
|
|
|
7
7
|
|
|
8
8
|
export const createCommunityEventSubscriber = (
|
|
9
9
|
event: keyof Amity.MqttCommunityEvents,
|
|
10
|
-
callback: Amity.Listener<Amity.
|
|
10
|
+
callback: Amity.Listener<Amity.InternalCommunity>,
|
|
11
11
|
) => {
|
|
12
12
|
const client = getActiveClient();
|
|
13
13
|
|
package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
|
|
63
|
-
return (community: Amity.
|
|
63
|
+
return (community: Amity.InternalCommunity) => {
|
|
64
64
|
const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
|
|
65
65
|
if (!collection) return;
|
|
66
66
|
|
|
@@ -76,7 +76,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
|
|
|
76
76
|
|
|
77
77
|
subscribeRTE(
|
|
78
78
|
createSubscriber: {
|
|
79
|
-
fn: (reactor: (channel: Amity.
|
|
79
|
+
fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
|
|
80
80
|
action: EnumCommunityActions | EnumCommunityMemberActions;
|
|
81
81
|
}[],
|
|
82
82
|
) {
|
|
@@ -66,7 +66,7 @@ export class RecommendedCommunitiesQueryStreamController extends QueryStreamCont
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
|
|
69
|
-
return (community: Amity.
|
|
69
|
+
return (community: Amity.InternalCommunity) => {
|
|
70
70
|
const collection = pullFromCache<Amity.RecommendedCommunityLiveCollectionCache>(
|
|
71
71
|
this.cacheKey,
|
|
72
72
|
)?.data;
|
|
@@ -79,7 +79,7 @@ export class RecommendedCommunitiesQueryStreamController extends QueryStreamCont
|
|
|
79
79
|
|
|
80
80
|
subscribeRTE(
|
|
81
81
|
createSubscriber: {
|
|
82
|
-
fn: (reactor: (channel: Amity.
|
|
82
|
+
fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
|
|
83
83
|
action: EnumCommunityActions | EnumCommunityMemberActions;
|
|
84
84
|
}[],
|
|
85
85
|
) {
|
|
@@ -64,7 +64,7 @@ export class TrendingCommunitiesQueryStreamController extends QueryStreamControl
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
|
|
67
|
-
return (community: Amity.
|
|
67
|
+
return (community: Amity.InternalCommunity) => {
|
|
68
68
|
const collection = pullFromCache<Amity.TrendingCommunityLiveCollectionCache>(
|
|
69
69
|
this.cacheKey,
|
|
70
70
|
)?.data;
|
|
@@ -77,7 +77,7 @@ export class TrendingCommunitiesQueryStreamController extends QueryStreamControl
|
|
|
77
77
|
|
|
78
78
|
subscribeRTE(
|
|
79
79
|
createSubscriber: {
|
|
80
|
-
fn: (reactor: (channel: Amity.
|
|
80
|
+
fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
|
|
81
81
|
action: EnumCommunityActions | EnumCommunityMemberActions;
|
|
82
82
|
}[],
|
|
83
83
|
) {
|
|
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
|
|
63
|
-
return (community: Amity.
|
|
63
|
+
return (community: Amity.InternalCommunity) => {
|
|
64
64
|
const collection = pullFromCache<Amity.SearchCommunityLiveCollectionCache>(
|
|
65
65
|
this.cacheKey,
|
|
66
66
|
)?.data;
|
|
@@ -73,7 +73,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
|
|
|
73
73
|
|
|
74
74
|
subscribeRTE(
|
|
75
75
|
createSubscriber: {
|
|
76
|
-
fn: (reactor: (channel: Amity.
|
|
76
|
+
fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
|
|
77
77
|
action: EnumCommunityActions | EnumCommunityMemberActions;
|
|
78
78
|
}[],
|
|
79
79
|
) {
|
|
@@ -63,7 +63,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
|
|
66
|
-
return (community: Amity.
|
|
66
|
+
return (community: Amity.InternalCommunity) => {
|
|
67
67
|
const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
|
|
68
68
|
if (!collection) return;
|
|
69
69
|
|
|
@@ -77,7 +77,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
|
|
|
77
77
|
|
|
78
78
|
subscribeRTE(
|
|
79
79
|
createSubscriber: {
|
|
80
|
-
fn: (reactor: (community: Amity.
|
|
80
|
+
fn: (reactor: (community: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
|
|
81
81
|
action: EnumCommunityActions | EnumCommunityMemberActions;
|
|
82
82
|
}[],
|
|
83
83
|
) {
|
|
@@ -12,7 +12,7 @@ function isMember(membership: Amity.Membership<'community'>['communityMembership
|
|
|
12
12
|
* checks if currently logged in user is part of the community
|
|
13
13
|
*/
|
|
14
14
|
function isCurrentUserPartOfCommunity(
|
|
15
|
-
c: Amity.
|
|
15
|
+
c: Amity.InternalCommunity,
|
|
16
16
|
m: Amity.Membership<'community'>,
|
|
17
17
|
): boolean {
|
|
18
18
|
const { userId } = getActiveUser();
|
|
@@ -28,11 +28,15 @@ function isCurrentUserPartOfCommunity(
|
|
|
28
28
|
* Althought this can be calculated, it's not scalable.
|
|
29
29
|
*/
|
|
30
30
|
export function updateMembershipStatus(
|
|
31
|
-
communities: Amity.
|
|
31
|
+
communities: Amity.RawCommunity[],
|
|
32
32
|
communityUsers: Amity.Membership<'community'>[],
|
|
33
|
-
): Amity.
|
|
33
|
+
): Amity.InternalCommunity[] {
|
|
34
34
|
return communities.map(c => {
|
|
35
|
-
const cachedCommunity = pullFromCache<Amity.
|
|
35
|
+
const cachedCommunity = pullFromCache<Amity.InternalCommunity>([
|
|
36
|
+
'community',
|
|
37
|
+
'get',
|
|
38
|
+
c.communityId,
|
|
39
|
+
]);
|
|
36
40
|
if (cachedCommunity?.data && cachedCommunity?.data.hasOwnProperty('isJoined')) {
|
|
37
41
|
return {
|
|
38
42
|
...cachedCommunity.data,
|
|
@@ -13,7 +13,7 @@ const getMatchPostSetting = (value: {
|
|
|
13
13
|
) ?? DefaultCommunityPostSetting;
|
|
14
14
|
|
|
15
15
|
export function addPostSetting({ communities }: { communities: Amity.RawCommunity[] }) {
|
|
16
|
-
return communities.map<Amity.
|
|
16
|
+
return communities.map<Amity.InternalCommunity>(
|
|
17
17
|
({ needApprovalOnPostCreation, onlyAdminCanPost, ...restCommunityPayload }) => ({
|
|
18
18
|
postSetting: getMatchPostSetting({
|
|
19
19
|
needApprovalOnPostCreation,
|
package/src/core/model/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ```js
|
|
6
|
+
* import { onLocalInvitationCreated } from '@amityco/ts-sdk'
|
|
7
|
+
* const dispose = onLocalInvitationCreated(data => {
|
|
8
|
+
* // ...
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Fired when an {@link Amity.InvitationPayload} has been created
|
|
13
|
+
*
|
|
14
|
+
* @param callback The function to call when the event was fired
|
|
15
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16
|
+
*
|
|
17
|
+
* @category Invitation Events
|
|
18
|
+
*/
|
|
19
|
+
export const onLocalInvitationCreated = (
|
|
20
|
+
callback: Amity.Listener<Amity.InternalInvitation[]>,
|
|
21
|
+
): Amity.Unsubscriber => {
|
|
22
|
+
const client = getActiveClient();
|
|
23
|
+
|
|
24
|
+
const disposers = [
|
|
25
|
+
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload =>
|
|
26
|
+
callback(payload),
|
|
27
|
+
),
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
return () => {
|
|
31
|
+
disposers.forEach(fn => fn());
|
|
32
|
+
};
|
|
33
|
+
};
|