@amityco/ts-sdk 7.4.1-0e170b02.0 → 7.4.1-108e44a8.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 +12 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/joinRequest.d.ts +7 -7
- package/dist/@types/domains/joinRequest.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +4 -2
- package/dist/@types/domains/notification.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/index.d.ts +1 -0
- package/dist/communityRepository/communityMembership/events/index.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts +2 -0
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts.map +1 -0
- package/dist/communityRepository/internalAPI/joinCommunity.d.ts.map +1 -1
- package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts.map +1 -1
- package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +1 -1
- package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts +14 -0
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts +9 -0
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts +15 -0
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts +6 -0
- package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequestList.d.ts +12 -0
- package/dist/communityRepository/observers/getJoinRequestList.d.ts.map +1 -0
- package/dist/communityRepository/observers/index.d.ts +1 -0
- package/dist/communityRepository/observers/index.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/index.d.ts.map +1 -1
- package/dist/index.cjs.js +254 -36
- package/dist/index.esm.js +254 -36
- package/dist/index.umd.js +2 -2
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +2 -2
- package/src/@types/domains/community.ts +18 -1
- package/src/@types/domains/joinRequest.ts +7 -7
- package/src/@types/domains/notification.ts +2 -0
- package/src/communityRepository/api/getCommunities.ts +3 -1
- package/src/communityRepository/communityMembership/events/index.ts +1 -0
- package/src/communityRepository/communityMembership/events/onLocalCommunityJoin.ts +20 -0
- package/src/communityRepository/internalAPI/joinCommunity.ts +21 -4
- package/src/communityRepository/joinRequest/internalAPI/approveJoinRequest.ts +1 -5
- package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +0 -5
- package/src/communityRepository/joinRequest/internalAPI/rejectJoinRequest.ts +3 -0
- package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +6 -0
- package/src/communityRepository/observers/getCommunity.ts +3 -0
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.ts +130 -0
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.ts +30 -0
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.ts +112 -0
- package/src/communityRepository/observers/getJoinRequestList/enum.ts +5 -0
- package/src/communityRepository/observers/getJoinRequestList.ts +51 -0
- package/src/communityRepository/observers/index.ts +1 -0
- package/src/core/model/index.ts +1 -0
- package/src/utils/linkedObject/communityLinkedObject.ts +1 -3
- package/src/utils/linkedObject/joinRequestLinkedObject.ts +11 -13
package/dist/index.cjs.js
CHANGED
|
@@ -650,6 +650,7 @@ const PAYLOAD2MODEL = {
|
|
|
650
650
|
pins: 'pin',
|
|
651
651
|
notificationTrayItems: 'notificationTrayItem',
|
|
652
652
|
invitations: 'invitation',
|
|
653
|
+
joinRequests: 'joinRequest',
|
|
653
654
|
};
|
|
654
655
|
/** hidden */
|
|
655
656
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -7482,11 +7483,8 @@ const approveJoinRequest = async (joinRequest) => {
|
|
|
7482
7483
|
const client = getActiveClient();
|
|
7483
7484
|
client.log('joinRequest/approveJoinRequest', joinRequest.joinRequestId);
|
|
7484
7485
|
const { data } = await client.http.post(`/api/v4/communities/${joinRequest.targetId}/join/approve`, {
|
|
7485
|
-
|
|
7486
|
-
userId: joinRequest.userId,
|
|
7487
|
-
},
|
|
7486
|
+
userId: joinRequest.requestorInternalId,
|
|
7488
7487
|
});
|
|
7489
|
-
// TODO : Check cache id
|
|
7490
7488
|
const joinRequestCache = (_a = pullFromCache([
|
|
7491
7489
|
'joinRequest',
|
|
7492
7490
|
'get',
|
|
@@ -7523,11 +7521,7 @@ const cancelJoinRequest = async (joinRequest) => {
|
|
|
7523
7521
|
var _a;
|
|
7524
7522
|
const client = getActiveClient();
|
|
7525
7523
|
client.log('joinRequest/cancelJoinRequest', joinRequest.joinRequestId);
|
|
7526
|
-
const { data } = await client.http.delete(`/api/v4/communities/${joinRequest.targetId}/join
|
|
7527
|
-
params: {
|
|
7528
|
-
userId: joinRequest.userId,
|
|
7529
|
-
},
|
|
7530
|
-
});
|
|
7524
|
+
const { data } = await client.http.delete(`/api/v4/communities/${joinRequest.targetId}/join`);
|
|
7531
7525
|
const joinRequestCache = (_a = pullFromCache([
|
|
7532
7526
|
'joinRequest',
|
|
7533
7527
|
'get',
|
|
@@ -7562,7 +7556,9 @@ const rejectJoinRequest = async (joinRequest) => {
|
|
|
7562
7556
|
var _a;
|
|
7563
7557
|
const client = getActiveClient();
|
|
7564
7558
|
client.log('joinRequest/rejectJoinRequest', joinRequest.joinRequestId);
|
|
7565
|
-
const { data } = await client.http.post(`/api/v4/communities/${joinRequest.targetId}/join/reject
|
|
7559
|
+
const { data } = await client.http.post(`/api/v4/communities/${joinRequest.targetId}/join/reject`, {
|
|
7560
|
+
userId: joinRequest.requestorInternalId,
|
|
7561
|
+
});
|
|
7566
7562
|
const joinRequestCache = (_a = pullFromCache([
|
|
7567
7563
|
'joinRequest',
|
|
7568
7564
|
'get',
|
|
@@ -7580,17 +7576,16 @@ const rejectJoinRequest = async (joinRequest) => {
|
|
|
7580
7576
|
|
|
7581
7577
|
const joinRequestLinkedObject = (joinRequest) => {
|
|
7582
7578
|
return Object.assign(Object.assign({}, joinRequest), { get user() {
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
} });
|
|
7579
|
+
var _a;
|
|
7580
|
+
const user = (_a = pullFromCache([
|
|
7581
|
+
'user',
|
|
7582
|
+
'get',
|
|
7583
|
+
joinRequest.requestorPublicId,
|
|
7584
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
7585
|
+
if (!user)
|
|
7586
|
+
return undefined;
|
|
7587
|
+
return userLinkedObject(user);
|
|
7588
|
+
}, cancel: () => cancelJoinRequest(joinRequest), approve: () => approveJoinRequest(joinRequest), reject: () => rejectJoinRequest(joinRequest) });
|
|
7594
7589
|
};
|
|
7595
7590
|
|
|
7596
7591
|
/* begin_public_function
|
|
@@ -7643,6 +7638,7 @@ const getMyJoinRequest = async (communityId) => {
|
|
|
7643
7638
|
* @async
|
|
7644
7639
|
*/
|
|
7645
7640
|
const joinRequest = async (communityId) => {
|
|
7641
|
+
var _a;
|
|
7646
7642
|
const client = getActiveClient();
|
|
7647
7643
|
client.log('community/joinRequest', communityId);
|
|
7648
7644
|
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/join`);
|
|
@@ -7650,8 +7646,17 @@ const joinRequest = async (communityId) => {
|
|
|
7650
7646
|
const cachedAt = client.cache && Date.now();
|
|
7651
7647
|
if (client.cache)
|
|
7652
7648
|
ingestInCache(data, { cachedAt });
|
|
7653
|
-
|
|
7654
|
-
|
|
7649
|
+
const status = data.joinRequests[0].status === "approved" /* JoinRequestStatusEnum.Approved */
|
|
7650
|
+
? "success" /* JoinResultStatusEnum.Success */
|
|
7651
|
+
: "pending" /* JoinResultStatusEnum.Pending */;
|
|
7652
|
+
if (status === "success" /* JoinResultStatusEnum.Success */ && client.cache) {
|
|
7653
|
+
const community = (_a = pullFromCache(['community', 'get', communityId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
7654
|
+
if (community) {
|
|
7655
|
+
const updatedCommunity = Object.assign(Object.assign({}, community), { isJoined: true });
|
|
7656
|
+
upsertInCache(['community', 'get', communityId], updatedCommunity);
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
fireEvent('v4.local.community.joined', data.joinRequests);
|
|
7655
7660
|
return status === "success" /* JoinResultStatusEnum.Success */
|
|
7656
7661
|
? { status }
|
|
7657
7662
|
: { status, request: joinRequestLinkedObject(data.joinRequests[0]) };
|
|
@@ -7725,12 +7730,12 @@ class QueryStreamController {
|
|
|
7725
7730
|
}
|
|
7726
7731
|
}
|
|
7727
7732
|
|
|
7728
|
-
var EnumJoinRequestAction;
|
|
7733
|
+
var EnumJoinRequestAction$1;
|
|
7729
7734
|
(function (EnumJoinRequestAction) {
|
|
7730
7735
|
EnumJoinRequestAction["OnLocalJoinRequestCreated"] = "OnLocalJoinRequestCreated";
|
|
7731
7736
|
EnumJoinRequestAction["OnLocalJoinRequestUpdated"] = "OnLocalJoinRequestUpdated";
|
|
7732
7737
|
EnumJoinRequestAction["OnLocalJoinRequestDeleted"] = "OnLocalJoinRequestDeleted";
|
|
7733
|
-
})(EnumJoinRequestAction || (EnumJoinRequestAction = {}));
|
|
7738
|
+
})(EnumJoinRequestAction$1 || (EnumJoinRequestAction$1 = {}));
|
|
7734
7739
|
|
|
7735
7740
|
class JoinRequestsQueryStreamController extends QueryStreamController {
|
|
7736
7741
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
@@ -7770,12 +7775,12 @@ class JoinRequestsQueryStreamController extends QueryStreamController {
|
|
|
7770
7775
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
7771
7776
|
if (!collection)
|
|
7772
7777
|
return;
|
|
7773
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestUpdated) {
|
|
7778
|
+
if (action === EnumJoinRequestAction$1.OnLocalJoinRequestUpdated) {
|
|
7774
7779
|
const isExist = collection.data.find(id => id === joinRequest[0].joinRequestId);
|
|
7775
7780
|
if (!isExist)
|
|
7776
7781
|
return;
|
|
7777
7782
|
}
|
|
7778
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestCreated) {
|
|
7783
|
+
if (action === EnumJoinRequestAction$1.OnLocalJoinRequestCreated) {
|
|
7779
7784
|
collection.data = [
|
|
7780
7785
|
...new Set([
|
|
7781
7786
|
...joinRequest.map(joinRequest => joinRequest.joinRequestId),
|
|
@@ -7783,7 +7788,7 @@ class JoinRequestsQueryStreamController extends QueryStreamController {
|
|
|
7783
7788
|
]),
|
|
7784
7789
|
];
|
|
7785
7790
|
}
|
|
7786
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestDeleted) {
|
|
7791
|
+
if (action === EnumJoinRequestAction$1.OnLocalJoinRequestDeleted) {
|
|
7787
7792
|
collection.data = collection.data.filter(id => id !== joinRequest[0].joinRequestId);
|
|
7788
7793
|
}
|
|
7789
7794
|
pushToCache(this.cacheKey, collection);
|
|
@@ -8035,9 +8040,9 @@ class JoinRequestsLiveCollectionController extends LiveCollectionController {
|
|
|
8035
8040
|
}
|
|
8036
8041
|
startSubscription() {
|
|
8037
8042
|
return this.queryStreamController.subscribeRTE([
|
|
8038
|
-
{ fn: onJoinRequestCreated, action: EnumJoinRequestAction.OnLocalJoinRequestCreated },
|
|
8039
|
-
{ fn: onJoinRequestUpdated, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
|
|
8040
|
-
{ fn: onJoinRequestDeleted, action: EnumJoinRequestAction.OnLocalJoinRequestDeleted },
|
|
8043
|
+
{ fn: onJoinRequestCreated, action: EnumJoinRequestAction$1.OnLocalJoinRequestCreated },
|
|
8044
|
+
{ fn: onJoinRequestUpdated, action: EnumJoinRequestAction$1.OnLocalJoinRequestUpdated },
|
|
8045
|
+
{ fn: onJoinRequestDeleted, action: EnumJoinRequestAction$1.OnLocalJoinRequestDeleted },
|
|
8041
8046
|
]);
|
|
8042
8047
|
}
|
|
8043
8048
|
notifyChange({ origin, loading, error }) {
|
|
@@ -8615,9 +8620,7 @@ const communityLinkedObject = (community) => {
|
|
|
8615
8620
|
}, getInvitation: async () => {
|
|
8616
8621
|
const { data } = await getInvitation('community', community.communityId);
|
|
8617
8622
|
return data;
|
|
8618
|
-
}, join:
|
|
8619
|
-
return joinRequest(community.communityId);
|
|
8620
|
-
}, getJoinRequests: (params, callback) => {
|
|
8623
|
+
}, join: joinRequest(community.communityId), getJoinRequests: (params, callback) => {
|
|
8621
8624
|
return getJoinRequests(Object.assign(Object.assign({}, params), { communityId: community.communityId }), callback);
|
|
8622
8625
|
}, getMyJoinRequest: async () => {
|
|
8623
8626
|
const { data } = await getMyJoinRequest(community.communityId);
|
|
@@ -19575,10 +19578,11 @@ const saveCommunityUsers = (communities, communityUsers) => {
|
|
|
19575
19578
|
const getCommunities$1 = async (communityIds, includeDiscoverablePrivateCommunity) => {
|
|
19576
19579
|
const client = getActiveClient();
|
|
19577
19580
|
client.log('community/getCommunities', communityIds);
|
|
19581
|
+
const encodedCommunityIds = communityIds.map(communityId => encodeURIComponent(communityId));
|
|
19578
19582
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
19579
19583
|
const { data: payload } = await client.http.get(`/api/v3/communities/list`, {
|
|
19580
19584
|
params: {
|
|
19581
|
-
communityIds,
|
|
19585
|
+
communityIds: encodedCommunityIds,
|
|
19582
19586
|
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity !== null && includeDiscoverablePrivateCommunity !== void 0 ? includeDiscoverablePrivateCommunity : true,
|
|
19583
19587
|
},
|
|
19584
19588
|
});
|
|
@@ -20443,6 +20447,19 @@ const onLocalCommunityJoined = (callback) => createLocalCommunityMemberEventSubs
|
|
|
20443
20447
|
|
|
20444
20448
|
const onLocalCommunityLeft = (callback) => createLocalCommunityMemberEventSubscriber('local.community.left', callback);
|
|
20445
20449
|
|
|
20450
|
+
const onLocalCommunityJoin = (callback) => {
|
|
20451
|
+
const client = getActiveClient();
|
|
20452
|
+
const filter = async (rawPayload) => {
|
|
20453
|
+
callback(rawPayload[0]);
|
|
20454
|
+
};
|
|
20455
|
+
const disposers = [
|
|
20456
|
+
createEventSubscriber(client, 'onCommunityUpdate', 'v4.local.community.joined', filter),
|
|
20457
|
+
];
|
|
20458
|
+
return () => {
|
|
20459
|
+
disposers.forEach(fn => fn());
|
|
20460
|
+
};
|
|
20461
|
+
};
|
|
20462
|
+
|
|
20446
20463
|
/**
|
|
20447
20464
|
* ```js
|
|
20448
20465
|
* import { onLocalCommunityRoleRemoved } from '@amityco/ts-sdk'
|
|
@@ -20929,7 +20946,8 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
20929
20946
|
onCommunityJoined: onCommunityJoined,
|
|
20930
20947
|
onCommunityLeft: onCommunityLeft,
|
|
20931
20948
|
onLocalCommunityJoined: onLocalCommunityJoined,
|
|
20932
|
-
onLocalCommunityLeft: onLocalCommunityLeft
|
|
20949
|
+
onLocalCommunityLeft: onLocalCommunityLeft,
|
|
20950
|
+
onLocalCommunityJoin: onLocalCommunityJoin
|
|
20933
20951
|
});
|
|
20934
20952
|
|
|
20935
20953
|
class SearchCommunityLiveCollectionController extends LiveCollectionController {
|
|
@@ -21153,6 +21171,10 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
21153
21171
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
21154
21172
|
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
21155
21173
|
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
21174
|
+
{
|
|
21175
|
+
fn: convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
|
|
21176
|
+
action: EnumCommunityActions$3.OnCommunityUpdated,
|
|
21177
|
+
},
|
|
21156
21178
|
]);
|
|
21157
21179
|
}
|
|
21158
21180
|
notifyChange({ origin, loading, error }) {
|
|
@@ -21276,6 +21298,7 @@ const getCommunity = (communityId, callback) => {
|
|
|
21276
21298
|
onCommunityUserBanned,
|
|
21277
21299
|
onCommunityUserUnbanned,
|
|
21278
21300
|
onCommunityUserChanged,
|
|
21301
|
+
convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
|
|
21279
21302
|
]);
|
|
21280
21303
|
};
|
|
21281
21304
|
/* end_public_function */
|
|
@@ -21792,6 +21815,200 @@ const semanticSearchCommunities = (params, callback, config) => {
|
|
|
21792
21815
|
};
|
|
21793
21816
|
};
|
|
21794
21817
|
|
|
21818
|
+
/**
|
|
21819
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
21820
|
+
* TODO: check if querybyIds is supported
|
|
21821
|
+
*/
|
|
21822
|
+
class JoinRequestListPaginationController extends PaginationController {
|
|
21823
|
+
async getRequest(queryParams, token) {
|
|
21824
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityIds } = queryParams, params = __rest(queryParams, ["limit", "communityIds"]);
|
|
21825
|
+
const options = token ? { token } : { limit };
|
|
21826
|
+
const encodedChannelIds = communityIds.map(communityId => encodeURIComponent(communityId));
|
|
21827
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/communities/join/requests`, {
|
|
21828
|
+
params: Object.assign(Object.assign({}, params), { options, communityIds: encodedChannelIds }),
|
|
21829
|
+
});
|
|
21830
|
+
return queryResponse;
|
|
21831
|
+
}
|
|
21832
|
+
}
|
|
21833
|
+
|
|
21834
|
+
var EnumJoinRequestAction;
|
|
21835
|
+
(function (EnumJoinRequestAction) {
|
|
21836
|
+
EnumJoinRequestAction["OnLocalJoinRequestCreated"] = "OnLocalJoinRequestCreated";
|
|
21837
|
+
EnumJoinRequestAction["OnLocalJoinRequestUpdated"] = "OnLocalJoinRequestUpdated";
|
|
21838
|
+
EnumJoinRequestAction["OnLocalJoinRequestDeleted"] = "OnLocalJoinRequestDeleted";
|
|
21839
|
+
})(EnumJoinRequestAction || (EnumJoinRequestAction = {}));
|
|
21840
|
+
|
|
21841
|
+
class JoinRequestListQueryStreamController extends QueryStreamController {
|
|
21842
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
21843
|
+
super(query, cacheKey);
|
|
21844
|
+
this.notifyChange = notifyChange;
|
|
21845
|
+
this.preparePayload = preparePayload;
|
|
21846
|
+
}
|
|
21847
|
+
async saveToMainDB(response) {
|
|
21848
|
+
const processedPayload = await this.preparePayload(response);
|
|
21849
|
+
const client = getActiveClient();
|
|
21850
|
+
const cachedAt = client.cache && Date.now();
|
|
21851
|
+
if (client.cache) {
|
|
21852
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
21853
|
+
}
|
|
21854
|
+
}
|
|
21855
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
21856
|
+
var _a, _b;
|
|
21857
|
+
if (refresh) {
|
|
21858
|
+
pushToCache(this.cacheKey, {
|
|
21859
|
+
data: response.joinRequests.map(joinRequest => getResolver('joinRequest')({ joinRequestId: joinRequest._id })),
|
|
21860
|
+
});
|
|
21861
|
+
}
|
|
21862
|
+
else {
|
|
21863
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21864
|
+
const joinRequests = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
21865
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
21866
|
+
...new Set([
|
|
21867
|
+
...joinRequests,
|
|
21868
|
+
...response.joinRequests.map(joinRequest => getResolver('joinRequest')({ joinRequestId: joinRequest._id })),
|
|
21869
|
+
]),
|
|
21870
|
+
] }));
|
|
21871
|
+
}
|
|
21872
|
+
}
|
|
21873
|
+
reactor(action) {
|
|
21874
|
+
return (joinRequest) => {
|
|
21875
|
+
var _a;
|
|
21876
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21877
|
+
if (!collection)
|
|
21878
|
+
return;
|
|
21879
|
+
if (action === EnumJoinRequestAction.OnLocalJoinRequestUpdated) {
|
|
21880
|
+
const isExist = collection.data.find(id => id === joinRequest[0].joinRequestId);
|
|
21881
|
+
if (!isExist)
|
|
21882
|
+
return;
|
|
21883
|
+
}
|
|
21884
|
+
if (action === EnumJoinRequestAction.OnLocalJoinRequestCreated) {
|
|
21885
|
+
collection.data = [
|
|
21886
|
+
...new Set([
|
|
21887
|
+
...joinRequest.map(joinRequest => joinRequest.joinRequestId),
|
|
21888
|
+
...collection.data,
|
|
21889
|
+
]),
|
|
21890
|
+
];
|
|
21891
|
+
}
|
|
21892
|
+
if (action === EnumJoinRequestAction.OnLocalJoinRequestDeleted) {
|
|
21893
|
+
collection.data = collection.data.filter(id => id !== joinRequest[0].joinRequestId);
|
|
21894
|
+
}
|
|
21895
|
+
pushToCache(this.cacheKey, collection);
|
|
21896
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
21897
|
+
};
|
|
21898
|
+
}
|
|
21899
|
+
subscribeRTE(createSubscriber) {
|
|
21900
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
21901
|
+
}
|
|
21902
|
+
}
|
|
21903
|
+
|
|
21904
|
+
class JoinRequestListLiveCollectionController extends LiveCollectionController {
|
|
21905
|
+
constructor(query, callback) {
|
|
21906
|
+
const queryStreamId = hash__default["default"](query);
|
|
21907
|
+
const cacheKey = ['joinRequestList', 'collection', queryStreamId];
|
|
21908
|
+
const paginationController = new JoinRequestListPaginationController(query);
|
|
21909
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
21910
|
+
this.query = query;
|
|
21911
|
+
this.queryStreamController = new JoinRequestListQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommunityJoinRequestPayload);
|
|
21912
|
+
this.callback = callback.bind(this);
|
|
21913
|
+
this.loadPage({ initial: true });
|
|
21914
|
+
}
|
|
21915
|
+
setup() {
|
|
21916
|
+
var _a;
|
|
21917
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21918
|
+
if (!collection) {
|
|
21919
|
+
pushToCache(this.cacheKey, {
|
|
21920
|
+
data: [],
|
|
21921
|
+
params: this.query,
|
|
21922
|
+
});
|
|
21923
|
+
}
|
|
21924
|
+
}
|
|
21925
|
+
async persistModel(queryPayload) {
|
|
21926
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
21927
|
+
}
|
|
21928
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
21929
|
+
const joinRequestResponse = response;
|
|
21930
|
+
this.queryStreamController.appendToQueryStream(joinRequestResponse, direction, refresh);
|
|
21931
|
+
}
|
|
21932
|
+
startSubscription() {
|
|
21933
|
+
return this.queryStreamController.subscribeRTE([
|
|
21934
|
+
{ fn: onJoinRequestCreated, action: EnumJoinRequestAction.OnLocalJoinRequestCreated },
|
|
21935
|
+
{ fn: onJoinRequestUpdated, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
|
|
21936
|
+
{ fn: onJoinRequestDeleted, action: EnumJoinRequestAction.OnLocalJoinRequestDeleted },
|
|
21937
|
+
]);
|
|
21938
|
+
}
|
|
21939
|
+
notifyChange({ origin, loading, error }) {
|
|
21940
|
+
var _a;
|
|
21941
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21942
|
+
if (!collection)
|
|
21943
|
+
return;
|
|
21944
|
+
const data = this.applyFilter(collection.data
|
|
21945
|
+
.map(id => pullFromCache(['joinRequest', 'get', id]))
|
|
21946
|
+
.filter(isNonNullable)
|
|
21947
|
+
.map(({ data }) => data)
|
|
21948
|
+
.map(joinRequestLinkedObject));
|
|
21949
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
21950
|
+
return;
|
|
21951
|
+
this.callback({
|
|
21952
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
21953
|
+
data,
|
|
21954
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
21955
|
+
loading,
|
|
21956
|
+
error,
|
|
21957
|
+
});
|
|
21958
|
+
}
|
|
21959
|
+
applyFilter(data) {
|
|
21960
|
+
let joinRequest = data;
|
|
21961
|
+
if (this.query.communityIds && this.query.communityIds.length > 0) {
|
|
21962
|
+
joinRequest = joinRequest.filter(joinRequest => this.query.communityIds.some(id => id === joinRequest.targetId));
|
|
21963
|
+
}
|
|
21964
|
+
const sortFn = (() => {
|
|
21965
|
+
switch (this.query.sortBy) {
|
|
21966
|
+
case 'firstCreated':
|
|
21967
|
+
return sortByFirstCreated;
|
|
21968
|
+
case 'lastCreated':
|
|
21969
|
+
return sortByLastCreated;
|
|
21970
|
+
default:
|
|
21971
|
+
return sortByLastCreated;
|
|
21972
|
+
}
|
|
21973
|
+
})();
|
|
21974
|
+
joinRequest = joinRequest.sort(sortFn);
|
|
21975
|
+
return joinRequest;
|
|
21976
|
+
}
|
|
21977
|
+
}
|
|
21978
|
+
|
|
21979
|
+
/* begin_public_function
|
|
21980
|
+
id: community.getJoinRequestList
|
|
21981
|
+
*/
|
|
21982
|
+
/**
|
|
21983
|
+
* Get Join Requests
|
|
21984
|
+
*
|
|
21985
|
+
* @param params the query parameters
|
|
21986
|
+
* @param callback the callback to be called when the join request are updated
|
|
21987
|
+
* @returns joinRequest[]
|
|
21988
|
+
*
|
|
21989
|
+
* @category joinRequestList Live Collection
|
|
21990
|
+
*
|
|
21991
|
+
*/
|
|
21992
|
+
const getJoinRequestList = (params, callback, config) => {
|
|
21993
|
+
const { log, cache } = getActiveClient();
|
|
21994
|
+
if (!cache) {
|
|
21995
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
21996
|
+
}
|
|
21997
|
+
const timestamp = Date.now();
|
|
21998
|
+
log(`getJoinRequestList: (tmpid: ${timestamp}) > listen`);
|
|
21999
|
+
const joinRequestListLiveCollection = new JoinRequestListLiveCollectionController(params, callback);
|
|
22000
|
+
const disposers = joinRequestListLiveCollection.startSubscription();
|
|
22001
|
+
const cacheKey = joinRequestListLiveCollection.getCacheKey();
|
|
22002
|
+
disposers.push(() => {
|
|
22003
|
+
dropFromCache(cacheKey);
|
|
22004
|
+
});
|
|
22005
|
+
return () => {
|
|
22006
|
+
log(`getJoinRequestList (tmpid: ${timestamp}) > dispose`);
|
|
22007
|
+
disposers.forEach(fn => fn());
|
|
22008
|
+
};
|
|
22009
|
+
};
|
|
22010
|
+
/* end_public_function */
|
|
22011
|
+
|
|
21795
22012
|
var AmityCommunityMemberStatusFilter;
|
|
21796
22013
|
(function (AmityCommunityMemberStatusFilter) {
|
|
21797
22014
|
AmityCommunityMemberStatusFilter["ALL"] = "all";
|
|
@@ -21962,6 +22179,7 @@ var index$b = /*#__PURE__*/Object.freeze({
|
|
|
21962
22179
|
getTrendingCommunities: getTrendingCommunities,
|
|
21963
22180
|
getRecommendedCommunities: getRecommendedCommunities,
|
|
21964
22181
|
semanticSearchCommunities: semanticSearchCommunities,
|
|
22182
|
+
getJoinRequestList: getJoinRequestList,
|
|
21965
22183
|
get AmityCommunityMemberStatusFilter () { return AmityCommunityMemberStatusFilter; }
|
|
21966
22184
|
});
|
|
21967
22185
|
|