@amityco/ts-sdk 6.29.3-e60fd01.0 → 6.30.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/.env +26 -26
- package/dist/@types/core/events.d.ts +41 -11
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +1 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +18 -4
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts +4 -4
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts +21 -3
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +3 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +2 -2
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberPaginationController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberPaginationController.d.ts.map +1 -1
- package/dist/channelRepository/events/onUserDeleted.d.ts +2 -0
- package/dist/channelRepository/events/onUserDeleted.d.ts.map +1 -0
- package/dist/commentRepository/api/createComment.d.ts.map +1 -1
- package/dist/commentRepository/api/deleteComment.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentCreatedLocal.d.ts +17 -0
- package/dist/commentRepository/events/onCommentCreatedLocal.d.ts.map +1 -0
- package/dist/commentRepository/events/onCommentDeletedLocal.d.ts +17 -0
- package/dist/commentRepository/events/onCommentDeletedLocal.d.ts.map +1 -0
- package/dist/commentRepository/events/onLocalCommentReactionAdded.d.ts +17 -0
- package/dist/commentRepository/events/onLocalCommentReactionAdded.d.ts.map +1 -0
- package/dist/commentRepository/events/onLocalCommentReactionRemoved.d.ts +17 -0
- package/dist/commentRepository/events/onLocalCommentReactionRemoved.d.ts.map +1 -0
- package/dist/commentRepository/events/utils.d.ts +1 -0
- package/dist/commentRepository/events/utils.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComment.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComments/CommentLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/index.d.ts +2 -0
- package/dist/communityRepository/communityMembership/events/index.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +17 -0
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +17 -0
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +17 -0
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/events/utils.d.ts +1 -0
- package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts +4 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +17 -0
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +17 -0
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -0
- package/dist/communityRepository/utils/payload.d.ts +1 -0
- 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/index.cjs.js +1624 -901
- package/dist/index.esm.js +1538 -815
- package/dist/index.umd.js +4 -4
- package/dist/postRepository/events/onLocalPostDeleted.d.ts +17 -0
- package/dist/postRepository/events/onLocalPostDeleted.d.ts.map +1 -0
- package/dist/postRepository/events/onLocalPostReactionAdded.d.ts +17 -0
- package/dist/postRepository/events/onLocalPostReactionAdded.d.ts.map +1 -0
- package/dist/postRepository/events/onLocalPostReactionRemoved.d.ts +17 -0
- package/dist/postRepository/events/onLocalPostReactionRemoved.d.ts.map +1 -0
- package/dist/postRepository/events/onPostUpdatedLocal.d.ts +17 -0
- package/dist/postRepository/events/onPostUpdatedLocal.d.ts.map +1 -0
- package/dist/postRepository/events/utils.d.ts +1 -0
- package/dist/postRepository/events/utils.d.ts.map +1 -1
- package/dist/postRepository/observers/getPost.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/utils/payload.d.ts.map +1 -1
- package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts +14 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserPaginationController.d.ts +5 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserPaginationController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts +15 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/enums.d.ts +11 -0
- package/dist/userRepository/relationship/follow/enums.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/index.d.ts +5 -0
- package/dist/userRepository/relationship/follow/events/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/events/onFollowInfoUpdated.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/events/onFollowerUserDeleted.d.ts +4 -0
- package/dist/userRepository/relationship/follow/events/onFollowerUserDeleted.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onFollowingUserDeleted.d.ts +4 -0
- package/dist/userRepository/relationship/follow/events/onFollowingUserDeleted.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestAccepted.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestAccepted.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestDeclined.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestDeclined.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowerRequested.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowerRequested.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserFollowed.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserFollowed.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserUnfollowed.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserUnfollowed.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/utils.d.ts +2 -1
- package/dist/userRepository/relationship/follow/events/utils.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.d.ts +14 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.d.ts +5 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerQueryStreamController.d.ts +15 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerQueryStreamController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.d.ts +14 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.d.ts +5 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingQueryStreamController.d.ts +15 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingQueryStreamController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/utils.d.ts +4 -0
- package/dist/userRepository/relationship/follow/utils.d.ts.map +1 -0
- package/dist/userRepository/utils/convertRawUserToInternalUser.d.ts +2 -0
- package/dist/userRepository/utils/convertRawUserToInternalUser.d.ts.map +1 -0
- package/dist/userRepository/utils/prepareBlockedUserPayload.d.ts +2 -0
- package/dist/userRepository/utils/prepareBlockedUserPayload.d.ts.map +1 -0
- package/dist/userRepository/utils/prepareUserPayload.d.ts +2 -0
- package/dist/userRepository/utils/prepareUserPayload.d.ts.map +1 -0
- package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -1
- package/dist/utils/tests/dummy/block.d.ts +2 -2
- package/dist/utils/tests/dummy/follow.d.ts +2 -2
- package/package.json +1 -1
- package/src/@types/core/events.ts +40 -13
- package/src/@types/core/model.ts +1 -1
- package/src/@types/core/payload.ts +27 -7
- package/src/@types/core/permissions.ts +4 -4
- package/src/@types/domains/follow.ts +26 -12
- package/src/@types/domains/post.ts +3 -1
- package/src/@types/domains/user.ts +2 -2
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +4 -4
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberPaginationController.ts +4 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.ts +6 -0
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberPaginationController.ts +4 -1
- package/src/channelRepository/events/onUserDeleted.ts +46 -0
- package/src/channelRepository/utils/prepareChannelPayload.ts +1 -1
- package/src/commentRepository/api/createComment.ts +16 -12
- package/src/commentRepository/api/deleteComment.ts +23 -13
- package/src/commentRepository/events/onCommentCreatedLocal.ts +22 -0
- package/src/commentRepository/events/onCommentDeletedLocal.ts +20 -0
- package/src/commentRepository/events/onLocalCommentReactionAdded.ts +42 -0
- package/src/commentRepository/events/onLocalCommentReactionRemoved.ts +42 -0
- package/src/commentRepository/events/utils.ts +78 -1
- package/src/commentRepository/observers/getComment.ts +6 -19
- package/src/commentRepository/observers/getComments/CommentLiveCollectionController.ts +8 -0
- package/src/communityRepository/communityMembership/api/addMembers.ts +1 -1
- package/src/communityRepository/communityMembership/api/removeMembers.ts +1 -1
- package/src/communityRepository/communityMembership/events/index.ts +2 -0
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +20 -0
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +20 -0
- package/src/communityRepository/communityMembership/events/onUserDeleted.ts +64 -0
- package/src/communityRepository/communityMembership/events/utils.ts +50 -2
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.ts +24 -5
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersPaginationController.ts +4 -1
- package/src/communityRepository/communityMembership/observers/getMembers/enums.ts +3 -0
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersLiveCollectionController.ts +12 -4
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersPaginationController.ts +4 -1
- package/src/communityRepository/communityModeration/api/addRoles.ts +5 -2
- package/src/communityRepository/communityModeration/api/removeRoles.ts +5 -2
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +38 -0
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +38 -0
- package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +3 -3
- package/src/communityRepository/utils/payload.ts +29 -0
- package/src/core/model/idResolvers.ts +1 -1
- package/src/postRepository/api/deletePost.ts +9 -9
- package/src/postRepository/api/updatePost.ts +1 -1
- package/src/postRepository/events/onLocalPostDeleted.ts +20 -0
- package/src/postRepository/events/onLocalPostReactionAdded.ts +38 -0
- package/src/postRepository/events/onLocalPostReactionRemoved.ts +41 -0
- package/src/postRepository/events/onPostUpdatedLocal.ts +20 -0
- package/src/postRepository/events/utils.ts +41 -6
- package/src/postRepository/observers/getPost.ts +8 -0
- package/src/postRepository/observers/getPosts/PostLiveCollectionController.ts +8 -0
- package/src/postRepository/utils/payload.ts +10 -2
- package/src/reactionRepository/api/addReaction.ts +27 -2
- package/src/reactionRepository/api/removeReaction.ts +27 -2
- package/src/report/api/createReport.ts +1 -1
- package/src/report/api/deleteReport.ts +1 -1
- package/src/userRepository/api/flagUser.ts +1 -1
- package/src/userRepository/api/getUserByIds.ts +1 -1
- package/src/userRepository/api/queryBlockedUsers.ts +1 -1
- package/src/userRepository/api/unflagUser.ts +1 -1
- package/src/userRepository/api/updateUser.ts +1 -1
- package/src/userRepository/events/utils.ts +1 -1
- package/src/userRepository/internalApi/getUser.ts +1 -1
- package/src/userRepository/internalApi/queryUsers.ts +1 -1
- package/src/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.ts +106 -0
- package/src/userRepository/observers/getBlockedUsers/BlockedUserPaginationController.ts +24 -0
- package/src/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.ts +76 -0
- package/src/userRepository/observers/getBlockedUsers.ts +8 -81
- package/src/userRepository/observers/getUsers/UserLiveCollectionController.ts +4 -4
- package/src/userRepository/observers/searchUserByDisplayName/SearchUserLiveCollectionController.ts +1 -1
- package/src/userRepository/relationship/block/api/blockUser.ts +4 -1
- package/src/userRepository/relationship/block/api/unBlockUser.ts +4 -1
- package/src/userRepository/relationship/follow/api/acceptFollower.ts +4 -1
- package/src/userRepository/relationship/follow/api/acceptMyFollower.ts +4 -1
- package/src/userRepository/relationship/follow/api/declineFollower.ts +5 -2
- package/src/userRepository/relationship/follow/api/declineMyFollower.ts +5 -2
- package/src/userRepository/relationship/follow/api/follow.ts +8 -1
- package/src/userRepository/relationship/follow/api/unfollow.ts +4 -1
- package/src/userRepository/relationship/follow/api/utils.ts +6 -2
- package/src/userRepository/relationship/follow/enums.ts +10 -0
- package/src/userRepository/relationship/follow/events/index.ts +6 -0
- package/src/userRepository/relationship/follow/events/onFollowInfoUpdated.ts +6 -1
- package/src/userRepository/relationship/follow/events/onFollowerUserDeleted.ts +33 -0
- package/src/userRepository/relationship/follow/events/onFollowingUserDeleted.ts +33 -0
- package/src/userRepository/relationship/follow/events/onLocalFollowRequestAccepted.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalFollowRequestDeclined.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalFollowerRequested.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalUserFollowed.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalUserUnfollowed.ts +5 -0
- package/src/userRepository/relationship/follow/events/utils.ts +25 -14
- package/src/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.ts +132 -0
- package/src/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.ts +29 -0
- package/src/userRepository/relationship/follow/observers/getFollowers/FollowerQueryStreamController.ts +95 -0
- package/src/userRepository/relationship/follow/observers/getFollowers.ts +8 -106
- package/src/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.ts +136 -0
- package/src/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.ts +29 -0
- package/src/userRepository/relationship/follow/observers/getFollowings/FollowingQueryStreamController.ts +95 -0
- package/src/userRepository/relationship/follow/observers/getFollowings.ts +6 -106
- package/src/userRepository/relationship/follow/observers/observeFollowers.ts +11 -0
- package/src/userRepository/relationship/follow/observers/observeFollowings.ts +11 -0
- package/src/userRepository/relationship/follow/utils.ts +36 -0
- package/src/userRepository/utils/convertRawUserToInternalUser.ts +6 -0
- package/src/userRepository/utils/prepareBlockedUserPayload.ts +19 -0
- package/src/userRepository/utils/{index.ts → prepareUserPayload.ts} +1 -6
- package/src/utils/linkedObject/commentLinkedObject.ts +13 -16
- package/dist/userRepository/utils/index.d.ts +0 -3
- package/dist/userRepository/utils/index.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -102,8 +102,8 @@ const PostContentType = Object.freeze({
|
|
|
102
102
|
|
|
103
103
|
function getVersion() {
|
|
104
104
|
try {
|
|
105
|
-
// the string ''v6.
|
|
106
|
-
return 'v6.
|
|
105
|
+
// the string ''v6.30.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
106
|
+
return 'v6.30.0-cjs';
|
|
107
107
|
}
|
|
108
108
|
catch (error) {
|
|
109
109
|
return '__dev__';
|
|
@@ -540,7 +540,7 @@ const idResolvers = {
|
|
|
540
540
|
storyTarget: ({ targetId }) => targetId,
|
|
541
541
|
ad: ({ adId }) => adId,
|
|
542
542
|
advertiser: ({ advertiserId }) => advertiserId,
|
|
543
|
-
pin: ({ referenceId }) => referenceId
|
|
543
|
+
pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
|
|
544
544
|
pinTarget: ({ targetId }) => targetId,
|
|
545
545
|
};
|
|
546
546
|
/**
|
|
@@ -5390,6 +5390,80 @@ const categoryLinkedObject = (category) => {
|
|
|
5390
5390
|
} });
|
|
5391
5391
|
};
|
|
5392
5392
|
|
|
5393
|
+
/**
|
|
5394
|
+
* ```js
|
|
5395
|
+
* import { isEqual } from '~/utils/isEqual'
|
|
5396
|
+
* const isEqual = isEqual(post1, post2)
|
|
5397
|
+
* ```
|
|
5398
|
+
*
|
|
5399
|
+
* Compares two Amity.Model
|
|
5400
|
+
*
|
|
5401
|
+
* @param x the Amity.Model to compare
|
|
5402
|
+
* @param y the Amity.Model to compare wit x
|
|
5403
|
+
* @returns a boolean based on equality
|
|
5404
|
+
*
|
|
5405
|
+
* @category utility
|
|
5406
|
+
* @private
|
|
5407
|
+
*/
|
|
5408
|
+
function isEqual(x, y) {
|
|
5409
|
+
if (x === null || x === undefined || y === null || y === undefined) {
|
|
5410
|
+
return x === y;
|
|
5411
|
+
}
|
|
5412
|
+
// after this just checking type of one would be enough
|
|
5413
|
+
if (x.constructor !== y.constructor) {
|
|
5414
|
+
return false;
|
|
5415
|
+
}
|
|
5416
|
+
// if they are functions, they should exactly refer to same one (because of closures)
|
|
5417
|
+
if (x instanceof Function) {
|
|
5418
|
+
return x === y;
|
|
5419
|
+
}
|
|
5420
|
+
// if they are regexps, they should exactly refer to same one
|
|
5421
|
+
if (x instanceof RegExp) {
|
|
5422
|
+
return x === y;
|
|
5423
|
+
}
|
|
5424
|
+
if (x === y || x.valueOf() === y.valueOf()) {
|
|
5425
|
+
return true;
|
|
5426
|
+
}
|
|
5427
|
+
if (Array.isArray(x) && x.length !== y.length) {
|
|
5428
|
+
return false;
|
|
5429
|
+
}
|
|
5430
|
+
// check each element of the array for equality
|
|
5431
|
+
if (Array.isArray(x) && Array.isArray(y)) {
|
|
5432
|
+
if (x.length !== y.length)
|
|
5433
|
+
return false;
|
|
5434
|
+
for (let i = 0; i < x.length; i += 1) {
|
|
5435
|
+
if (!isEqual(x[i], y[i]))
|
|
5436
|
+
return false;
|
|
5437
|
+
}
|
|
5438
|
+
// if all elements are equal, the arrays are equal
|
|
5439
|
+
return true;
|
|
5440
|
+
}
|
|
5441
|
+
// if they are dates, they must had equal valueOf
|
|
5442
|
+
if (x instanceof Date) {
|
|
5443
|
+
return false;
|
|
5444
|
+
}
|
|
5445
|
+
// if they are strictly equal, they both need to be object at least
|
|
5446
|
+
if (!(x instanceof Object)) {
|
|
5447
|
+
return false;
|
|
5448
|
+
}
|
|
5449
|
+
if (!(y instanceof Object)) {
|
|
5450
|
+
return false;
|
|
5451
|
+
}
|
|
5452
|
+
// recursive object equality check
|
|
5453
|
+
const p = Object.keys(x);
|
|
5454
|
+
return (Object.keys(y).every(i => {
|
|
5455
|
+
// @ts-ignore
|
|
5456
|
+
return p.indexOf(i) !== -1;
|
|
5457
|
+
}) &&
|
|
5458
|
+
p.every(i => {
|
|
5459
|
+
return isEqual(x[i], y[i]);
|
|
5460
|
+
}));
|
|
5461
|
+
}
|
|
5462
|
+
|
|
5463
|
+
function isNonNullable(value) {
|
|
5464
|
+
return value != null;
|
|
5465
|
+
}
|
|
5466
|
+
|
|
5393
5467
|
const commentLinkedObject = (comment) => {
|
|
5394
5468
|
return Object.assign(Object.assign({}, comment), { get target() {
|
|
5395
5469
|
const commentTypes = {
|
|
@@ -5420,7 +5494,7 @@ const commentLinkedObject = (comment) => {
|
|
|
5420
5494
|
return undefined;
|
|
5421
5495
|
},
|
|
5422
5496
|
get childrenComment() {
|
|
5423
|
-
return
|
|
5497
|
+
return comment.children
|
|
5424
5498
|
.map(childCommentId => {
|
|
5425
5499
|
const commentCache = pullFromCache([
|
|
5426
5500
|
'comment',
|
|
@@ -5431,10 +5505,8 @@ const commentLinkedObject = (comment) => {
|
|
|
5431
5505
|
return;
|
|
5432
5506
|
return commentCache === null || commentCache === void 0 ? void 0 : commentCache.data;
|
|
5433
5507
|
})
|
|
5434
|
-
.filter(
|
|
5435
|
-
|
|
5436
|
-
// TS always alert returned value is possibly undefined
|
|
5437
|
-
.map(item => commentLinkedObject(item)));
|
|
5508
|
+
.filter(isNonNullable)
|
|
5509
|
+
.map(item => commentLinkedObject(item));
|
|
5438
5510
|
} });
|
|
5439
5511
|
};
|
|
5440
5512
|
|
|
@@ -6264,13 +6336,7 @@ const getChannelIsMentioned = (channel, marker) => {
|
|
|
6264
6336
|
};
|
|
6265
6337
|
|
|
6266
6338
|
function convertRawUserToInternalUser(rawUser) {
|
|
6267
|
-
return Object.assign(Object.assign({}, rawUser), { isGlobalBanned: rawUser.isGlobalBan });
|
|
6268
|
-
}
|
|
6269
|
-
function prepareUserPayload(response) {
|
|
6270
|
-
return {
|
|
6271
|
-
users: response.users.map(convertRawUserToInternalUser),
|
|
6272
|
-
files: response.files,
|
|
6273
|
-
};
|
|
6339
|
+
return Object.assign(Object.assign({}, rawUser), { isGlobalBanned: (rawUser === null || rawUser === void 0 ? void 0 : rawUser.isGlobalBan) || false });
|
|
6274
6340
|
}
|
|
6275
6341
|
|
|
6276
6342
|
const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
@@ -7758,6 +7824,13 @@ const onChannelMemberBanned = (callback) => {
|
|
|
7758
7824
|
return createEventSubscriber(client, 'onChannelMemberBanned', 'channel.banned', filter);
|
|
7759
7825
|
};
|
|
7760
7826
|
|
|
7827
|
+
function prepareUserPayload(response) {
|
|
7828
|
+
return {
|
|
7829
|
+
users: response.users.map(convertRawUserToInternalUser),
|
|
7830
|
+
files: response.files,
|
|
7831
|
+
};
|
|
7832
|
+
}
|
|
7833
|
+
|
|
7761
7834
|
const createUserEventSubscriber = (event, callback) => {
|
|
7762
7835
|
const client = getActiveClient();
|
|
7763
7836
|
const filter = (data) => {
|
|
@@ -7785,7 +7858,7 @@ const createUserEventSubscriber = (event, callback) => {
|
|
|
7785
7858
|
*
|
|
7786
7859
|
* @category User Events
|
|
7787
7860
|
*/
|
|
7788
|
-
const onUserDeleted = (callback) => createUserEventSubscriber('user.deleted', callback);
|
|
7861
|
+
const onUserDeleted$2 = (callback) => createUserEventSubscriber('user.deleted', callback);
|
|
7789
7862
|
|
|
7790
7863
|
var analyticsEngineOnLoginHandler = () => {
|
|
7791
7864
|
const analyticsEngine = AnalyticsEngine$1.getInstance();
|
|
@@ -9047,7 +9120,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
9047
9120
|
terminateClient();
|
|
9048
9121
|
subscriptions.forEach(fn => fn());
|
|
9049
9122
|
unsubWatcher();
|
|
9050
|
-
}), onUserDeleted((user) => {
|
|
9123
|
+
}), onUserDeleted$2((user) => {
|
|
9051
9124
|
if (user.userId === client.userId) {
|
|
9052
9125
|
terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
|
|
9053
9126
|
subscriptions.forEach(fn => fn());
|
|
@@ -9599,76 +9672,6 @@ const removeFunctionProperties = (obj) => {
|
|
|
9599
9672
|
return Object.fromEntries(entries);
|
|
9600
9673
|
};
|
|
9601
9674
|
|
|
9602
|
-
/**
|
|
9603
|
-
* ```js
|
|
9604
|
-
* import { isEqual } from '~/utils/isEqual'
|
|
9605
|
-
* const isEqual = isEqual(post1, post2)
|
|
9606
|
-
* ```
|
|
9607
|
-
*
|
|
9608
|
-
* Compares two Amity.Model
|
|
9609
|
-
*
|
|
9610
|
-
* @param x the Amity.Model to compare
|
|
9611
|
-
* @param y the Amity.Model to compare wit x
|
|
9612
|
-
* @returns a boolean based on equality
|
|
9613
|
-
*
|
|
9614
|
-
* @category utility
|
|
9615
|
-
* @private
|
|
9616
|
-
*/
|
|
9617
|
-
function isEqual(x, y) {
|
|
9618
|
-
if (x === null || x === undefined || y === null || y === undefined) {
|
|
9619
|
-
return x === y;
|
|
9620
|
-
}
|
|
9621
|
-
// after this just checking type of one would be enough
|
|
9622
|
-
if (x.constructor !== y.constructor) {
|
|
9623
|
-
return false;
|
|
9624
|
-
}
|
|
9625
|
-
// if they are functions, they should exactly refer to same one (because of closures)
|
|
9626
|
-
if (x instanceof Function) {
|
|
9627
|
-
return x === y;
|
|
9628
|
-
}
|
|
9629
|
-
// if they are regexps, they should exactly refer to same one
|
|
9630
|
-
if (x instanceof RegExp) {
|
|
9631
|
-
return x === y;
|
|
9632
|
-
}
|
|
9633
|
-
if (x === y || x.valueOf() === y.valueOf()) {
|
|
9634
|
-
return true;
|
|
9635
|
-
}
|
|
9636
|
-
if (Array.isArray(x) && x.length !== y.length) {
|
|
9637
|
-
return false;
|
|
9638
|
-
}
|
|
9639
|
-
// check each element of the array for equality
|
|
9640
|
-
if (Array.isArray(x) && Array.isArray(y)) {
|
|
9641
|
-
if (x.length !== y.length)
|
|
9642
|
-
return false;
|
|
9643
|
-
for (let i = 0; i < x.length; i += 1) {
|
|
9644
|
-
if (!isEqual(x[i], y[i]))
|
|
9645
|
-
return false;
|
|
9646
|
-
}
|
|
9647
|
-
// if all elements are equal, the arrays are equal
|
|
9648
|
-
return true;
|
|
9649
|
-
}
|
|
9650
|
-
// if they are dates, they must had equal valueOf
|
|
9651
|
-
if (x instanceof Date) {
|
|
9652
|
-
return false;
|
|
9653
|
-
}
|
|
9654
|
-
// if they are strictly equal, they both need to be object at least
|
|
9655
|
-
if (!(x instanceof Object)) {
|
|
9656
|
-
return false;
|
|
9657
|
-
}
|
|
9658
|
-
if (!(y instanceof Object)) {
|
|
9659
|
-
return false;
|
|
9660
|
-
}
|
|
9661
|
-
// recursive object equality check
|
|
9662
|
-
const p = Object.keys(x);
|
|
9663
|
-
return (Object.keys(y).every(i => {
|
|
9664
|
-
// @ts-ignore
|
|
9665
|
-
return p.indexOf(i) !== -1;
|
|
9666
|
-
}) &&
|
|
9667
|
-
p.every(i => {
|
|
9668
|
-
return isEqual(x[i], y[i]);
|
|
9669
|
-
}));
|
|
9670
|
-
}
|
|
9671
|
-
|
|
9672
9675
|
/**
|
|
9673
9676
|
* @deprecated This function is deprecated
|
|
9674
9677
|
*/
|
|
@@ -9905,6 +9908,19 @@ var index$l = /*#__PURE__*/Object.freeze({
|
|
|
9905
9908
|
getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
|
|
9906
9909
|
});
|
|
9907
9910
|
|
|
9911
|
+
function prepareFollowersPayload(response) {
|
|
9912
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
9913
|
+
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
9914
|
+
}
|
|
9915
|
+
function prepareFollowingsPayload(response) {
|
|
9916
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
9917
|
+
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
9918
|
+
}
|
|
9919
|
+
function prepareFollowStatusPayload(response) {
|
|
9920
|
+
const { follows } = response, rest = __rest(response, ["follows"]);
|
|
9921
|
+
return Object.assign(Object.assign({}, rest), { follows });
|
|
9922
|
+
}
|
|
9923
|
+
|
|
9908
9924
|
/* begin_public_function
|
|
9909
9925
|
id: user.relationship.block
|
|
9910
9926
|
*/
|
|
@@ -9933,7 +9949,8 @@ const blockUser = async (userId) => {
|
|
|
9933
9949
|
ingestInCache(followStatus, { cachedAt });
|
|
9934
9950
|
upsertInCache(['followInfo', 'get', userId], followCounts[0], { cachedAt });
|
|
9935
9951
|
}
|
|
9936
|
-
|
|
9952
|
+
const payload = prepareFollowStatusPayload(followStatus);
|
|
9953
|
+
fireEvent('local.follow.unfollowed', payload);
|
|
9937
9954
|
return data;
|
|
9938
9955
|
};
|
|
9939
9956
|
/* end_public_function */
|
|
@@ -9966,170 +9983,397 @@ const unBlockUser = async (userId) => {
|
|
|
9966
9983
|
ingestInCache(followStatus, { cachedAt });
|
|
9967
9984
|
upsertInCache(['followInfo', 'get', userId], followCounts[0], { cachedAt });
|
|
9968
9985
|
}
|
|
9969
|
-
|
|
9986
|
+
const payload = prepareFollowStatusPayload(followStatus);
|
|
9987
|
+
fireEvent('local.follow.created', payload);
|
|
9970
9988
|
return data;
|
|
9971
9989
|
};
|
|
9972
9990
|
/* end_public_function */
|
|
9973
9991
|
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
*
|
|
9980
|
-
* @param query The query parameters
|
|
9981
|
-
* @returns A page of {@link Amity.User} objects
|
|
9982
|
-
*
|
|
9983
|
-
* @category Block API
|
|
9984
|
-
* @async
|
|
9985
|
-
*/
|
|
9986
|
-
const queryBlockedUsers = async (query) => {
|
|
9987
|
-
const client = getActiveClient();
|
|
9988
|
-
let params = {};
|
|
9989
|
-
if (query) {
|
|
9990
|
-
const { token, limit } = query;
|
|
9991
|
-
params = {
|
|
9992
|
-
limit,
|
|
9993
|
-
token,
|
|
9994
|
-
};
|
|
9992
|
+
class PaginationController {
|
|
9993
|
+
constructor(queryParams) {
|
|
9994
|
+
const { http } = getActiveClient();
|
|
9995
|
+
this.queryParams = queryParams;
|
|
9996
|
+
this.http = http;
|
|
9995
9997
|
}
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
params,
|
|
9999
|
-
});
|
|
10000
|
-
const payload = prepareUserPayload(data);
|
|
10001
|
-
const cachedAt = client.cache && Date.now();
|
|
10002
|
-
if (client.cache) {
|
|
10003
|
-
ingestInCache(payload, { cachedAt });
|
|
10004
|
-
const cacheKey = ['blockedUsers', 'query', params];
|
|
10005
|
-
pushToCache(cacheKey, { users: payload.users.map(getResolver('user')), paging: data.paging });
|
|
9998
|
+
loadFirstPage() {
|
|
9999
|
+
return this.onFetch("first" /* Amity.LiveCollectionPageDirection.FIRST */);
|
|
10006
10000
|
}
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
const prevPage = toPageRaw(previous);
|
|
10010
|
-
return { data: payload.users, prevPage, nextPage, total, cachedAt };
|
|
10011
|
-
};
|
|
10012
|
-
/**
|
|
10013
|
-
* ```js
|
|
10014
|
-
* import { queryBlockedUsers } from '@amityco/ts-sdk'
|
|
10015
|
-
* const { data: users } = queryBlockedUsers.locally({ page: 'page_token' })
|
|
10016
|
-
* ```
|
|
10017
|
-
*
|
|
10018
|
-
* Queries a paginable list of {@link Amity.User} objects from cache
|
|
10019
|
-
* Search is performed by displayName such as `.startsWith(search)`
|
|
10020
|
-
*
|
|
10021
|
-
* @param query The query parameters
|
|
10022
|
-
* @returns A page of {@link Amity.User} objects
|
|
10023
|
-
*
|
|
10024
|
-
* @category Block API
|
|
10025
|
-
*/
|
|
10026
|
-
queryBlockedUsers.locally = (query = {}) => {
|
|
10027
|
-
var _a, _b, _c;
|
|
10028
|
-
const client = getActiveClient();
|
|
10029
|
-
client.log('user/queryBlockedUsers.locally');
|
|
10030
|
-
if (!client.cache)
|
|
10031
|
-
return;
|
|
10032
|
-
let params = {};
|
|
10033
|
-
if (query) {
|
|
10034
|
-
const { token, limit } = query;
|
|
10035
|
-
params = {
|
|
10036
|
-
token,
|
|
10037
|
-
limit,
|
|
10038
|
-
};
|
|
10001
|
+
loadNextPage() {
|
|
10002
|
+
return this.onFetch("next" /* Amity.LiveCollectionPageDirection.NEXT */);
|
|
10039
10003
|
}
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
const users = (_b = data === null || data === void 0 ? void 0 : data.users.map(userId => pullFromCache(['user', 'get', userId])).filter(Boolean).map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
|
|
10043
|
-
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
10044
|
-
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
10045
|
-
return users.length > 0 && users.length === ((_c = data === null || data === void 0 ? void 0 : data.users) === null || _c === void 0 ? void 0 : _c.length)
|
|
10046
|
-
? { data: users, nextPage, prevPage, total: data === null || data === void 0 ? void 0 : data.paging.total, cachedAt }
|
|
10047
|
-
: undefined;
|
|
10048
|
-
};
|
|
10049
|
-
|
|
10050
|
-
/* eslint-disable no-use-before-define */
|
|
10051
|
-
/* begin_public_function
|
|
10052
|
-
id: user.get_blocked_users
|
|
10053
|
-
*/
|
|
10054
|
-
/**
|
|
10055
|
-
* ```js
|
|
10056
|
-
* import { UserRepository } from '@amityco/ts-sdk'
|
|
10057
|
-
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
10058
|
-
* ```
|
|
10059
|
-
*
|
|
10060
|
-
* Blocks a {@link Amity.InternalUser}
|
|
10061
|
-
*
|
|
10062
|
-
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
10063
|
-
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
10064
|
-
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
10065
|
-
*
|
|
10066
|
-
* @category Post API
|
|
10067
|
-
* @async
|
|
10068
|
-
*/
|
|
10069
|
-
const getBlockedUsers$1 = (params, callback, config) => {
|
|
10070
|
-
const { log, cache } = getActiveClient();
|
|
10071
|
-
if (!cache) {
|
|
10072
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
10004
|
+
loadPreviousPage() {
|
|
10005
|
+
return this.onFetch("prev" /* Amity.LiveCollectionPageDirection.PREV */);
|
|
10073
10006
|
}
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
10078
|
-
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
10079
|
-
const disposers = [];
|
|
10080
|
-
const cacheKey = ['blockedUsers', 'collection', {}];
|
|
10081
|
-
const responder = (data) => {
|
|
10082
|
-
var _a, _b;
|
|
10083
|
-
const users = (_a = data.data
|
|
10084
|
-
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
10085
|
-
.filter(Boolean)
|
|
10086
|
-
.map(({ data }) => LinkedObject.user(data))) !== null && _a !== void 0 ? _a : [];
|
|
10087
|
-
callback({
|
|
10088
|
-
onNextPage: onFetch,
|
|
10089
|
-
data: users,
|
|
10090
|
-
hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
|
|
10091
|
-
loading: data.loading,
|
|
10092
|
-
error: data.error,
|
|
10093
|
-
});
|
|
10094
|
-
};
|
|
10095
|
-
/*
|
|
10096
|
-
* const realtimeRouter = () => {
|
|
10097
|
-
* @TODO: At the time of creating this api blocked user do not have any
|
|
10098
|
-
* observers
|
|
10099
|
-
*};
|
|
10100
|
-
*/
|
|
10101
|
-
const onFetch = (initial = false) => {
|
|
10102
|
-
var _a, _b;
|
|
10103
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10104
|
-
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
10105
|
-
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
10007
|
+
async onFetch(direction = "first" /* Amity.LiveCollectionPageDirection.FIRST */) {
|
|
10008
|
+
var _a, _b, _c, _d;
|
|
10009
|
+
if (direction === 'prev' && !this.previousToken)
|
|
10106
10010
|
return;
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10011
|
+
if (direction === 'next' && !this.nextToken)
|
|
10012
|
+
return;
|
|
10013
|
+
let token;
|
|
10014
|
+
if (direction === 'prev')
|
|
10015
|
+
token = this.previousToken;
|
|
10016
|
+
if (direction === 'next')
|
|
10017
|
+
token = this.nextToken;
|
|
10018
|
+
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
10019
|
+
if (direction === 'first') {
|
|
10020
|
+
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
10021
|
+
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
10022
|
+
}
|
|
10023
|
+
if (direction === 'prev')
|
|
10024
|
+
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
10025
|
+
if (direction === 'next')
|
|
10026
|
+
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
10027
|
+
return queryResponse;
|
|
10028
|
+
}
|
|
10029
|
+
getNextToken() {
|
|
10030
|
+
return this.nextToken;
|
|
10031
|
+
}
|
|
10032
|
+
getPrevToken() {
|
|
10033
|
+
return this.previousToken;
|
|
10034
|
+
}
|
|
10035
|
+
}
|
|
10036
|
+
|
|
10037
|
+
class BlockedUserPaginationController extends PaginationController {
|
|
10038
|
+
async getRequest(queryParams, token) {
|
|
10039
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
10040
|
+
const options = token ? { token } : { limit };
|
|
10041
|
+
const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
|
|
10042
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
10110
10043
|
});
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10044
|
+
return queryResponse;
|
|
10045
|
+
}
|
|
10046
|
+
}
|
|
10047
|
+
|
|
10048
|
+
class QueryStreamController {
|
|
10049
|
+
constructor(query, cacheKey) {
|
|
10050
|
+
this.query = query;
|
|
10051
|
+
this.cacheKey = cacheKey;
|
|
10052
|
+
}
|
|
10053
|
+
}
|
|
10054
|
+
|
|
10055
|
+
class BlockedUserQueryStreamController extends QueryStreamController {
|
|
10056
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
10057
|
+
super(query, cacheKey);
|
|
10058
|
+
this.notifyChange = notifyChange;
|
|
10059
|
+
this.preparePayload = preparePayload;
|
|
10060
|
+
}
|
|
10061
|
+
async saveToMainDB(response) {
|
|
10062
|
+
const processedPayload = await this.preparePayload(response);
|
|
10063
|
+
const client = getActiveClient();
|
|
10064
|
+
const cachedAt = client.cache && Date.now();
|
|
10065
|
+
if (client.cache) {
|
|
10066
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
10067
|
+
}
|
|
10068
|
+
}
|
|
10069
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
10070
|
+
var _a, _b;
|
|
10071
|
+
if (refresh) {
|
|
10072
|
+
pushToCache(this.cacheKey, {
|
|
10073
|
+
data: response.users.map(getResolver('user')),
|
|
10074
|
+
});
|
|
10075
|
+
}
|
|
10076
|
+
else {
|
|
10077
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10078
|
+
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
10079
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
|
|
10080
|
+
}
|
|
10081
|
+
}
|
|
10082
|
+
reactor(action) {
|
|
10083
|
+
return (followStatus) => {
|
|
10084
|
+
var _a;
|
|
10085
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10086
|
+
pushToCache(this.cacheKey, collection);
|
|
10087
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
10088
|
+
};
|
|
10089
|
+
}
|
|
10090
|
+
subscribeRTE(createSubscriber) {
|
|
10091
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
10092
|
+
}
|
|
10093
|
+
}
|
|
10094
|
+
|
|
10095
|
+
class PaginationNoPageController {
|
|
10096
|
+
constructor(queryParams) {
|
|
10097
|
+
const { http } = getActiveClient();
|
|
10098
|
+
this.queryParams = queryParams;
|
|
10099
|
+
this.http = http;
|
|
10100
|
+
}
|
|
10101
|
+
async onFetch() {
|
|
10102
|
+
const queryResponse = await this.getRequest(this.queryParams);
|
|
10103
|
+
return queryResponse;
|
|
10104
|
+
}
|
|
10105
|
+
}
|
|
10106
|
+
|
|
10107
|
+
class LiveCollectionController {
|
|
10108
|
+
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
10109
|
+
this.paginationController = paginationController;
|
|
10110
|
+
this.queryStreamId = queryStreamId;
|
|
10111
|
+
this.cacheKey = cacheKey;
|
|
10112
|
+
this.callback = callback;
|
|
10113
|
+
}
|
|
10114
|
+
async refresh() {
|
|
10115
|
+
try {
|
|
10116
|
+
let result;
|
|
10117
|
+
if (this.paginationController instanceof PaginationNoPageController) {
|
|
10118
|
+
result = await this.paginationController.onFetch();
|
|
10122
10119
|
}
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10120
|
+
else {
|
|
10121
|
+
result = await this.paginationController.loadFirstPage();
|
|
10122
|
+
}
|
|
10123
|
+
if (!result)
|
|
10124
|
+
return;
|
|
10125
|
+
await this.persistModel(result);
|
|
10126
|
+
this.persistQueryStream({
|
|
10127
|
+
response: result,
|
|
10128
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
10129
|
+
refresh: true,
|
|
10130
|
+
});
|
|
10131
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
10132
|
+
}
|
|
10133
|
+
catch (e) {
|
|
10134
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
10135
|
+
}
|
|
10136
|
+
}
|
|
10137
|
+
loadPage({ initial = false, direction = "next" /* Amity.LiveCollectionPageDirection.NEXT */, }) {
|
|
10138
|
+
this.setup();
|
|
10139
|
+
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
10140
|
+
if (initial) {
|
|
10141
|
+
this.refresh();
|
|
10142
|
+
}
|
|
10143
|
+
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
10144
|
+
this.loadPrevPage();
|
|
10145
|
+
}
|
|
10146
|
+
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
10147
|
+
this.loadNextPage();
|
|
10148
|
+
}
|
|
10149
|
+
}
|
|
10150
|
+
async loadNextPage() {
|
|
10151
|
+
try {
|
|
10152
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
10153
|
+
return;
|
|
10154
|
+
const result = await this.paginationController.loadNextPage();
|
|
10155
|
+
if (!result)
|
|
10156
|
+
return;
|
|
10157
|
+
await this.persistModel(result);
|
|
10158
|
+
this.persistQueryStream({
|
|
10159
|
+
response: result,
|
|
10160
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
10161
|
+
});
|
|
10162
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
10163
|
+
}
|
|
10164
|
+
catch (e) {
|
|
10165
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
10166
|
+
}
|
|
10167
|
+
}
|
|
10168
|
+
async loadPrevPage() {
|
|
10169
|
+
try {
|
|
10170
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
10171
|
+
return;
|
|
10172
|
+
const result = await this.paginationController.loadPreviousPage();
|
|
10173
|
+
if (!result)
|
|
10174
|
+
return;
|
|
10175
|
+
await this.persistModel(result);
|
|
10176
|
+
this.persistQueryStream({
|
|
10177
|
+
response: result,
|
|
10178
|
+
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
10179
|
+
});
|
|
10180
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
10181
|
+
}
|
|
10182
|
+
catch (e) {
|
|
10183
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
10184
|
+
}
|
|
10185
|
+
}
|
|
10186
|
+
shouldNotify(data) {
|
|
10187
|
+
const newData = data.map(convertGetterPropsToStatic).map(removeFunctionProperties);
|
|
10188
|
+
if (isEqual(this.snapshot, newData))
|
|
10189
|
+
return false;
|
|
10190
|
+
this.snapshot = newData;
|
|
10191
|
+
return true;
|
|
10192
|
+
}
|
|
10193
|
+
getCacheKey() {
|
|
10194
|
+
return this.cacheKey;
|
|
10195
|
+
}
|
|
10196
|
+
}
|
|
10197
|
+
|
|
10198
|
+
function prepareBlockedUserPayload(response) {
|
|
10199
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
10200
|
+
return Object.assign(Object.assign({}, rest), { follows: follows.map(follow => {
|
|
10201
|
+
const followUser = users.find(user => user.userId === follow.from);
|
|
10202
|
+
return Object.assign(Object.assign({}, follow), { user: convertRawUserToInternalUser(followUser) });
|
|
10203
|
+
}), users: users.map(convertRawUserToInternalUser) });
|
|
10204
|
+
}
|
|
10205
|
+
|
|
10206
|
+
/**
|
|
10207
|
+
* ```js
|
|
10208
|
+
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
10209
|
+
* const dispose = onUserUpdated(user => {
|
|
10210
|
+
* // ...
|
|
10211
|
+
* })
|
|
10212
|
+
* ```
|
|
10213
|
+
*
|
|
10214
|
+
* Fired when a {@link Amity.InternalUser} has been updated
|
|
10215
|
+
*
|
|
10216
|
+
* @param callback The function to call when the event was fired
|
|
10217
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
10218
|
+
*
|
|
10219
|
+
* @category User Events
|
|
10220
|
+
*/
|
|
10221
|
+
const onUserUpdated = (callback) => createUserEventSubscriber('user.updated', callback);
|
|
10222
|
+
|
|
10223
|
+
/**
|
|
10224
|
+
* ```js
|
|
10225
|
+
* import { onUserFlagged } from '@amityco/ts-sdk'
|
|
10226
|
+
* const dispose = onUserFlagged(user => {
|
|
10227
|
+
* // ...
|
|
10228
|
+
* })
|
|
10229
|
+
* ```
|
|
10230
|
+
*
|
|
10231
|
+
* Fired when a {@link Amity.InternalUser} has been flagged
|
|
10232
|
+
*
|
|
10233
|
+
* @param callback The function to call when the event was fired
|
|
10234
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
10235
|
+
*
|
|
10236
|
+
* @category User Events
|
|
10237
|
+
*/
|
|
10238
|
+
const onUserFlagged = (callback) => createUserEventSubscriber('user.flagged', callback);
|
|
10239
|
+
|
|
10240
|
+
/**
|
|
10241
|
+
* ```js
|
|
10242
|
+
* import { onUserUnflagged } from '@amityco/ts-sdk'
|
|
10243
|
+
* const dispose = onUserUnflagged(user => {
|
|
10244
|
+
* // ...
|
|
10245
|
+
* })
|
|
10246
|
+
* ```
|
|
10247
|
+
*
|
|
10248
|
+
* Fired when a flag has been removed from a {@link Amity.InternalUser}
|
|
10249
|
+
*
|
|
10250
|
+
* @param callback The function to call when the event was fired
|
|
10251
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
10252
|
+
*
|
|
10253
|
+
* @category User Events
|
|
10254
|
+
*/
|
|
10255
|
+
const onUserUnflagged = (callback) => createUserEventSubscriber('user.unflagged', callback);
|
|
10256
|
+
|
|
10257
|
+
/**
|
|
10258
|
+
* ```js
|
|
10259
|
+
* import { onUserFlagCleared } from '@amityco/ts-sdk'
|
|
10260
|
+
* const dispose = onUserFlagCleared(user => {
|
|
10261
|
+
* // ...
|
|
10262
|
+
* })
|
|
10263
|
+
* ```
|
|
10264
|
+
*
|
|
10265
|
+
* Fired when flags have been cleared for a {@link Amity.InternalUser}
|
|
10266
|
+
*
|
|
10267
|
+
* @param callback The function to call when the event was fired
|
|
10268
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
10269
|
+
*
|
|
10270
|
+
* @category User Events
|
|
10271
|
+
*/
|
|
10272
|
+
const onUserFlagCleared = (callback) => createUserEventSubscriber('user.flagCleared', callback);
|
|
10273
|
+
|
|
10274
|
+
var EnumUserActions;
|
|
10275
|
+
(function (EnumUserActions) {
|
|
10276
|
+
EnumUserActions["OnUserDeleted"] = "onUserDeleted";
|
|
10277
|
+
EnumUserActions["OnUserUpdated"] = "onUserUpdated";
|
|
10278
|
+
EnumUserActions["OnUserFlagged"] = "onUserFlagged";
|
|
10279
|
+
EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
|
|
10280
|
+
EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
|
|
10281
|
+
})(EnumUserActions || (EnumUserActions = {}));
|
|
10282
|
+
|
|
10283
|
+
class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
10284
|
+
constructor(query, callback) {
|
|
10285
|
+
const queryStreamId = hash__default["default"](query);
|
|
10286
|
+
const cacheKey = ['blockedUsers', 'collection', queryStreamId];
|
|
10287
|
+
const paginationController = new BlockedUserPaginationController(query);
|
|
10288
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
10289
|
+
this.query = query;
|
|
10290
|
+
this.queryStreamController = new BlockedUserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareBlockedUserPayload);
|
|
10291
|
+
this.callback = callback.bind(this);
|
|
10292
|
+
this.loadPage({ initial: true });
|
|
10293
|
+
}
|
|
10294
|
+
setup() {
|
|
10295
|
+
var _a;
|
|
10296
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10297
|
+
if (!collection) {
|
|
10298
|
+
pushToCache(this.cacheKey, {
|
|
10299
|
+
data: [],
|
|
10300
|
+
params: {},
|
|
10301
|
+
});
|
|
10302
|
+
}
|
|
10303
|
+
}
|
|
10304
|
+
async persistModel(queryPayload) {
|
|
10305
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
10306
|
+
}
|
|
10307
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
10308
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
10309
|
+
}
|
|
10310
|
+
startSubscription() {
|
|
10311
|
+
return this.queryStreamController.subscribeRTE([
|
|
10312
|
+
{
|
|
10313
|
+
fn: onUserDeleted$2,
|
|
10314
|
+
action: EnumUserActions.OnUserDeleted,
|
|
10315
|
+
},
|
|
10316
|
+
]);
|
|
10317
|
+
}
|
|
10318
|
+
notifyChange({ origin, loading, error }) {
|
|
10319
|
+
var _a, _b;
|
|
10320
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10321
|
+
if (!collection)
|
|
10322
|
+
return;
|
|
10323
|
+
const data = this.applyFilter((_b = collection.data
|
|
10324
|
+
.map(id => pullFromCache(['user', 'get', id]))
|
|
10325
|
+
.filter(isNonNullable)
|
|
10326
|
+
.map(({ data }) => data)
|
|
10327
|
+
.map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
|
|
10328
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
10329
|
+
return;
|
|
10330
|
+
this.callback({
|
|
10331
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
10332
|
+
data,
|
|
10333
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
10334
|
+
loading,
|
|
10335
|
+
error,
|
|
10336
|
+
});
|
|
10337
|
+
}
|
|
10338
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10339
|
+
applyFilter(data) {
|
|
10340
|
+
let users = data;
|
|
10341
|
+
users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
|
|
10342
|
+
return users;
|
|
10343
|
+
}
|
|
10344
|
+
}
|
|
10345
|
+
|
|
10346
|
+
/* begin_public_function
|
|
10347
|
+
id: user.get_blocked_users
|
|
10348
|
+
*/
|
|
10349
|
+
/**
|
|
10350
|
+
* ```js
|
|
10351
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
10352
|
+
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
10353
|
+
* ```
|
|
10354
|
+
*
|
|
10355
|
+
* Blocks a {@link Amity.InternalUser}
|
|
10356
|
+
*
|
|
10357
|
+
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
10358
|
+
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
10359
|
+
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
10360
|
+
*
|
|
10361
|
+
* @category Post API
|
|
10362
|
+
* @async
|
|
10363
|
+
*/
|
|
10364
|
+
const getBlockedUsers$1 = (params, callback, config) => {
|
|
10365
|
+
const { log, cache } = getActiveClient();
|
|
10366
|
+
if (!cache) {
|
|
10367
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
10368
|
+
}
|
|
10369
|
+
const timestamp = Date.now();
|
|
10370
|
+
log(`getBlockedUsers(tmpid: ${timestamp}) > listen`);
|
|
10371
|
+
const blockedUserLiveCollection = new BlockedUserLiveCollectionController(params, callback);
|
|
10372
|
+
const disposers = blockedUserLiveCollection.startSubscription();
|
|
10373
|
+
const cacheKey = blockedUserLiveCollection.getCacheKey();
|
|
10374
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
10131
10375
|
return () => {
|
|
10132
|
-
log(`
|
|
10376
|
+
log(`getBlockedUsers(tmpid: ${timestamp}) > dispose`);
|
|
10133
10377
|
disposers.forEach(fn => fn());
|
|
10134
10378
|
dropFromCache(cacheKey);
|
|
10135
10379
|
};
|
|
@@ -10139,7 +10383,7 @@ const getBlockedUsers$1 = (params, callback, config) => {
|
|
|
10139
10383
|
/* eslint-disable no-use-before-define */
|
|
10140
10384
|
const getBlockedUsers = (params, callback, config) => {
|
|
10141
10385
|
console.log('Deprecation Notice: UserRepository.Relationship.getBlockedUsers will be deprecated on 9th June 2023, please use UserRepository.getBlockedUsers instead.');
|
|
10142
|
-
return getBlockedUsers$1(params, callback
|
|
10386
|
+
return getBlockedUsers$1(params, callback);
|
|
10143
10387
|
};
|
|
10144
10388
|
|
|
10145
10389
|
/* begin_public_function
|
|
@@ -10167,7 +10411,13 @@ const follow = async (userId) => {
|
|
|
10167
10411
|
if (client.cache) {
|
|
10168
10412
|
ingestInCache(data, { cachedAt });
|
|
10169
10413
|
}
|
|
10170
|
-
|
|
10414
|
+
const payload = prepareFollowStatusPayload(data);
|
|
10415
|
+
if (data.follows[0].status === 'accepted') {
|
|
10416
|
+
fireEvent('local.follow.created', payload);
|
|
10417
|
+
}
|
|
10418
|
+
else {
|
|
10419
|
+
fireEvent('local.follow.requested', payload);
|
|
10420
|
+
}
|
|
10171
10421
|
return {
|
|
10172
10422
|
data: data.follows[0],
|
|
10173
10423
|
cachedAt,
|
|
@@ -10199,7 +10449,8 @@ const unfollow = async (userId) => {
|
|
|
10199
10449
|
if (client.cache) {
|
|
10200
10450
|
ingestInCache(data);
|
|
10201
10451
|
}
|
|
10202
|
-
|
|
10452
|
+
const payload = prepareFollowStatusPayload(data);
|
|
10453
|
+
fireEvent('local.follow.unfollowed', payload);
|
|
10203
10454
|
return true;
|
|
10204
10455
|
};
|
|
10205
10456
|
/* end_public_function */
|
|
@@ -10228,7 +10479,8 @@ const acceptFollower = async (userId) => {
|
|
|
10228
10479
|
if (client.cache) {
|
|
10229
10480
|
ingestInCache(data);
|
|
10230
10481
|
}
|
|
10231
|
-
|
|
10482
|
+
const payload = prepareFollowStatusPayload(data);
|
|
10483
|
+
fireEvent('local.follow.accepted', payload);
|
|
10232
10484
|
return true;
|
|
10233
10485
|
};
|
|
10234
10486
|
|
|
@@ -10256,7 +10508,8 @@ const acceptMyFollower = async (userId) => {
|
|
|
10256
10508
|
if (client.cache) {
|
|
10257
10509
|
ingestInCache(data);
|
|
10258
10510
|
}
|
|
10259
|
-
|
|
10511
|
+
const payload = prepareFollowStatusPayload(data);
|
|
10512
|
+
fireEvent('local.follow.accepted', payload);
|
|
10260
10513
|
return true;
|
|
10261
10514
|
};
|
|
10262
10515
|
/* end_public_function */
|
|
@@ -10285,7 +10538,8 @@ const declineFollower = async (userId) => {
|
|
|
10285
10538
|
if (client.cache) {
|
|
10286
10539
|
ingestInCache(data);
|
|
10287
10540
|
}
|
|
10288
|
-
|
|
10541
|
+
const payload = prepareFollowStatusPayload(data);
|
|
10542
|
+
fireEvent('local.follow.requestDeclined', payload);
|
|
10289
10543
|
return true;
|
|
10290
10544
|
};
|
|
10291
10545
|
|
|
@@ -10313,29 +10567,35 @@ const declineMyFollower = async (userId) => {
|
|
|
10313
10567
|
if (client.cache) {
|
|
10314
10568
|
ingestInCache(data);
|
|
10315
10569
|
}
|
|
10316
|
-
|
|
10570
|
+
const payload = prepareFollowStatusPayload(data);
|
|
10571
|
+
fireEvent('local.follow.requestDeclined', payload);
|
|
10317
10572
|
return true;
|
|
10318
10573
|
};
|
|
10319
10574
|
/* end_public_function */
|
|
10320
10575
|
|
|
10321
10576
|
const createFollowEventSubscriber = (event, callback) => {
|
|
10322
10577
|
const client = getActiveClient();
|
|
10323
|
-
const filter = (
|
|
10324
|
-
|
|
10578
|
+
const filter = (data) => {
|
|
10579
|
+
const payload = prepareFollowersPayload(data);
|
|
10580
|
+
if (!client.cache) {
|
|
10581
|
+
callback(payload.follows[0]);
|
|
10582
|
+
}
|
|
10583
|
+
else {
|
|
10584
|
+
ingestInCache(payload);
|
|
10585
|
+
callback(payload.follows[0]);
|
|
10586
|
+
}
|
|
10587
|
+
};
|
|
10588
|
+
return createEventSubscriber(client, event, event, filter);
|
|
10589
|
+
};
|
|
10590
|
+
const createLocalFollowEventSubscriber = (event, callback) => {
|
|
10591
|
+
const client = getActiveClient();
|
|
10592
|
+
const filter = (data) => {
|
|
10593
|
+
const payload = prepareFollowStatusPayload(data);
|
|
10325
10594
|
if (!client.cache) {
|
|
10326
10595
|
callback(payload.follows[0]);
|
|
10327
10596
|
}
|
|
10328
10597
|
else {
|
|
10329
10598
|
ingestInCache(payload);
|
|
10330
|
-
const queries = [
|
|
10331
|
-
...((_a = queryCache(['followers', 'query'])) !== null && _a !== void 0 ? _a : []),
|
|
10332
|
-
...((_b = queryCache(['followings', 'query'])) !== null && _b !== void 0 ? _b : []),
|
|
10333
|
-
];
|
|
10334
|
-
queries
|
|
10335
|
-
.filter(({ key }) =>
|
|
10336
|
-
// @ts-ignore
|
|
10337
|
-
key[2].userId === payload.follows[0].from || key[2].userId === payload.follows[0].to)
|
|
10338
|
-
.forEach(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
|
|
10339
10599
|
callback(payload.follows[0]);
|
|
10340
10600
|
}
|
|
10341
10601
|
};
|
|
@@ -10554,12 +10814,27 @@ const onFollowInfoUpdated = (callback) => {
|
|
|
10554
10814
|
createFollowEventSubscriber('follow.requestCanceled', handler),
|
|
10555
10815
|
createFollowEventSubscriber('follow.requestDeclined', handler),
|
|
10556
10816
|
createFollowEventSubscriber('follow.followerDeleted', handler),
|
|
10817
|
+
createLocalFollowEventSubscriber('local.follow.created', handler),
|
|
10818
|
+
createLocalFollowEventSubscriber('local.follow.requested', handler),
|
|
10819
|
+
createLocalFollowEventSubscriber('local.follow.accepted', handler),
|
|
10820
|
+
createLocalFollowEventSubscriber('local.follow.unfollowed', handler),
|
|
10821
|
+
createLocalFollowEventSubscriber('local.follow.requestDeclined', handler),
|
|
10557
10822
|
];
|
|
10558
10823
|
return () => {
|
|
10559
10824
|
disposers.forEach(fn => fn());
|
|
10560
10825
|
};
|
|
10561
10826
|
};
|
|
10562
10827
|
|
|
10828
|
+
const onLocalUserFollowed = (callback) => createLocalFollowEventSubscriber('local.follow.created', callback);
|
|
10829
|
+
|
|
10830
|
+
const onLocalUserUnfollowed = (callback) => createLocalFollowEventSubscriber('local.follow.unfollowed', callback);
|
|
10831
|
+
|
|
10832
|
+
const onLocalFollowerRequested = (callback) => createLocalFollowEventSubscriber('local.follow.requested', callback);
|
|
10833
|
+
|
|
10834
|
+
const onLocalFollowRequestAccepted = (callback) => createLocalFollowEventSubscriber('local.follow.accepted', callback);
|
|
10835
|
+
|
|
10836
|
+
const onLocalFollowRequestDeclined = (callback) => createLocalFollowEventSubscriber('local.follow.requestDeclined', callback);
|
|
10837
|
+
|
|
10563
10838
|
/**
|
|
10564
10839
|
* ```js
|
|
10565
10840
|
* import { observeFollowInfo } from '@amityco/ts-sdk'
|
|
@@ -10632,7 +10907,7 @@ const observeFollowers = (userId, callback) => {
|
|
|
10632
10907
|
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, status);
|
|
10633
10908
|
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, status);
|
|
10634
10909
|
};
|
|
10635
|
-
disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')));
|
|
10910
|
+
disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')), onLocalFollowerRequested(x => router(x, 'onRequested')), onLocalFollowRequestAccepted(x => router(x, 'onAccepted')), onLocalFollowRequestDeclined(x => router(x, 'onDeclined')), onLocalUserFollowed(x => router(x, 'onFollowed')), onLocalUserUnfollowed(x => router(x, 'onUnfollowed')));
|
|
10636
10911
|
return () => {
|
|
10637
10912
|
log(`observeFollowers(tmpid: ${timestamp}) > dispose`);
|
|
10638
10913
|
disposers.forEach(fn => fn());
|
|
@@ -10668,216 +10943,397 @@ const observeFollowings = (userId, callback) => {
|
|
|
10668
10943
|
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, status);
|
|
10669
10944
|
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, status);
|
|
10670
10945
|
};
|
|
10671
|
-
disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')));
|
|
10946
|
+
disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')), onLocalFollowerRequested(x => router(x, 'onRequested')), onLocalFollowRequestAccepted(x => router(x, 'onAccepted')), onLocalFollowRequestDeclined(x => router(x, 'onDeclined')), onLocalUserFollowed(x => router(x, 'onFollowed')), onLocalUserUnfollowed(x => router(x, 'onUnfollowed')));
|
|
10672
10947
|
return () => {
|
|
10673
10948
|
log(`observeFollowings(tmpid: ${timestamp}) > dispose`);
|
|
10674
10949
|
disposers.forEach(fn => fn());
|
|
10675
10950
|
};
|
|
10676
10951
|
};
|
|
10677
10952
|
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
if (client.cache) {
|
|
10689
|
-
ingestInCache(payload, { cachedAt });
|
|
10690
|
-
const cacheKey = [
|
|
10691
|
-
'follow',
|
|
10692
|
-
'query',
|
|
10693
|
-
Object.assign(Object.assign({}, params), { userId, options: Object.assign({}, page), type: key }),
|
|
10694
|
-
];
|
|
10695
|
-
pushToCache(cacheKey, { follows: follows.map(getResolver('follow')), paging });
|
|
10696
|
-
}
|
|
10697
|
-
const nextPage = toPageRaw(paging.next);
|
|
10698
|
-
const prevPage = toPageRaw(paging.previous);
|
|
10699
|
-
return { data: follows, cachedAt, prevPage, nextPage };
|
|
10700
|
-
};
|
|
10701
|
-
queryFollows.locally = (key, query) => {
|
|
10702
|
-
var _a, _b;
|
|
10703
|
-
const client = getActiveClient();
|
|
10704
|
-
client.log(`follow/queryF${key.substring(1)}.locally`, query);
|
|
10705
|
-
if (!client.cache)
|
|
10706
|
-
return;
|
|
10707
|
-
const { page } = query, params = __rest(query, ["page"]);
|
|
10708
|
-
const queryKey = [
|
|
10709
|
-
'follow',
|
|
10710
|
-
'query',
|
|
10711
|
-
Object.assign(Object.assign({}, params), { options: Object.assign({}, page), type: key }),
|
|
10712
|
-
];
|
|
10713
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
10714
|
-
if (!(data === null || data === void 0 ? void 0 : data.follows.length)) {
|
|
10715
|
-
return;
|
|
10953
|
+
class FollowerPaginationController extends PaginationController {
|
|
10954
|
+
async getRequest(queryParams, token) {
|
|
10955
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
10956
|
+
const options = token ? { token } : { limit };
|
|
10957
|
+
const client = getActiveClient();
|
|
10958
|
+
const path = client.userId === userId ? `/api/v4/me/followers` : `/api/v4/users/${userId}/followers`;
|
|
10959
|
+
const { data: queryResponse } = await this.http.get(path, {
|
|
10960
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
10961
|
+
});
|
|
10962
|
+
return queryResponse;
|
|
10716
10963
|
}
|
|
10717
|
-
|
|
10718
|
-
.map(key => pullFromCache(['follow', 'get', key]))
|
|
10719
|
-
.filter(Boolean)
|
|
10720
|
-
.map(({ data }) => data);
|
|
10721
|
-
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
10722
|
-
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
10723
|
-
return follows.length === ((_b = data === null || data === void 0 ? void 0 : data.follows) === null || _b === void 0 ? void 0 : _b.length)
|
|
10724
|
-
? { data: follows, cachedAt, prevPage, nextPage }
|
|
10725
|
-
: undefined;
|
|
10726
|
-
};
|
|
10727
|
-
|
|
10728
|
-
/**
|
|
10729
|
-
* ```js
|
|
10730
|
-
* import { queryFollowers } from '@amityco/ts-sdk'
|
|
10731
|
-
* const { data: followers, prevPage, nextPage } = await queryFollowers({ userId })
|
|
10732
|
-
* ```
|
|
10733
|
-
*
|
|
10734
|
-
* Queries a paginable list of {@link Amity.FollowStatus}
|
|
10735
|
-
*
|
|
10736
|
-
* @param query The query parameters
|
|
10737
|
-
* @returns followers
|
|
10738
|
-
*
|
|
10739
|
-
* @category Follow API
|
|
10740
|
-
* @async
|
|
10741
|
-
*/
|
|
10742
|
-
const queryFollowers = async (query) => queryFollows('followers', query);
|
|
10743
|
-
/**
|
|
10744
|
-
* ```js
|
|
10745
|
-
* import { queryFollowers } from '@amityco/ts-sdk'
|
|
10746
|
-
* const { data: followers, prevPage, nextPage } = queryFollowers.locally({ userId })
|
|
10747
|
-
* ```
|
|
10748
|
-
*
|
|
10749
|
-
* Queries a paginable list of {@link Amity.FollowStatus} objects from cache
|
|
10750
|
-
*
|
|
10751
|
-
* @param query The query parameters
|
|
10752
|
-
* @returns followers
|
|
10753
|
-
*
|
|
10754
|
-
* @category Post API
|
|
10755
|
-
*/
|
|
10756
|
-
queryFollowers.locally = (query) => queryFollows.locally('followers', query);
|
|
10964
|
+
}
|
|
10757
10965
|
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
10776
|
-
*
|
|
10777
|
-
* @category Followers Live Collection
|
|
10778
|
-
*/
|
|
10779
|
-
const getFollowers = (params, callback, config) => {
|
|
10780
|
-
const { log, cache } = getActiveClient();
|
|
10781
|
-
if (!cache) {
|
|
10782
|
-
console.log('For using Live Collection feature you need to enable Cache!');
|
|
10966
|
+
var EnumFollowActions;
|
|
10967
|
+
(function (EnumFollowActions) {
|
|
10968
|
+
EnumFollowActions["OnRequested"] = "onRequested";
|
|
10969
|
+
EnumFollowActions["OnAccepted"] = "onAccepted";
|
|
10970
|
+
EnumFollowActions["OnDeclined"] = "onDeclined";
|
|
10971
|
+
EnumFollowActions["OnCanceled"] = "onCanceled";
|
|
10972
|
+
EnumFollowActions["OnFollowed"] = "onFollowed";
|
|
10973
|
+
EnumFollowActions["OnUnfollowed"] = "onUnfollowed";
|
|
10974
|
+
EnumFollowActions["OnDeleted"] = "onDeleted";
|
|
10975
|
+
EnumFollowActions["OnUserDeleted"] = "onUserDeleted";
|
|
10976
|
+
})(EnumFollowActions || (EnumFollowActions = {}));
|
|
10977
|
+
|
|
10978
|
+
class FollowerQueryStreamController extends QueryStreamController {
|
|
10979
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
10980
|
+
super(query, cacheKey);
|
|
10981
|
+
this.notifyChange = notifyChange;
|
|
10982
|
+
this.preparePayload = preparePayload;
|
|
10783
10983
|
}
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
const cacheKey = ['follow', 'collection', { userId: params.userId, type: 'follower' }];
|
|
10791
|
-
const responder = (data) => {
|
|
10792
|
-
var _a, _b;
|
|
10793
|
-
let followers = (_a = data.data
|
|
10794
|
-
.map(key => pullFromCache(['follow', 'get', key]))
|
|
10795
|
-
.filter(Boolean)
|
|
10796
|
-
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
10797
|
-
if (params.status && params.status !== 'all') {
|
|
10798
|
-
followers = filterByPropEquality(followers, 'status', params.status);
|
|
10984
|
+
async saveToMainDB(response) {
|
|
10985
|
+
const processedPayload = await this.preparePayload(response);
|
|
10986
|
+
const client = getActiveClient();
|
|
10987
|
+
const cachedAt = client.cache && Date.now();
|
|
10988
|
+
if (client.cache) {
|
|
10989
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
10799
10990
|
}
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
};
|
|
10808
|
-
const realtimeRouter = (action) => (followStatus) => {
|
|
10809
|
-
var _a;
|
|
10810
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10811
|
-
if (params.userId !== followStatus.to || !collection)
|
|
10812
|
-
return;
|
|
10813
|
-
if (['onDeclined', 'onCanceled', 'onUnfollowed', 'onDeleted'].includes(action)) {
|
|
10814
|
-
collection.data = collection.data.filter(p => p !== getResolver('follow')(followStatus));
|
|
10991
|
+
}
|
|
10992
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
10993
|
+
var _a, _b;
|
|
10994
|
+
if (refresh) {
|
|
10995
|
+
pushToCache(this.cacheKey, {
|
|
10996
|
+
data: response.follows.map(getResolver('follow')),
|
|
10997
|
+
});
|
|
10815
10998
|
}
|
|
10816
|
-
else
|
|
10817
|
-
collection
|
|
10999
|
+
else {
|
|
11000
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11001
|
+
const follows = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
11002
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...follows, ...response.follows.map(getResolver('follow'))])] }));
|
|
10818
11003
|
}
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
11004
|
+
}
|
|
11005
|
+
reactor(action) {
|
|
11006
|
+
return (followStatus) => {
|
|
11007
|
+
var _a;
|
|
11008
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11009
|
+
if (this.query.userId !== followStatus.to || !collection)
|
|
11010
|
+
return;
|
|
11011
|
+
switch (action) {
|
|
11012
|
+
case EnumFollowActions.OnDeclined:
|
|
11013
|
+
case EnumFollowActions.OnCanceled:
|
|
11014
|
+
case EnumFollowActions.OnUnfollowed:
|
|
11015
|
+
case EnumFollowActions.OnDeleted:
|
|
11016
|
+
collection.data = collection.data.filter(p => p !== getResolver('follow')(followStatus));
|
|
11017
|
+
break;
|
|
11018
|
+
case EnumFollowActions.OnRequested:
|
|
11019
|
+
case EnumFollowActions.OnAccepted:
|
|
11020
|
+
case EnumFollowActions.OnFollowed:
|
|
11021
|
+
collection.data = [...new Set([getResolver('follow')(followStatus), ...collection.data])];
|
|
11022
|
+
break;
|
|
10838
11023
|
}
|
|
10839
|
-
pushToCache(cacheKey,
|
|
10840
|
-
|
|
10841
|
-
}
|
|
10842
|
-
}
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
11024
|
+
pushToCache(this.cacheKey, collection);
|
|
11025
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
11026
|
+
};
|
|
11027
|
+
}
|
|
11028
|
+
subscribeRTE(createSubscriber) {
|
|
11029
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
11030
|
+
}
|
|
11031
|
+
}
|
|
11032
|
+
|
|
11033
|
+
const onFollowerUserDeleted = ({ userId }) => (callback) => {
|
|
11034
|
+
const client = getActiveClient();
|
|
11035
|
+
const filter = (data) => {
|
|
11036
|
+
const userPayload = prepareUserPayload(data);
|
|
11037
|
+
ingestInCache(userPayload);
|
|
11038
|
+
const cacheData = pullFromCache([
|
|
11039
|
+
'follow',
|
|
11040
|
+
'get',
|
|
11041
|
+
getResolver('follow')({
|
|
11042
|
+
from: userPayload.users[0].userId,
|
|
11043
|
+
to: userId,
|
|
11044
|
+
}),
|
|
11045
|
+
]);
|
|
11046
|
+
if (!cacheData)
|
|
11047
|
+
return;
|
|
11048
|
+
callback(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data);
|
|
10848
11049
|
};
|
|
10849
|
-
|
|
10850
|
-
|
|
11050
|
+
return createEventSubscriber(client, 'user.deleted', 'user.deleted', filter);
|
|
11051
|
+
};
|
|
10851
11052
|
|
|
11053
|
+
class FollowerLiveCollectionController extends LiveCollectionController {
|
|
11054
|
+
constructor(query, callback) {
|
|
11055
|
+
const queryStreamId = hash__default["default"](query);
|
|
11056
|
+
const cacheKey = ['follow', 'collection', queryStreamId];
|
|
11057
|
+
const paginationController = new FollowerPaginationController(query);
|
|
11058
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
11059
|
+
this.query = query;
|
|
11060
|
+
this.queryStreamController = new FollowerQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareFollowersPayload);
|
|
11061
|
+
this.callback = callback.bind(this);
|
|
11062
|
+
this.loadPage({ initial: true });
|
|
11063
|
+
}
|
|
11064
|
+
setup() {
|
|
11065
|
+
var _a;
|
|
11066
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11067
|
+
if (!collection) {
|
|
11068
|
+
pushToCache(this.cacheKey, {
|
|
11069
|
+
data: [],
|
|
11070
|
+
params: {},
|
|
11071
|
+
});
|
|
11072
|
+
}
|
|
11073
|
+
}
|
|
11074
|
+
async persistModel(queryPayload) {
|
|
11075
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
11076
|
+
}
|
|
11077
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
11078
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
11079
|
+
}
|
|
11080
|
+
startSubscription() {
|
|
11081
|
+
return this.queryStreamController.subscribeRTE([
|
|
11082
|
+
{ fn: onUserFollowed, action: EnumFollowActions.OnFollowed },
|
|
11083
|
+
{ fn: onUserUnfollowed, action: EnumFollowActions.OnUnfollowed },
|
|
11084
|
+
{ fn: onFollowRequestAccepted, action: EnumFollowActions.OnAccepted },
|
|
11085
|
+
{ fn: onFollowRequestDeclined, action: EnumFollowActions.OnDeclined },
|
|
11086
|
+
{ fn: onFollowRequestCanceled, action: EnumFollowActions.OnCanceled },
|
|
11087
|
+
{ fn: onFollowerDeleted, action: EnumFollowActions.OnDeleted },
|
|
11088
|
+
{ fn: onLocalFollowRequestAccepted, action: EnumFollowActions.OnAccepted },
|
|
11089
|
+
{ fn: onLocalFollowRequestDeclined, action: EnumFollowActions.OnDeclined },
|
|
11090
|
+
{ fn: onLocalUserFollowed, action: EnumFollowActions.OnFollowed },
|
|
11091
|
+
{ fn: onLocalUserUnfollowed, action: EnumFollowActions.OnUnfollowed },
|
|
11092
|
+
{
|
|
11093
|
+
fn: onFollowerUserDeleted({ userId: this.query.userId }),
|
|
11094
|
+
action: EnumFollowActions.OnUserDeleted,
|
|
11095
|
+
},
|
|
11096
|
+
]);
|
|
11097
|
+
}
|
|
11098
|
+
notifyChange({ origin, loading, error }) {
|
|
11099
|
+
var _a, _b;
|
|
11100
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11101
|
+
if (!collection)
|
|
11102
|
+
return;
|
|
11103
|
+
const data = this.applyFilter((_b = collection.data
|
|
11104
|
+
.map(id => pullFromCache(['follow', 'get', id]))
|
|
11105
|
+
.filter(isNonNullable)
|
|
11106
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
|
|
11107
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
11108
|
+
return;
|
|
11109
|
+
this.callback({
|
|
11110
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
11111
|
+
data,
|
|
11112
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
11113
|
+
loading,
|
|
11114
|
+
error,
|
|
11115
|
+
});
|
|
11116
|
+
}
|
|
11117
|
+
applyFilter(data) {
|
|
11118
|
+
let followers = data;
|
|
11119
|
+
if (this.query.status && this.query.status !== "all" /* Amity.FollowStatusTypeEnum.All */) {
|
|
11120
|
+
followers = followers.filter(follower => follower.status === this.query.status);
|
|
11121
|
+
}
|
|
11122
|
+
followers = followers.filter(follower => {
|
|
11123
|
+
var _a;
|
|
11124
|
+
const fromUser = (_a = pullFromCache(['user', 'get', follower.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
11125
|
+
return (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) == null || (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) === false;
|
|
11126
|
+
});
|
|
11127
|
+
return followers;
|
|
11128
|
+
}
|
|
11129
|
+
}
|
|
11130
|
+
|
|
11131
|
+
/* begin_public_function
|
|
11132
|
+
id: user.relationship.query_my_followers, user.relationship.query_followers
|
|
11133
|
+
*/
|
|
10852
11134
|
/**
|
|
10853
11135
|
* ```js
|
|
10854
|
-
* import {
|
|
10855
|
-
*
|
|
10856
|
-
*
|
|
10857
|
-
*
|
|
10858
|
-
*
|
|
10859
|
-
*
|
|
10860
|
-
* @param query The query parameters
|
|
10861
|
-
* @returns followings
|
|
10862
|
-
*
|
|
10863
|
-
* @category Follow API
|
|
10864
|
-
* @async
|
|
10865
|
-
*/
|
|
10866
|
-
const queryFollowings = async (query) => queryFollows('following', query);
|
|
10867
|
-
/**
|
|
10868
|
-
* ```js
|
|
10869
|
-
* import { queryFollowings } from '@amityco/ts-sdk'
|
|
10870
|
-
* const { data: followings, prevPage, nextPage } = queryFollowings.locally({ userId })
|
|
11136
|
+
* import { getFollowers } from '@amityco/ts-sdk'
|
|
11137
|
+
*
|
|
11138
|
+
* let followers = []
|
|
11139
|
+
* const unsub = getFollowers({
|
|
11140
|
+
* userId: Amity.InternalUser['userId'];
|
|
11141
|
+
* }, response => merge(followers, response.data))
|
|
10871
11142
|
* ```
|
|
10872
11143
|
*
|
|
10873
|
-
*
|
|
11144
|
+
* Observe all mutations on a list of {@link Amity.FollowStatus} followers for a given userId
|
|
10874
11145
|
*
|
|
10875
|
-
* @param
|
|
10876
|
-
* @
|
|
11146
|
+
* @param userId the user
|
|
11147
|
+
* @param callback the function to call when new data are available
|
|
11148
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
10877
11149
|
*
|
|
10878
|
-
* @category
|
|
11150
|
+
* @category Followers Live Collection
|
|
10879
11151
|
*/
|
|
10880
|
-
|
|
11152
|
+
const getFollowers = (params, callback, config) => {
|
|
11153
|
+
const { log, cache } = getActiveClient();
|
|
11154
|
+
if (!cache) {
|
|
11155
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
11156
|
+
}
|
|
11157
|
+
const timestamp = Date.now();
|
|
11158
|
+
log(`getFollowers(tmpid: ${timestamp}) > listen`);
|
|
11159
|
+
const followerLiveCollection = new FollowerLiveCollectionController(params, callback);
|
|
11160
|
+
const disposers = followerLiveCollection.startSubscription();
|
|
11161
|
+
const cacheKey = followerLiveCollection.getCacheKey();
|
|
11162
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
11163
|
+
return () => {
|
|
11164
|
+
log(`getFollowers(tmpid: ${timestamp}) > dispose`);
|
|
11165
|
+
disposers.forEach(fn => fn());
|
|
11166
|
+
};
|
|
11167
|
+
};
|
|
11168
|
+
/* end_public_function */
|
|
11169
|
+
|
|
11170
|
+
class FollowingPaginationController extends PaginationController {
|
|
11171
|
+
async getRequest(queryParams, token) {
|
|
11172
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
11173
|
+
const options = token ? { token } : { limit };
|
|
11174
|
+
const client = getActiveClient();
|
|
11175
|
+
const path = client.userId === userId ? `/api/v4/me/following` : `/api/v4/users/${userId}/following`;
|
|
11176
|
+
const { data: queryResponse } = await this.http.get(path, {
|
|
11177
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
11178
|
+
});
|
|
11179
|
+
return queryResponse;
|
|
11180
|
+
}
|
|
11181
|
+
}
|
|
11182
|
+
|
|
11183
|
+
class FollowingQueryStreamController extends QueryStreamController {
|
|
11184
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
11185
|
+
super(query, cacheKey);
|
|
11186
|
+
this.notifyChange = notifyChange;
|
|
11187
|
+
this.preparePayload = preparePayload;
|
|
11188
|
+
}
|
|
11189
|
+
async saveToMainDB(response) {
|
|
11190
|
+
const processedPayload = await this.preparePayload(response);
|
|
11191
|
+
const client = getActiveClient();
|
|
11192
|
+
const cachedAt = client.cache && Date.now();
|
|
11193
|
+
if (client.cache) {
|
|
11194
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
11195
|
+
}
|
|
11196
|
+
}
|
|
11197
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
11198
|
+
var _a, _b;
|
|
11199
|
+
if (refresh) {
|
|
11200
|
+
pushToCache(this.cacheKey, {
|
|
11201
|
+
data: response.follows.map(getResolver('follow')),
|
|
11202
|
+
});
|
|
11203
|
+
}
|
|
11204
|
+
else {
|
|
11205
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11206
|
+
const follows = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
11207
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...follows, ...response.follows.map(getResolver('follow'))])] }));
|
|
11208
|
+
}
|
|
11209
|
+
}
|
|
11210
|
+
reactor(action) {
|
|
11211
|
+
return (followStatus) => {
|
|
11212
|
+
var _a;
|
|
11213
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11214
|
+
if (this.query.userId !== followStatus.from || !collection)
|
|
11215
|
+
return;
|
|
11216
|
+
switch (action) {
|
|
11217
|
+
case EnumFollowActions.OnDeclined:
|
|
11218
|
+
case EnumFollowActions.OnCanceled:
|
|
11219
|
+
case EnumFollowActions.OnUnfollowed:
|
|
11220
|
+
case EnumFollowActions.OnDeleted:
|
|
11221
|
+
collection.data = collection.data.filter(p => p !== getResolver('follow')(followStatus));
|
|
11222
|
+
break;
|
|
11223
|
+
case EnumFollowActions.OnRequested:
|
|
11224
|
+
case EnumFollowActions.OnAccepted:
|
|
11225
|
+
case EnumFollowActions.OnFollowed:
|
|
11226
|
+
collection.data = [...new Set([getResolver('follow')(followStatus), ...collection.data])];
|
|
11227
|
+
break;
|
|
11228
|
+
}
|
|
11229
|
+
pushToCache(this.cacheKey, collection);
|
|
11230
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
11231
|
+
};
|
|
11232
|
+
}
|
|
11233
|
+
subscribeRTE(createSubscriber) {
|
|
11234
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
11235
|
+
}
|
|
11236
|
+
}
|
|
11237
|
+
|
|
11238
|
+
const onFollowingUserDeleted = ({ userId }) => (callback) => {
|
|
11239
|
+
const client = getActiveClient();
|
|
11240
|
+
const filter = (data) => {
|
|
11241
|
+
const userPayload = prepareUserPayload(data);
|
|
11242
|
+
ingestInCache(userPayload);
|
|
11243
|
+
const cacheData = pullFromCache([
|
|
11244
|
+
'follow',
|
|
11245
|
+
'get',
|
|
11246
|
+
getResolver('follow')({
|
|
11247
|
+
from: userId,
|
|
11248
|
+
to: userPayload.users[0].userId,
|
|
11249
|
+
}),
|
|
11250
|
+
]);
|
|
11251
|
+
if (!cacheData)
|
|
11252
|
+
return;
|
|
11253
|
+
callback(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data);
|
|
11254
|
+
};
|
|
11255
|
+
return createEventSubscriber(client, 'user.deleted', 'user.deleted', filter);
|
|
11256
|
+
};
|
|
11257
|
+
|
|
11258
|
+
class FollowingLiveCollectionController extends LiveCollectionController {
|
|
11259
|
+
constructor(query, callback) {
|
|
11260
|
+
const queryStreamId = hash__default["default"](query);
|
|
11261
|
+
const cacheKey = ['follow', 'collection', queryStreamId];
|
|
11262
|
+
const paginationController = new FollowingPaginationController(query);
|
|
11263
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
11264
|
+
this.query = query;
|
|
11265
|
+
this.queryStreamController = new FollowingQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareFollowingsPayload);
|
|
11266
|
+
this.callback = callback.bind(this);
|
|
11267
|
+
this.loadPage({ initial: true });
|
|
11268
|
+
}
|
|
11269
|
+
setup() {
|
|
11270
|
+
var _a;
|
|
11271
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11272
|
+
if (!collection) {
|
|
11273
|
+
pushToCache(this.cacheKey, {
|
|
11274
|
+
data: [],
|
|
11275
|
+
params: {},
|
|
11276
|
+
});
|
|
11277
|
+
}
|
|
11278
|
+
}
|
|
11279
|
+
async persistModel(queryPayload) {
|
|
11280
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
11281
|
+
}
|
|
11282
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
11283
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
11284
|
+
}
|
|
11285
|
+
startSubscription() {
|
|
11286
|
+
return this.queryStreamController.subscribeRTE([
|
|
11287
|
+
{ fn: onFollowerRequested, action: EnumFollowActions.OnRequested },
|
|
11288
|
+
{ fn: onFollowRequestAccepted, action: EnumFollowActions.OnAccepted },
|
|
11289
|
+
{ fn: onFollowRequestDeclined, action: EnumFollowActions.OnDeclined },
|
|
11290
|
+
{ fn: onFollowRequestCanceled, action: EnumFollowActions.OnCanceled },
|
|
11291
|
+
{ fn: onUserFollowed, action: EnumFollowActions.OnFollowed },
|
|
11292
|
+
{ fn: onUserUnfollowed, action: EnumFollowActions.OnUnfollowed },
|
|
11293
|
+
{ fn: onFollowerDeleted, action: EnumFollowActions.OnDeleted },
|
|
11294
|
+
{ fn: onLocalFollowerRequested, action: EnumFollowActions.OnRequested },
|
|
11295
|
+
{ fn: onLocalFollowRequestAccepted, action: EnumFollowActions.OnAccepted },
|
|
11296
|
+
{ fn: onLocalFollowRequestDeclined, action: EnumFollowActions.OnDeclined },
|
|
11297
|
+
{ fn: onLocalUserFollowed, action: EnumFollowActions.OnFollowed },
|
|
11298
|
+
{ fn: onLocalUserUnfollowed, action: EnumFollowActions.OnUnfollowed },
|
|
11299
|
+
{
|
|
11300
|
+
fn: onFollowingUserDeleted({ userId: this.query.userId }),
|
|
11301
|
+
action: EnumFollowActions.OnUserDeleted,
|
|
11302
|
+
},
|
|
11303
|
+
]);
|
|
11304
|
+
}
|
|
11305
|
+
notifyChange({ origin, loading, error }) {
|
|
11306
|
+
var _a, _b;
|
|
11307
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11308
|
+
if (!collection)
|
|
11309
|
+
return;
|
|
11310
|
+
const data = this.applyFilter((_b = collection.data
|
|
11311
|
+
.map(id => pullFromCache(['follow', 'get', id]))
|
|
11312
|
+
.filter(isNonNullable)
|
|
11313
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
|
|
11314
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
11315
|
+
return;
|
|
11316
|
+
this.callback({
|
|
11317
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
11318
|
+
data,
|
|
11319
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
11320
|
+
loading,
|
|
11321
|
+
error,
|
|
11322
|
+
});
|
|
11323
|
+
}
|
|
11324
|
+
applyFilter(data) {
|
|
11325
|
+
let followings = data;
|
|
11326
|
+
if (this.query.status && this.query.status !== "all" /* Amity.FollowStatusTypeEnum.All */) {
|
|
11327
|
+
followings = followings.filter(following => following.status === this.query.status);
|
|
11328
|
+
}
|
|
11329
|
+
followings = followings.filter(following => {
|
|
11330
|
+
var _a;
|
|
11331
|
+
const toUser = (_a = pullFromCache(['user', 'get', following.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
11332
|
+
return (toUser === null || toUser === void 0 ? void 0 : toUser.isDeleted) == null || (toUser === null || toUser === void 0 ? void 0 : toUser.isDeleted) === false;
|
|
11333
|
+
});
|
|
11334
|
+
return followings;
|
|
11335
|
+
}
|
|
11336
|
+
}
|
|
10881
11337
|
|
|
10882
11338
|
/* begin_public_function
|
|
10883
11339
|
id: user.relationship.query_my_followings, user.relationship.query_followings
|
|
@@ -10907,65 +11363,10 @@ const getFollowings = (params, callback, config) => {
|
|
|
10907
11363
|
}
|
|
10908
11364
|
const timestamp = Date.now();
|
|
10909
11365
|
log(`getFollowings(tmpid: ${timestamp}) > listen`);
|
|
10910
|
-
const
|
|
10911
|
-
const
|
|
10912
|
-
const
|
|
10913
|
-
|
|
10914
|
-
const cacheKey = ['follow', 'collection', { userId: params.userId, type: 'following' }];
|
|
10915
|
-
const responder = (data) => {
|
|
10916
|
-
var _a, _b;
|
|
10917
|
-
let followings = (_a = data.data
|
|
10918
|
-
.map(key => pullFromCache(['follow', 'get', key]))
|
|
10919
|
-
.filter(Boolean)
|
|
10920
|
-
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
10921
|
-
if (params.status && params.status !== 'all') {
|
|
10922
|
-
followings = filterByPropEquality(followings, 'status', params.status);
|
|
10923
|
-
}
|
|
10924
|
-
callback({
|
|
10925
|
-
onNextPage: onFetch,
|
|
10926
|
-
data: followings,
|
|
10927
|
-
hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
|
|
10928
|
-
loading: data.loading,
|
|
10929
|
-
error: data.error,
|
|
10930
|
-
});
|
|
10931
|
-
};
|
|
10932
|
-
const realtimeRouter = (action) => (followStatus) => {
|
|
10933
|
-
var _a;
|
|
10934
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10935
|
-
if (params.userId !== followStatus.from || !collection)
|
|
10936
|
-
return;
|
|
10937
|
-
if (['onDeclined', 'onCanceled', 'onUnfollowed', 'onDeleted'].includes(action)) {
|
|
10938
|
-
collection.data = collection.data.filter(p => p !== getResolver('follow')(followStatus));
|
|
10939
|
-
}
|
|
10940
|
-
else if (['onRequested', 'onAccepted', 'onFollowed'].includes(action)) {
|
|
10941
|
-
collection.data = [...new Set([getResolver('follow')(followStatus), ...collection.data])];
|
|
10942
|
-
}
|
|
10943
|
-
pushToCache(cacheKey, collection);
|
|
10944
|
-
responder(collection);
|
|
10945
|
-
};
|
|
10946
|
-
const onFetch = (initial = false) => {
|
|
10947
|
-
var _a, _b, _c, _d;
|
|
10948
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
10949
|
-
const followings = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
10950
|
-
if (!initial && followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
10951
|
-
return;
|
|
10952
|
-
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
10953
|
-
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
10954
|
-
const data = {
|
|
10955
|
-
loading,
|
|
10956
|
-
error,
|
|
10957
|
-
params: { page },
|
|
10958
|
-
data: followings,
|
|
10959
|
-
};
|
|
10960
|
-
if (result) {
|
|
10961
|
-
data.data = [...new Set([...followings, ...result.map(getResolver('follow'))])];
|
|
10962
|
-
}
|
|
10963
|
-
pushToCache(cacheKey, data);
|
|
10964
|
-
responder(data);
|
|
10965
|
-
}, queryOptions(policy));
|
|
10966
|
-
};
|
|
10967
|
-
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
10968
|
-
onFetch(true);
|
|
11366
|
+
const followingLiveCollection = new FollowingLiveCollectionController(params, callback);
|
|
11367
|
+
const disposers = followingLiveCollection.startSubscription();
|
|
11368
|
+
const cacheKey = followingLiveCollection.getCacheKey();
|
|
11369
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
10969
11370
|
return () => {
|
|
10970
11371
|
log(`getFollowings(tmpid: ${timestamp}) > dispose`);
|
|
10971
11372
|
disposers.forEach(fn => fn());
|
|
@@ -11053,6 +11454,11 @@ var index$k = /*#__PURE__*/Object.freeze({
|
|
|
11053
11454
|
onFollowRequestAccepted: onFollowRequestAccepted,
|
|
11054
11455
|
onFollowRequestDeclined: onFollowRequestDeclined,
|
|
11055
11456
|
onFollowInfoUpdated: onFollowInfoUpdated,
|
|
11457
|
+
onLocalUserFollowed: onLocalUserFollowed,
|
|
11458
|
+
onLocalUserUnfollowed: onLocalUserUnfollowed,
|
|
11459
|
+
onLocalFollowerRequested: onLocalFollowerRequested,
|
|
11460
|
+
onLocalFollowRequestAccepted: onLocalFollowRequestAccepted,
|
|
11461
|
+
onLocalFollowRequestDeclined: onLocalFollowRequestDeclined,
|
|
11056
11462
|
observeFollowInfo: observeFollowInfo,
|
|
11057
11463
|
observeFollowers: observeFollowers,
|
|
11058
11464
|
observeFollowings: observeFollowings,
|
|
@@ -11221,95 +11627,27 @@ const unflagUser = async (userId) => {
|
|
|
11221
11627
|
/* end_public_function */
|
|
11222
11628
|
|
|
11223
11629
|
/* begin_public_function
|
|
11224
|
-
id: user.check_flag_by_me
|
|
11225
|
-
*/
|
|
11226
|
-
/**
|
|
11227
|
-
* ```js
|
|
11228
|
-
* import { UserRepository } from '@amityco/ts-sdk'
|
|
11229
|
-
* const isFlagged = await UserRepository.isUserFlaggedByMe(postId)
|
|
11230
|
-
* ```
|
|
11231
|
-
*
|
|
11232
|
-
* @param userId The ID of the thing to check a report to.
|
|
11233
|
-
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
11234
|
-
*
|
|
11235
|
-
* @category Report API
|
|
11236
|
-
* @async
|
|
11237
|
-
* */
|
|
11238
|
-
const isUserFlaggedByMe = async (userId) => {
|
|
11239
|
-
const client = getActiveClient();
|
|
11240
|
-
client.log('user/isUserFlaggedByMe', userId);
|
|
11241
|
-
const { data: { isFlagByMe }, } = await client.http.get(`/api/v3/users/${userId}/isFlagByMe`);
|
|
11242
|
-
return isFlagByMe;
|
|
11243
|
-
};
|
|
11244
|
-
/* end_public_function */
|
|
11245
|
-
|
|
11246
|
-
/**
|
|
11247
|
-
* ```js
|
|
11248
|
-
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
11249
|
-
* const dispose = onUserUpdated(user => {
|
|
11250
|
-
* // ...
|
|
11251
|
-
* })
|
|
11252
|
-
* ```
|
|
11253
|
-
*
|
|
11254
|
-
* Fired when a {@link Amity.InternalUser} has been updated
|
|
11255
|
-
*
|
|
11256
|
-
* @param callback The function to call when the event was fired
|
|
11257
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11258
|
-
*
|
|
11259
|
-
* @category User Events
|
|
11260
|
-
*/
|
|
11261
|
-
const onUserUpdated = (callback) => createUserEventSubscriber('user.updated', callback);
|
|
11262
|
-
|
|
11263
|
-
/**
|
|
11264
|
-
* ```js
|
|
11265
|
-
* import { onUserFlagged } from '@amityco/ts-sdk'
|
|
11266
|
-
* const dispose = onUserFlagged(user => {
|
|
11267
|
-
* // ...
|
|
11268
|
-
* })
|
|
11269
|
-
* ```
|
|
11270
|
-
*
|
|
11271
|
-
* Fired when a {@link Amity.InternalUser} has been flagged
|
|
11272
|
-
*
|
|
11273
|
-
* @param callback The function to call when the event was fired
|
|
11274
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11275
|
-
*
|
|
11276
|
-
* @category User Events
|
|
11277
|
-
*/
|
|
11278
|
-
const onUserFlagged = (callback) => createUserEventSubscriber('user.flagged', callback);
|
|
11279
|
-
|
|
11280
|
-
/**
|
|
11281
|
-
* ```js
|
|
11282
|
-
* import { onUserUnflagged } from '@amityco/ts-sdk'
|
|
11283
|
-
* const dispose = onUserUnflagged(user => {
|
|
11284
|
-
* // ...
|
|
11285
|
-
* })
|
|
11286
|
-
* ```
|
|
11287
|
-
*
|
|
11288
|
-
* Fired when a flag has been removed from a {@link Amity.InternalUser}
|
|
11289
|
-
*
|
|
11290
|
-
* @param callback The function to call when the event was fired
|
|
11291
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11292
|
-
*
|
|
11293
|
-
* @category User Events
|
|
11294
|
-
*/
|
|
11295
|
-
const onUserUnflagged = (callback) => createUserEventSubscriber('user.unflagged', callback);
|
|
11296
|
-
|
|
11630
|
+
id: user.check_flag_by_me
|
|
11631
|
+
*/
|
|
11297
11632
|
/**
|
|
11298
11633
|
* ```js
|
|
11299
|
-
* import {
|
|
11300
|
-
* const
|
|
11301
|
-
* // ...
|
|
11302
|
-
* })
|
|
11634
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
11635
|
+
* const isFlagged = await UserRepository.isUserFlaggedByMe(postId)
|
|
11303
11636
|
* ```
|
|
11304
11637
|
*
|
|
11305
|
-
*
|
|
11306
|
-
*
|
|
11307
|
-
* @param callback The function to call when the event was fired
|
|
11308
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11638
|
+
* @param userId The ID of the thing to check a report to.
|
|
11639
|
+
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
11309
11640
|
*
|
|
11310
|
-
* @category
|
|
11311
|
-
|
|
11312
|
-
|
|
11641
|
+
* @category Report API
|
|
11642
|
+
* @async
|
|
11643
|
+
* */
|
|
11644
|
+
const isUserFlaggedByMe = async (userId) => {
|
|
11645
|
+
const client = getActiveClient();
|
|
11646
|
+
client.log('user/isUserFlaggedByMe', userId);
|
|
11647
|
+
const { data: { isFlagByMe }, } = await client.http.get(`/api/v3/users/${userId}/isFlagByMe`);
|
|
11648
|
+
return isFlagByMe;
|
|
11649
|
+
};
|
|
11650
|
+
/* end_public_function */
|
|
11313
11651
|
|
|
11314
11652
|
/**
|
|
11315
11653
|
* ```js
|
|
@@ -11421,7 +11759,7 @@ const getUser$1 = (userId, callback) => {
|
|
|
11421
11759
|
return liveObject(userId, reactor, 'userId', getUser$2, [
|
|
11422
11760
|
onUserFetched,
|
|
11423
11761
|
onUserUpdated,
|
|
11424
|
-
onUserDeleted,
|
|
11762
|
+
onUserDeleted$2,
|
|
11425
11763
|
onUserFlagged,
|
|
11426
11764
|
onUserUnflagged,
|
|
11427
11765
|
onUserFlagCleared,
|
|
@@ -11429,51 +11767,6 @@ const getUser$1 = (userId, callback) => {
|
|
|
11429
11767
|
};
|
|
11430
11768
|
/* end_public_function */
|
|
11431
11769
|
|
|
11432
|
-
class PaginationController {
|
|
11433
|
-
constructor(queryParams) {
|
|
11434
|
-
const { http } = getActiveClient();
|
|
11435
|
-
this.queryParams = queryParams;
|
|
11436
|
-
this.http = http;
|
|
11437
|
-
}
|
|
11438
|
-
loadFirstPage() {
|
|
11439
|
-
return this.onFetch("first" /* Amity.LiveCollectionPageDirection.FIRST */);
|
|
11440
|
-
}
|
|
11441
|
-
loadNextPage() {
|
|
11442
|
-
return this.onFetch("next" /* Amity.LiveCollectionPageDirection.NEXT */);
|
|
11443
|
-
}
|
|
11444
|
-
loadPreviousPage() {
|
|
11445
|
-
return this.onFetch("prev" /* Amity.LiveCollectionPageDirection.PREV */);
|
|
11446
|
-
}
|
|
11447
|
-
async onFetch(direction = "first" /* Amity.LiveCollectionPageDirection.FIRST */) {
|
|
11448
|
-
var _a, _b, _c, _d;
|
|
11449
|
-
if (direction === 'prev' && !this.previousToken)
|
|
11450
|
-
return;
|
|
11451
|
-
if (direction === 'next' && !this.nextToken)
|
|
11452
|
-
return;
|
|
11453
|
-
let token;
|
|
11454
|
-
if (direction === 'prev')
|
|
11455
|
-
token = this.previousToken;
|
|
11456
|
-
if (direction === 'next')
|
|
11457
|
-
token = this.nextToken;
|
|
11458
|
-
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
11459
|
-
if (direction === 'first') {
|
|
11460
|
-
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
11461
|
-
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
11462
|
-
}
|
|
11463
|
-
if (direction === 'prev')
|
|
11464
|
-
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
11465
|
-
if (direction === 'next')
|
|
11466
|
-
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
11467
|
-
return queryResponse;
|
|
11468
|
-
}
|
|
11469
|
-
getNextToken() {
|
|
11470
|
-
return this.nextToken;
|
|
11471
|
-
}
|
|
11472
|
-
getPrevToken() {
|
|
11473
|
-
return this.previousToken;
|
|
11474
|
-
}
|
|
11475
|
-
}
|
|
11476
|
-
|
|
11477
11770
|
class UserPaginationController extends PaginationController {
|
|
11478
11771
|
async getRequest(queryParams, token) {
|
|
11479
11772
|
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, displayName } = queryParams, params = __rest(queryParams, ["limit", "displayName"]);
|
|
@@ -11485,13 +11778,6 @@ class UserPaginationController extends PaginationController {
|
|
|
11485
11778
|
}
|
|
11486
11779
|
}
|
|
11487
11780
|
|
|
11488
|
-
class QueryStreamController {
|
|
11489
|
-
constructor(query, cacheKey) {
|
|
11490
|
-
this.query = query;
|
|
11491
|
-
this.cacheKey = cacheKey;
|
|
11492
|
-
}
|
|
11493
|
-
}
|
|
11494
|
-
|
|
11495
11781
|
class UserQueryStreamController extends QueryStreamController {
|
|
11496
11782
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
11497
11783
|
super(query, cacheKey);
|
|
@@ -11538,122 +11824,6 @@ class UserQueryStreamController extends QueryStreamController {
|
|
|
11538
11824
|
}
|
|
11539
11825
|
}
|
|
11540
11826
|
|
|
11541
|
-
class PaginationNoPageController {
|
|
11542
|
-
constructor(queryParams) {
|
|
11543
|
-
const { http } = getActiveClient();
|
|
11544
|
-
this.queryParams = queryParams;
|
|
11545
|
-
this.http = http;
|
|
11546
|
-
}
|
|
11547
|
-
async onFetch() {
|
|
11548
|
-
const queryResponse = await this.getRequest(this.queryParams);
|
|
11549
|
-
return queryResponse;
|
|
11550
|
-
}
|
|
11551
|
-
}
|
|
11552
|
-
|
|
11553
|
-
class LiveCollectionController {
|
|
11554
|
-
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
11555
|
-
this.paginationController = paginationController;
|
|
11556
|
-
this.queryStreamId = queryStreamId;
|
|
11557
|
-
this.cacheKey = cacheKey;
|
|
11558
|
-
this.callback = callback;
|
|
11559
|
-
}
|
|
11560
|
-
async refresh() {
|
|
11561
|
-
try {
|
|
11562
|
-
let result;
|
|
11563
|
-
if (this.paginationController instanceof PaginationNoPageController) {
|
|
11564
|
-
result = await this.paginationController.onFetch();
|
|
11565
|
-
}
|
|
11566
|
-
else {
|
|
11567
|
-
result = await this.paginationController.loadFirstPage();
|
|
11568
|
-
}
|
|
11569
|
-
if (!result)
|
|
11570
|
-
return;
|
|
11571
|
-
await this.persistModel(result);
|
|
11572
|
-
this.persistQueryStream({
|
|
11573
|
-
response: result,
|
|
11574
|
-
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
11575
|
-
refresh: true,
|
|
11576
|
-
});
|
|
11577
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
11578
|
-
}
|
|
11579
|
-
catch (e) {
|
|
11580
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
11581
|
-
}
|
|
11582
|
-
}
|
|
11583
|
-
loadPage({ initial = false, direction = "next" /* Amity.LiveCollectionPageDirection.NEXT */, }) {
|
|
11584
|
-
this.setup();
|
|
11585
|
-
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
11586
|
-
if (initial) {
|
|
11587
|
-
this.refresh();
|
|
11588
|
-
}
|
|
11589
|
-
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
11590
|
-
this.loadPrevPage();
|
|
11591
|
-
}
|
|
11592
|
-
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
11593
|
-
this.loadNextPage();
|
|
11594
|
-
}
|
|
11595
|
-
}
|
|
11596
|
-
async loadNextPage() {
|
|
11597
|
-
try {
|
|
11598
|
-
if (this.paginationController instanceof PaginationNoPageController)
|
|
11599
|
-
return;
|
|
11600
|
-
const result = await this.paginationController.loadNextPage();
|
|
11601
|
-
if (!result)
|
|
11602
|
-
return;
|
|
11603
|
-
await this.persistModel(result);
|
|
11604
|
-
this.persistQueryStream({
|
|
11605
|
-
response: result,
|
|
11606
|
-
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
11607
|
-
});
|
|
11608
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
11609
|
-
}
|
|
11610
|
-
catch (e) {
|
|
11611
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
11612
|
-
}
|
|
11613
|
-
}
|
|
11614
|
-
async loadPrevPage() {
|
|
11615
|
-
try {
|
|
11616
|
-
if (this.paginationController instanceof PaginationNoPageController)
|
|
11617
|
-
return;
|
|
11618
|
-
const result = await this.paginationController.loadPreviousPage();
|
|
11619
|
-
if (!result)
|
|
11620
|
-
return;
|
|
11621
|
-
await this.persistModel(result);
|
|
11622
|
-
this.persistQueryStream({
|
|
11623
|
-
response: result,
|
|
11624
|
-
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
11625
|
-
});
|
|
11626
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
11627
|
-
}
|
|
11628
|
-
catch (e) {
|
|
11629
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
11630
|
-
}
|
|
11631
|
-
}
|
|
11632
|
-
shouldNotify(data) {
|
|
11633
|
-
const newData = data.map(convertGetterPropsToStatic).map(removeFunctionProperties);
|
|
11634
|
-
if (isEqual(this.snapshot, newData))
|
|
11635
|
-
return false;
|
|
11636
|
-
this.snapshot = newData;
|
|
11637
|
-
return true;
|
|
11638
|
-
}
|
|
11639
|
-
getCacheKey() {
|
|
11640
|
-
return this.cacheKey;
|
|
11641
|
-
}
|
|
11642
|
-
}
|
|
11643
|
-
|
|
11644
|
-
var EnumUserActions;
|
|
11645
|
-
(function (EnumUserActions) {
|
|
11646
|
-
EnumUserActions["OnUserDeleted"] = "onUserDeleted";
|
|
11647
|
-
EnumUserActions["OnUserUpdated"] = "onUserUpdated";
|
|
11648
|
-
EnumUserActions["OnUserFlagged"] = "onUserFlagged";
|
|
11649
|
-
EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
|
|
11650
|
-
EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
|
|
11651
|
-
})(EnumUserActions || (EnumUserActions = {}));
|
|
11652
|
-
|
|
11653
|
-
function isNonNullable(value) {
|
|
11654
|
-
return value != null;
|
|
11655
|
-
}
|
|
11656
|
-
|
|
11657
11827
|
class UserLiveCollectionController extends LiveCollectionController {
|
|
11658
11828
|
constructor(query, callback) {
|
|
11659
11829
|
const queryStreamId = hash__default["default"](query);
|
|
@@ -11683,7 +11853,7 @@ class UserLiveCollectionController extends LiveCollectionController {
|
|
|
11683
11853
|
}
|
|
11684
11854
|
startSubscription() {
|
|
11685
11855
|
return this.queryStreamController.subscribeRTE([
|
|
11686
|
-
{ fn: onUserDeleted, action: EnumUserActions.OnUserDeleted },
|
|
11856
|
+
{ fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
|
|
11687
11857
|
{ fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
|
|
11688
11858
|
{ fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
|
|
11689
11859
|
{ fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
|
|
@@ -11715,11 +11885,11 @@ class UserLiveCollectionController extends LiveCollectionController {
|
|
|
11715
11885
|
if (!this.query.displayName) {
|
|
11716
11886
|
const sortFn = (() => {
|
|
11717
11887
|
switch (this.query.sortBy) {
|
|
11718
|
-
case
|
|
11888
|
+
case 'firstCreated':
|
|
11719
11889
|
return sortByFirstCreated;
|
|
11720
|
-
case
|
|
11890
|
+
case 'lastCreated':
|
|
11721
11891
|
return sortByLastCreated;
|
|
11722
|
-
case
|
|
11892
|
+
case 'displayName':
|
|
11723
11893
|
return sortByDisplayName;
|
|
11724
11894
|
default:
|
|
11725
11895
|
return sortByLastCreated;
|
|
@@ -11850,7 +12020,7 @@ const observeUser = (userId, callback) => {
|
|
|
11850
12020
|
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, newResult);
|
|
11851
12021
|
};
|
|
11852
12022
|
const disposers = [];
|
|
11853
|
-
disposers.push(onUserUpdated(data => router({ data, loading: false, origin: 'event' }, 'onUpdate')), onUserDeleted(data => router({ data, loading: false, origin: 'event' }, 'onDelete')), onUserFlagged(data => router({ data, loading: false, origin: 'event' }, 'onFlagged')), onUserUnflagged(data => router({ data, loading: false, origin: 'event' }, 'onUnflagged')), onUserFlagCleared(data => router({ data, loading: false, origin: 'event' }, 'onFlagCleared')));
|
|
12023
|
+
disposers.push(onUserUpdated(data => router({ data, loading: false, origin: 'event' }, 'onUpdate')), onUserDeleted$2(data => router({ data, loading: false, origin: 'event' }, 'onDelete')), onUserFlagged(data => router({ data, loading: false, origin: 'event' }, 'onFlagged')), onUserUnflagged(data => router({ data, loading: false, origin: 'event' }, 'onUnflagged')), onUserFlagCleared(data => router({ data, loading: false, origin: 'event' }, 'onFlagCleared')));
|
|
11854
12024
|
runQuery(createQuery(getUser, userId), result => result.data && router(result, 'onFetch'));
|
|
11855
12025
|
return () => {
|
|
11856
12026
|
log(`observeUser(tmpid: ${timestamp}) > dispose`);
|
|
@@ -11945,7 +12115,7 @@ class SearchUserLiveCollectionController extends LiveCollectionController {
|
|
|
11945
12115
|
}
|
|
11946
12116
|
startSubscription() {
|
|
11947
12117
|
return this.queryStreamController.subscribeRTE([
|
|
11948
|
-
{ fn: onUserDeleted, action: EnumUserActions.OnUserDeleted },
|
|
12118
|
+
{ fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
|
|
11949
12119
|
{ fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
|
|
11950
12120
|
{ fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
|
|
11951
12121
|
{ fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
|
|
@@ -12186,7 +12356,7 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
12186
12356
|
unflagUser: unflagUser,
|
|
12187
12357
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
12188
12358
|
onUserUpdated: onUserUpdated,
|
|
12189
|
-
onUserDeleted: onUserDeleted,
|
|
12359
|
+
onUserDeleted: onUserDeleted$2,
|
|
12190
12360
|
onUserFlagged: onUserFlagged,
|
|
12191
12361
|
onUserUnflagged: onUserUnflagged,
|
|
12192
12362
|
onUserFlagCleared: onUserFlagCleared,
|
|
@@ -13093,6 +13263,7 @@ const prepareCommentFromFlaggedEvent = (payload) => {
|
|
|
13093
13263
|
* @async
|
|
13094
13264
|
* */
|
|
13095
13265
|
const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
13266
|
+
var _a, _b;
|
|
13096
13267
|
const client = getActiveClient();
|
|
13097
13268
|
client.log('reaction/createReaction', {
|
|
13098
13269
|
referenceId,
|
|
@@ -13111,8 +13282,21 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
13111
13282
|
'get',
|
|
13112
13283
|
referenceId,
|
|
13113
13284
|
]);
|
|
13114
|
-
(model
|
|
13115
|
-
|
|
13285
|
+
if (!model)
|
|
13286
|
+
return true;
|
|
13287
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) + 1 }) });
|
|
13288
|
+
if (referenceType === 'comment') {
|
|
13289
|
+
fireEvent('local.comment.addReaction', {
|
|
13290
|
+
comment: updatedModel,
|
|
13291
|
+
});
|
|
13292
|
+
return true;
|
|
13293
|
+
}
|
|
13294
|
+
if (referenceType === 'post') {
|
|
13295
|
+
fireEvent('local.post.addReaction', {
|
|
13296
|
+
post: updatedModel,
|
|
13297
|
+
});
|
|
13298
|
+
return true;
|
|
13299
|
+
}
|
|
13116
13300
|
}
|
|
13117
13301
|
return true;
|
|
13118
13302
|
};
|
|
@@ -13177,6 +13361,7 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
13177
13361
|
* @async
|
|
13178
13362
|
* */
|
|
13179
13363
|
const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
13364
|
+
var _a, _b;
|
|
13180
13365
|
const client = getActiveClient();
|
|
13181
13366
|
client.log('reaction/removeReaction', {
|
|
13182
13367
|
referenceId,
|
|
@@ -13197,8 +13382,21 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
13197
13382
|
'get',
|
|
13198
13383
|
referenceId,
|
|
13199
13384
|
]);
|
|
13200
|
-
(model
|
|
13201
|
-
|
|
13385
|
+
if (!model)
|
|
13386
|
+
return true;
|
|
13387
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }) });
|
|
13388
|
+
if (referenceType === 'comment') {
|
|
13389
|
+
fireEvent('local.comment.removeReaction', {
|
|
13390
|
+
comment: updatedModel,
|
|
13391
|
+
});
|
|
13392
|
+
return true;
|
|
13393
|
+
}
|
|
13394
|
+
if (referenceType === 'post') {
|
|
13395
|
+
fireEvent('local.post.removeReaction', {
|
|
13396
|
+
post: updatedModel,
|
|
13397
|
+
});
|
|
13398
|
+
return true;
|
|
13399
|
+
}
|
|
13202
13400
|
}
|
|
13203
13401
|
return true;
|
|
13204
13402
|
};
|
|
@@ -13226,21 +13424,81 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
13226
13424
|
referenceType,
|
|
13227
13425
|
reactionName,
|
|
13228
13426
|
});
|
|
13229
|
-
if (!client.cache)
|
|
13230
|
-
return;
|
|
13231
|
-
const model = pullFromCache([
|
|
13232
|
-
referenceType,
|
|
13233
|
-
'get',
|
|
13234
|
-
referenceId,
|
|
13235
|
-
]);
|
|
13236
|
-
if (!(model === null || model === void 0 ? void 0 : model.data) || !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
13237
|
-
return;
|
|
13238
|
-
const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) - 1) }) });
|
|
13239
|
-
upsertInCache([referenceType, 'get', referenceId], reaction, {
|
|
13240
|
-
cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
|
|
13427
|
+
if (!client.cache)
|
|
13428
|
+
return;
|
|
13429
|
+
const model = pullFromCache([
|
|
13430
|
+
referenceType,
|
|
13431
|
+
'get',
|
|
13432
|
+
referenceId,
|
|
13433
|
+
]);
|
|
13434
|
+
if (!(model === null || model === void 0 ? void 0 : model.data) || !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
13435
|
+
return;
|
|
13436
|
+
const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) - 1) }) });
|
|
13437
|
+
upsertInCache([referenceType, 'get', referenceId], reaction, {
|
|
13438
|
+
cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
|
|
13439
|
+
});
|
|
13440
|
+
dispatchReactable(referenceType, reaction);
|
|
13441
|
+
return (_e = !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName))) !== null && _e !== void 0 ? _e : false;
|
|
13442
|
+
};
|
|
13443
|
+
|
|
13444
|
+
const getMatchPostSetting = (value) => {
|
|
13445
|
+
var _a;
|
|
13446
|
+
return (_a = Object.keys(CommunityPostSettingMaps).find(key => value.needApprovalOnPostCreation ===
|
|
13447
|
+
CommunityPostSettingMaps[key].needApprovalOnPostCreation &&
|
|
13448
|
+
value.onlyAdminCanPost === CommunityPostSettingMaps[key].onlyAdminCanPost)) !== null && _a !== void 0 ? _a : DefaultCommunityPostSetting;
|
|
13449
|
+
};
|
|
13450
|
+
function addPostSetting({ communities }) {
|
|
13451
|
+
return communities.map((_a) => {
|
|
13452
|
+
var { needApprovalOnPostCreation, onlyAdminCanPost } = _a, restCommunityPayload = __rest(_a, ["needApprovalOnPostCreation", "onlyAdminCanPost"]);
|
|
13453
|
+
return (Object.assign({ postSetting: getMatchPostSetting({
|
|
13454
|
+
needApprovalOnPostCreation,
|
|
13455
|
+
onlyAdminCanPost,
|
|
13456
|
+
}) }, restCommunityPayload));
|
|
13457
|
+
});
|
|
13458
|
+
}
|
|
13459
|
+
const prepareCommunityPayload = (rawPayload) => {
|
|
13460
|
+
const communitiesWithPostSetting = addPostSetting({ communities: rawPayload.communities });
|
|
13461
|
+
// map users with community
|
|
13462
|
+
const mappedCommunityUsers = rawPayload.communityUsers.map(communityUser => {
|
|
13463
|
+
const user = rawPayload.users.find(user => user.userId === communityUser.userId);
|
|
13464
|
+
return Object.assign(Object.assign({}, communityUser), { user });
|
|
13465
|
+
});
|
|
13466
|
+
const communityWithMembershipStatus = updateMembershipStatus(communitiesWithPostSetting, mappedCommunityUsers);
|
|
13467
|
+
return Object.assign(Object.assign({}, rawPayload), { communities: communityWithMembershipStatus, communityUsers: mappedCommunityUsers });
|
|
13468
|
+
};
|
|
13469
|
+
const prepareCommunityMembershipPayload = (rawPayload) => {
|
|
13470
|
+
const communitiesWithPostSetting = addPostSetting({ communities: rawPayload.communities });
|
|
13471
|
+
// map users with community
|
|
13472
|
+
const mappedCommunityUsers = rawPayload.communityUsers.map(communityUser => {
|
|
13473
|
+
const user = rawPayload.users.find(user => user.userId === communityUser.userId);
|
|
13474
|
+
return Object.assign(Object.assign({}, communityUser), { user });
|
|
13475
|
+
});
|
|
13476
|
+
const communityWithMembershipStatus = updateMembershipStatus(communitiesWithPostSetting, mappedCommunityUsers);
|
|
13477
|
+
return Object.assign(Object.assign({}, rawPayload), { communities: communityWithMembershipStatus, communityUsers: mappedCommunityUsers });
|
|
13478
|
+
};
|
|
13479
|
+
const prepareCommunityRequest = (params) => {
|
|
13480
|
+
const { postSetting = undefined, storySetting } = params, restParam = __rest(params, ["postSetting", "storySetting"]);
|
|
13481
|
+
return Object.assign(Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)), {
|
|
13482
|
+
// Convert story setting to the actual value. (Allow by default)
|
|
13483
|
+
allowCommentInStory: typeof (storySetting === null || storySetting === void 0 ? void 0 : storySetting.enableComment) === 'boolean' ? storySetting.enableComment : true });
|
|
13484
|
+
};
|
|
13485
|
+
|
|
13486
|
+
const preparePostPayload = (postPayload) => {
|
|
13487
|
+
// Unpack community payload by mapping payload field to postSetting value.
|
|
13488
|
+
const communitiesWithPostSetting = addPostSetting({ communities: postPayload.communities });
|
|
13489
|
+
// map users with community
|
|
13490
|
+
const mappedCommunityUsers = postPayload.communityUsers.map(communityUser => {
|
|
13491
|
+
const user = postPayload.users.find(user => user.userId === communityUser.userId);
|
|
13492
|
+
return Object.assign(Object.assign({}, communityUser), { user });
|
|
13241
13493
|
});
|
|
13242
|
-
|
|
13243
|
-
|
|
13494
|
+
const communityWithMembershipStatus = updateMembershipStatus(communitiesWithPostSetting, mappedCommunityUsers);
|
|
13495
|
+
// feed type
|
|
13496
|
+
const posts = postPayload.posts.map(post => {
|
|
13497
|
+
var _a;
|
|
13498
|
+
const feedType = (_a = postPayload.feeds.find(feed => feed.feedId === post.feedId)) === null || _a === void 0 ? void 0 : _a.feedType;
|
|
13499
|
+
return Object.assign(Object.assign({}, post), { feedType });
|
|
13500
|
+
});
|
|
13501
|
+
return Object.assign(Object.assign({}, postPayload), { posts, communities: communityWithMembershipStatus, communityUsers: mappedCommunityUsers });
|
|
13244
13502
|
};
|
|
13245
13503
|
|
|
13246
13504
|
const createPostEventSubscriber = (event, callback) => {
|
|
@@ -13251,8 +13509,8 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
13251
13509
|
callback(payload.posts[0]);
|
|
13252
13510
|
}
|
|
13253
13511
|
else {
|
|
13254
|
-
const
|
|
13255
|
-
const
|
|
13512
|
+
const data = preparePostPayload(payload);
|
|
13513
|
+
const { communities } = data;
|
|
13256
13514
|
ingestInCache(data);
|
|
13257
13515
|
if ((communities === null || communities === void 0 ? void 0 : communities[0]) && !['post.updated'].includes(event)) {
|
|
13258
13516
|
fireEvent('community.updated', {
|
|
@@ -13279,7 +13537,7 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
13279
13537
|
// But if it is hard delete, it will pushed into tombstone before fire an event to BE. it means it will stay in tombstone already
|
|
13280
13538
|
// and will got skip to notify in a previous code block
|
|
13281
13539
|
if (postedUserId !== client.userId) {
|
|
13282
|
-
|
|
13540
|
+
dropFromCache(['post', 'get', postId]);
|
|
13283
13541
|
}
|
|
13284
13542
|
return callback(payload.posts[0]);
|
|
13285
13543
|
}
|
|
@@ -13296,6 +13554,32 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
13296
13554
|
}
|
|
13297
13555
|
};
|
|
13298
13556
|
return createEventSubscriber(client, event, event, filter);
|
|
13557
|
+
};
|
|
13558
|
+
const createLocalPostEventSubscriber = (event, callback) => {
|
|
13559
|
+
const client = getActiveClient();
|
|
13560
|
+
const filter = (payload) => {
|
|
13561
|
+
if (!client.cache) {
|
|
13562
|
+
callback(payload.posts[0]);
|
|
13563
|
+
}
|
|
13564
|
+
else {
|
|
13565
|
+
const data = preparePostPayload(payload);
|
|
13566
|
+
const { communities } = data;
|
|
13567
|
+
ingestInCache(data);
|
|
13568
|
+
if ((communities === null || communities === void 0 ? void 0 : communities[0]) && !['local.post.updated'].includes(event)) {
|
|
13569
|
+
fireEvent('community.updated', {
|
|
13570
|
+
communities,
|
|
13571
|
+
categories: [],
|
|
13572
|
+
communityUsers: data.communityUsers,
|
|
13573
|
+
feeds: [],
|
|
13574
|
+
files: [],
|
|
13575
|
+
users: [],
|
|
13576
|
+
});
|
|
13577
|
+
}
|
|
13578
|
+
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
13579
|
+
callback(post.data);
|
|
13580
|
+
}
|
|
13581
|
+
};
|
|
13582
|
+
return createEventSubscriber(client, event, event, filter);
|
|
13299
13583
|
};
|
|
13300
13584
|
|
|
13301
13585
|
/**
|
|
@@ -13502,6 +13786,9 @@ const createCommentEventSubscriber = (event, callback) => {
|
|
|
13502
13786
|
comments[0].commentId,
|
|
13503
13787
|
]);
|
|
13504
13788
|
if (['comment.created'].includes(event)) {
|
|
13789
|
+
// NOTE: skip adding comment to parent comment children if it's the same user since we use the local event to update instead.
|
|
13790
|
+
if (event === 'comment.created' && comment.data.userId === client.userId)
|
|
13791
|
+
return;
|
|
13505
13792
|
if (comments[0].parentId) {
|
|
13506
13793
|
const parentComment = pullFromCache([
|
|
13507
13794
|
'comment',
|
|
@@ -13523,6 +13810,58 @@ const createCommentEventSubscriber = (event, callback) => {
|
|
|
13523
13810
|
}
|
|
13524
13811
|
};
|
|
13525
13812
|
return createEventSubscriber(client, event, event, filter);
|
|
13813
|
+
};
|
|
13814
|
+
const createLocalCommentEventSubscriber = (event, callback) => {
|
|
13815
|
+
const client = getActiveClient();
|
|
13816
|
+
const filter = (payload) => {
|
|
13817
|
+
var _a;
|
|
13818
|
+
if (!client.cache) {
|
|
13819
|
+
// TODO: here we are missing specific properties here!
|
|
13820
|
+
callback(LinkedObject.comment(payload.comments[0]));
|
|
13821
|
+
}
|
|
13822
|
+
else {
|
|
13823
|
+
const processed = payload;
|
|
13824
|
+
ingestInCache(processed);
|
|
13825
|
+
const { comments } = processed;
|
|
13826
|
+
if (comments.length > 0) {
|
|
13827
|
+
const comment = pullFromCache([
|
|
13828
|
+
'comment',
|
|
13829
|
+
'get',
|
|
13830
|
+
comments[0].commentId,
|
|
13831
|
+
]);
|
|
13832
|
+
if (['local.comment.created'].includes(event)) {
|
|
13833
|
+
if (comments[0].parentId) {
|
|
13834
|
+
const parentComment = pullFromCache([
|
|
13835
|
+
'comment',
|
|
13836
|
+
'get',
|
|
13837
|
+
comments[0].parentId,
|
|
13838
|
+
]);
|
|
13839
|
+
if (parentComment === null || parentComment === void 0 ? void 0 : parentComment.data) {
|
|
13840
|
+
// Skip to update parent childComment if current comment already exists
|
|
13841
|
+
if (!parentComment.data.children.includes(comments[0].commentId)) {
|
|
13842
|
+
const newParentComment = Object.assign(Object.assign({}, parentComment.data), { childrenNumber: parentComment.data.childrenNumber + 1, children: [...new Set([...parentComment.data.children, comments[0].commentId])] });
|
|
13843
|
+
pushToCache(['comment', 'get', comments[0].parentId], newParentComment);
|
|
13844
|
+
setTimeout(() => {
|
|
13845
|
+
// NOTE: This is workaround solution for emitting event not work properly.
|
|
13846
|
+
fireEvent('comment.updated', {
|
|
13847
|
+
comments: [newParentComment],
|
|
13848
|
+
commentChildren: [],
|
|
13849
|
+
files: [],
|
|
13850
|
+
users: [],
|
|
13851
|
+
communityUsers: [],
|
|
13852
|
+
});
|
|
13853
|
+
}, 200);
|
|
13854
|
+
}
|
|
13855
|
+
}
|
|
13856
|
+
}
|
|
13857
|
+
const queries = (_a = queryCache(['comment', 'query'])) === null || _a === void 0 ? void 0 : _a.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
|
|
13858
|
+
queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
|
|
13859
|
+
}
|
|
13860
|
+
callback(LinkedObject.comment(comment.data));
|
|
13861
|
+
}
|
|
13862
|
+
}
|
|
13863
|
+
};
|
|
13864
|
+
return createEventSubscriber(client, event, event, filter);
|
|
13526
13865
|
};
|
|
13527
13866
|
|
|
13528
13867
|
/**
|
|
@@ -14082,51 +14421,6 @@ var index$h = /*#__PURE__*/Object.freeze({
|
|
|
14082
14421
|
getReactions: getReactions
|
|
14083
14422
|
});
|
|
14084
14423
|
|
|
14085
|
-
const getMatchPostSetting = (value) => {
|
|
14086
|
-
var _a;
|
|
14087
|
-
return (_a = Object.keys(CommunityPostSettingMaps).find(key => value.needApprovalOnPostCreation ===
|
|
14088
|
-
CommunityPostSettingMaps[key].needApprovalOnPostCreation &&
|
|
14089
|
-
value.onlyAdminCanPost === CommunityPostSettingMaps[key].onlyAdminCanPost)) !== null && _a !== void 0 ? _a : DefaultCommunityPostSetting;
|
|
14090
|
-
};
|
|
14091
|
-
function addPostSetting({ communities }) {
|
|
14092
|
-
return communities.map((_a) => {
|
|
14093
|
-
var { needApprovalOnPostCreation, onlyAdminCanPost } = _a, restCommunityPayload = __rest(_a, ["needApprovalOnPostCreation", "onlyAdminCanPost"]);
|
|
14094
|
-
return (Object.assign({ postSetting: getMatchPostSetting({
|
|
14095
|
-
needApprovalOnPostCreation,
|
|
14096
|
-
onlyAdminCanPost,
|
|
14097
|
-
}) }, restCommunityPayload));
|
|
14098
|
-
});
|
|
14099
|
-
}
|
|
14100
|
-
const prepareCommunityPayload = (rawPayload) => {
|
|
14101
|
-
const communitiesWithPostSetting = addPostSetting({ communities: rawPayload.communities });
|
|
14102
|
-
// map users with community
|
|
14103
|
-
const mappedCommunityUsers = rawPayload.communityUsers.map(communityUser => {
|
|
14104
|
-
const user = rawPayload.users.find(user => user.userId === communityUser.userId);
|
|
14105
|
-
return Object.assign(Object.assign({}, communityUser), { user });
|
|
14106
|
-
});
|
|
14107
|
-
const communityWithMembershipStatus = updateMembershipStatus(communitiesWithPostSetting, mappedCommunityUsers);
|
|
14108
|
-
return Object.assign(Object.assign({}, rawPayload), { communities: communityWithMembershipStatus, communityUsers: mappedCommunityUsers });
|
|
14109
|
-
};
|
|
14110
|
-
const prepareCommunityRequest = (params) => {
|
|
14111
|
-
const { postSetting = undefined, storySetting } = params, restParam = __rest(params, ["postSetting", "storySetting"]);
|
|
14112
|
-
return Object.assign(Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)), {
|
|
14113
|
-
// Convert story setting to the actual value. (Allow by default)
|
|
14114
|
-
allowCommentInStory: typeof (storySetting === null || storySetting === void 0 ? void 0 : storySetting.enableComment) === 'boolean' ? storySetting.enableComment : true });
|
|
14115
|
-
};
|
|
14116
|
-
|
|
14117
|
-
const preparePostPayload = (postPayload) => {
|
|
14118
|
-
const { posts } = postPayload;
|
|
14119
|
-
// Unpack community payload by mapping payload field to postSetting value.
|
|
14120
|
-
const communitiesWithPostSetting = addPostSetting({ communities: postPayload.communities });
|
|
14121
|
-
// map users with community
|
|
14122
|
-
const mappedCommunityUsers = postPayload.communityUsers.map(communityUser => {
|
|
14123
|
-
const user = postPayload.users.find(user => user.userId === communityUser.userId);
|
|
14124
|
-
return Object.assign(Object.assign({}, communityUser), { user });
|
|
14125
|
-
});
|
|
14126
|
-
const communityWithMembershipStatus = updateMembershipStatus(communitiesWithPostSetting, mappedCommunityUsers);
|
|
14127
|
-
return Object.assign(Object.assign({}, postPayload), { posts, communities: communityWithMembershipStatus, communityUsers: mappedCommunityUsers });
|
|
14128
|
-
};
|
|
14129
|
-
|
|
14130
14424
|
function prepareCommentPayload(commentPayload) {
|
|
14131
14425
|
const { comments } = commentPayload;
|
|
14132
14426
|
return Object.assign(Object.assign({}, commentPayload), { comments: comments.map(comment => {
|
|
@@ -17718,10 +18012,12 @@ const removeMembers$1 = async (channelId, userIds) => {
|
|
|
17718
18012
|
*/
|
|
17719
18013
|
class ChannelMemberPaginationController extends PaginationController {
|
|
17720
18014
|
async getRequest(queryParams, token) {
|
|
17721
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
18015
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
17722
18016
|
const options = token ? { token } : { limit };
|
|
18017
|
+
const isDeleted = includeDeleted === false ? false : undefined;
|
|
17723
18018
|
const { data: queryResponse } = await this.http.get(`/api/v4/channels/${encodeURIComponent(params.channelId)}/users`, {
|
|
17724
|
-
params: Object.assign(Object.assign({}, params), { options
|
|
18019
|
+
params: Object.assign(Object.assign({}, params), { options,
|
|
18020
|
+
isDeleted }),
|
|
17725
18021
|
});
|
|
17726
18022
|
return queryResponse;
|
|
17727
18023
|
}
|
|
@@ -17787,6 +18083,33 @@ class ChannelMemberQueryStreamController extends QueryStreamController {
|
|
|
17787
18083
|
}
|
|
17788
18084
|
}
|
|
17789
18085
|
|
|
18086
|
+
const onUserDeleted$1 = (channelId) => (callback) => {
|
|
18087
|
+
const client = getActiveClient();
|
|
18088
|
+
const filter = (payload) => {
|
|
18089
|
+
var _a, _b;
|
|
18090
|
+
const userPayload = prepareUserPayload(payload);
|
|
18091
|
+
if (userPayload.users.length === 0)
|
|
18092
|
+
return;
|
|
18093
|
+
const user = userPayload.users[0];
|
|
18094
|
+
ingestInCache(userPayload);
|
|
18095
|
+
const channelUserCacheKey = getResolver('channelUsers')({
|
|
18096
|
+
channelId,
|
|
18097
|
+
userId: user.userId,
|
|
18098
|
+
});
|
|
18099
|
+
const cacheData = (_a = pullFromCache([
|
|
18100
|
+
'channelUsers',
|
|
18101
|
+
'get',
|
|
18102
|
+
channelUserCacheKey,
|
|
18103
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
18104
|
+
upsertInCache(['channelUsers', 'get', channelUserCacheKey], Object.assign(Object.assign({}, cacheData), { user }));
|
|
18105
|
+
const channel = (_b = pullFromCache(['channel', 'get', channelId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
18106
|
+
if (!channel)
|
|
18107
|
+
return;
|
|
18108
|
+
callback(channel, cacheData);
|
|
18109
|
+
};
|
|
18110
|
+
return createEventSubscriber(client, 'user.deleted', 'user.deleted', filter);
|
|
18111
|
+
};
|
|
18112
|
+
|
|
17790
18113
|
/* eslint-disable no-use-before-define */
|
|
17791
18114
|
class ChannelMemberLiveCollectionController extends LiveCollectionController {
|
|
17792
18115
|
constructor(query, callback) {
|
|
@@ -17825,6 +18148,7 @@ class ChannelMemberLiveCollectionController extends LiveCollectionController {
|
|
|
17825
18148
|
{ fn: onChannelMemberUnbanned, action: 'onChannelMemberUnbanned' },
|
|
17826
18149
|
{ fn: onChannelMemberRoleAdded, action: 'onChannelMemberRoleAdded' },
|
|
17827
18150
|
{ fn: onChannelMemberRoleRemoved, action: 'onChannelMemberRoleRemoved' },
|
|
18151
|
+
{ fn: onUserDeleted$1(this.query.channelId), action: 'onChannelMemberChanged' },
|
|
17828
18152
|
]);
|
|
17829
18153
|
}
|
|
17830
18154
|
notifyChange({ origin, loading, error }) {
|
|
@@ -17871,8 +18195,8 @@ class ChannelMemberLiveCollectionController extends LiveCollectionController {
|
|
|
17871
18195
|
console.warn('`search` param will be deprecated in the next major release. If you want to search channel members by displayName, Please use `searchMembers()` instead.');
|
|
17872
18196
|
channelMembers = filterBySearchTerm(channelMembers, this.query.search);
|
|
17873
18197
|
}
|
|
17874
|
-
if (
|
|
17875
|
-
channelMembers = channelMembers.filter(member => { var _a; return ((_a = member.user) === null || _a === void 0 ? void 0 : _a.isDeleted)
|
|
18198
|
+
if (this.query.includeDeleted === false) {
|
|
18199
|
+
channelMembers = channelMembers.filter(member => { var _a; return ((_a = member.user) === null || _a === void 0 ? void 0 : _a.isDeleted) !== true; });
|
|
17876
18200
|
}
|
|
17877
18201
|
// sort, 'lastCreated' is the default sort order
|
|
17878
18202
|
const sortBy = this.query.sortBy ? this.query.sortBy : 'lastCreated';
|
|
@@ -18690,7 +19014,7 @@ function getEventRelatedMember(event, payload) {
|
|
|
18690
19014
|
}
|
|
18691
19015
|
// NOTE: backend returns the one who took the action and the one on whom
|
|
18692
19016
|
// the action was taken. We need the 2nd one
|
|
18693
|
-
if (event === 'community.userRemoved') {
|
|
19017
|
+
if (event === 'community.userRemoved' || event === 'local.community.userRemoved') {
|
|
18694
19018
|
return payload.communityUsers.filter(x => x.communityMembership === 'none');
|
|
18695
19019
|
}
|
|
18696
19020
|
if (event === 'community.userBanned') {
|
|
@@ -18738,6 +19062,43 @@ const createCommunityMemberEventSubscriber = (event, callback) => {
|
|
|
18738
19062
|
}
|
|
18739
19063
|
};
|
|
18740
19064
|
return createEventSubscriber(client, event, event, filter);
|
|
19065
|
+
};
|
|
19066
|
+
const createLocalCommunityMemberEventSubscriber = (event, callback) => {
|
|
19067
|
+
const client = getActiveClient();
|
|
19068
|
+
const filter = (payload) => {
|
|
19069
|
+
const preparedPayload = prepareCommunityPayload(payload);
|
|
19070
|
+
const { communities, communityUsers } = preparedPayload;
|
|
19071
|
+
/*
|
|
19072
|
+
* community.isJoined is not part of the communityMembership payload, and needs
|
|
19073
|
+
* to be calculated based on the communityMembership value
|
|
19074
|
+
*/
|
|
19075
|
+
const communitiesWithMembership = updateMembershipStatus(communities, communityUsers);
|
|
19076
|
+
preparedPayload.communities = communitiesWithMembership;
|
|
19077
|
+
if (!client.cache) {
|
|
19078
|
+
// TODO: here we are missing specific properties here!
|
|
19079
|
+
callback(preparedPayload.communities[0], getEventRelatedMember(event, preparedPayload));
|
|
19080
|
+
}
|
|
19081
|
+
else {
|
|
19082
|
+
ingestInCache(preparedPayload);
|
|
19083
|
+
const community = pullFromCache([
|
|
19084
|
+
'community',
|
|
19085
|
+
'get',
|
|
19086
|
+
preparedPayload.communities[0].communityId,
|
|
19087
|
+
]);
|
|
19088
|
+
const members = getEventRelatedMember(event, preparedPayload)
|
|
19089
|
+
.map(member => {
|
|
19090
|
+
const memberCache = pullFromCache([
|
|
19091
|
+
'communityUsers',
|
|
19092
|
+
'get',
|
|
19093
|
+
getResolver('communityUsers')(member),
|
|
19094
|
+
]);
|
|
19095
|
+
return memberCache === null || memberCache === void 0 ? void 0 : memberCache.data;
|
|
19096
|
+
})
|
|
19097
|
+
.filter(isNonNullable);
|
|
19098
|
+
callback(community.data, members);
|
|
19099
|
+
}
|
|
19100
|
+
};
|
|
19101
|
+
return createEventSubscriber(client, event, event, filter);
|
|
18741
19102
|
};
|
|
18742
19103
|
|
|
18743
19104
|
/**
|
|
@@ -18859,6 +19220,40 @@ const onCommunityUserRoleAdded = (callback) => createCommunityMemberEventSubscri
|
|
|
18859
19220
|
*/
|
|
18860
19221
|
const onCommunityUserRoleRemoved = (callback) => createCommunityMemberEventSubscriber('community.roleRemoved', callback);
|
|
18861
19222
|
|
|
19223
|
+
/**
|
|
19224
|
+
* ```js
|
|
19225
|
+
* import { onLocalCommunityUserAdded } from '@amityco/ts-sdk'
|
|
19226
|
+
* const dispose = onLocalCommunityUserAdded((community, member) => {
|
|
19227
|
+
* // ...
|
|
19228
|
+
* })
|
|
19229
|
+
* ```
|
|
19230
|
+
*
|
|
19231
|
+
* Fired when a user has been added to a {@link Amity.Community}
|
|
19232
|
+
*
|
|
19233
|
+
* @param callback The function to call when the event was fired
|
|
19234
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19235
|
+
*
|
|
19236
|
+
* @category Community Events
|
|
19237
|
+
*/
|
|
19238
|
+
const onLocalCommunityUserAdded = (callback) => createLocalCommunityMemberEventSubscriber('local.community.userAdded', callback);
|
|
19239
|
+
|
|
19240
|
+
/**
|
|
19241
|
+
* ```js
|
|
19242
|
+
* import { onLocalCommunityUserRemoved } from '@amityco/ts-sdk'
|
|
19243
|
+
* const dispose = onLocalCommunityUserRemoved((community, member) => {
|
|
19244
|
+
* // ...
|
|
19245
|
+
* })
|
|
19246
|
+
* ```
|
|
19247
|
+
*
|
|
19248
|
+
* Fired when a user has been removed from a {@link Amity.Community}
|
|
19249
|
+
*
|
|
19250
|
+
* @param callback The function to call when the event was fired
|
|
19251
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19252
|
+
*
|
|
19253
|
+
* @category Community Events
|
|
19254
|
+
*/
|
|
19255
|
+
const onLocalCommunityUserRemoved = (callback) => createLocalCommunityMemberEventSubscriber('local.community.userRemoved', callback);
|
|
19256
|
+
|
|
18862
19257
|
/**
|
|
18863
19258
|
* ```js
|
|
18864
19259
|
* import { onCommunityJoined } from '@amityco/ts-sdk'
|
|
@@ -19011,6 +19406,9 @@ var EnumCommunityMemberActions$1;
|
|
|
19011
19406
|
EnumCommunityMemberActions["OnCommunityUserRoleRemoved"] = "onCommunityUserRoleRemoved";
|
|
19012
19407
|
EnumCommunityMemberActions["OnCommunityUserUnbanned"] = "onCommunityUserUnbanned";
|
|
19013
19408
|
EnumCommunityMemberActions["OnMemberCountChanged"] = "OnMemberCountChanged";
|
|
19409
|
+
EnumCommunityMemberActions["OnCommunityUserAdded"] = "OnCommunityUserAdded";
|
|
19410
|
+
EnumCommunityMemberActions["onCommunityUserRemoved"] = "onCommunityUserRemoved";
|
|
19411
|
+
EnumCommunityMemberActions["OnUserDeleted"] = "OnUserDeleted";
|
|
19014
19412
|
})(EnumCommunityMemberActions$1 || (EnumCommunityMemberActions$1 = {}));
|
|
19015
19413
|
|
|
19016
19414
|
/* begin_public_function
|
|
@@ -19035,7 +19433,7 @@ const addMembers = async (communityId, userIds) => {
|
|
|
19035
19433
|
const client = getActiveClient();
|
|
19036
19434
|
client.log('community/moderation/addMembers', communityId, userIds);
|
|
19037
19435
|
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
19038
|
-
fireEvent('community.userAdded', payload);
|
|
19436
|
+
fireEvent('local.community.userAdded', payload);
|
|
19039
19437
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
19040
19438
|
if (client.cache)
|
|
19041
19439
|
ingestInCache(data);
|
|
@@ -19066,7 +19464,7 @@ const removeMembers = async (communityId, userIds) => {
|
|
|
19066
19464
|
const client = getActiveClient();
|
|
19067
19465
|
client.log('community/moderation/removeMembers', communityId, userIds);
|
|
19068
19466
|
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
19069
|
-
fireEvent('community.userRemoved', payload);
|
|
19467
|
+
fireEvent('local.community.userRemoved', payload);
|
|
19070
19468
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
19071
19469
|
if (client.cache)
|
|
19072
19470
|
ingestInCache(data);
|
|
@@ -19081,10 +19479,12 @@ const removeMembers = async (communityId, userIds) => {
|
|
|
19081
19479
|
*/
|
|
19082
19480
|
class CommunityMembersPaginationController extends PaginationController {
|
|
19083
19481
|
async getRequest(queryParams, token) {
|
|
19084
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
19482
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
19085
19483
|
const options = token ? { token } : { limit };
|
|
19484
|
+
const isDeleted = includeDeleted === false ? false : undefined;
|
|
19086
19485
|
const { data: queryResponse } = await this.http.get(`/api/v3/communities/${params.communityId}/users`, {
|
|
19087
|
-
params: Object.assign(Object.assign({}, params), { options
|
|
19486
|
+
params: Object.assign(Object.assign({}, params), { options,
|
|
19487
|
+
isDeleted }),
|
|
19088
19488
|
});
|
|
19089
19489
|
return queryResponse;
|
|
19090
19490
|
}
|
|
@@ -19153,6 +19553,96 @@ class CommunityMembersQueryStreamController extends QueryStreamController {
|
|
|
19153
19553
|
}
|
|
19154
19554
|
}
|
|
19155
19555
|
|
|
19556
|
+
/**
|
|
19557
|
+
* ```js
|
|
19558
|
+
* import { onLocalCommunityRoleRemoved } from '@amityco/ts-sdk'
|
|
19559
|
+
* const dispose = onLocalCommunityRoleRemoved((community, member) => {
|
|
19560
|
+
* // ...
|
|
19561
|
+
* })
|
|
19562
|
+
* ```
|
|
19563
|
+
*
|
|
19564
|
+
* Fired when any {@link Amity.communityUsers} 's role has been added to any {@link Amity.Community}
|
|
19565
|
+
*
|
|
19566
|
+
* @param callback The function to call when the event was fired
|
|
19567
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19568
|
+
*
|
|
19569
|
+
* @category Community Events
|
|
19570
|
+
*/
|
|
19571
|
+
const onLocalCommunityRoleRemoved = (callback) => {
|
|
19572
|
+
const client = getActiveClient();
|
|
19573
|
+
const filter = async (payload) => {
|
|
19574
|
+
const { communities, communityUsers } = payload;
|
|
19575
|
+
callback(communities[0], communityUsers.filter(communityUser => communityUser.communityMembership === 'member'));
|
|
19576
|
+
};
|
|
19577
|
+
return createEventSubscriber(client, 'onLocalCommunityRoleRemoved', 'local.community.roleRemoved', filter);
|
|
19578
|
+
};
|
|
19579
|
+
|
|
19580
|
+
/**
|
|
19581
|
+
* ```js
|
|
19582
|
+
* import { onLocalCommunityRoleAdded } from '@amityco/ts-sdk'
|
|
19583
|
+
* const dispose = onLocalCommunityRoleAdded((community, member) => {
|
|
19584
|
+
* // ...
|
|
19585
|
+
* })
|
|
19586
|
+
* ```
|
|
19587
|
+
*
|
|
19588
|
+
* Fired when any {@link Amity.communityUsers} 's role has been added to any {@link Amity.Community}
|
|
19589
|
+
*
|
|
19590
|
+
* @param callback The function to call when the event was fired
|
|
19591
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19592
|
+
*
|
|
19593
|
+
* @category Community Events
|
|
19594
|
+
*/
|
|
19595
|
+
const onLocalCommunityRoleAdded = (callback) => {
|
|
19596
|
+
const client = getActiveClient();
|
|
19597
|
+
const filter = async (payload) => {
|
|
19598
|
+
const { communities, communityUsers } = payload;
|
|
19599
|
+
callback(communities[0], communityUsers.filter(communityUser => communityUser.communityMembership === 'member'));
|
|
19600
|
+
};
|
|
19601
|
+
return createEventSubscriber(client, 'onLocalCommunityRoleAdded', 'local.community.roleAdded', filter);
|
|
19602
|
+
};
|
|
19603
|
+
|
|
19604
|
+
/**
|
|
19605
|
+
* ```js
|
|
19606
|
+
* import { onUserDeleted } from '@amityco/ts-sdk'
|
|
19607
|
+
* const dispose = onUserDeleted((community, member) => {
|
|
19608
|
+
* // ...
|
|
19609
|
+
* })
|
|
19610
|
+
* ```
|
|
19611
|
+
*
|
|
19612
|
+
* Fired when a {@link Amity.Community} has been joined
|
|
19613
|
+
*
|
|
19614
|
+
* @param callback The function to call when the event was fired
|
|
19615
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19616
|
+
*
|
|
19617
|
+
* @category Community Events
|
|
19618
|
+
*/
|
|
19619
|
+
const onUserDeleted = (communityId) => (callback) => {
|
|
19620
|
+
const client = getActiveClient();
|
|
19621
|
+
const filter = (payload) => {
|
|
19622
|
+
var _a, _b;
|
|
19623
|
+
const userPayload = prepareUserPayload(payload);
|
|
19624
|
+
if (userPayload.users.length === 0)
|
|
19625
|
+
return;
|
|
19626
|
+
const user = userPayload.users[0];
|
|
19627
|
+
ingestInCache(userPayload);
|
|
19628
|
+
const communityUserCacheKey = getResolver('communityUsers')({
|
|
19629
|
+
communityId,
|
|
19630
|
+
userId: user.userId,
|
|
19631
|
+
});
|
|
19632
|
+
const cacheData = (_a = pullFromCache([
|
|
19633
|
+
'communityUsers',
|
|
19634
|
+
'get',
|
|
19635
|
+
communityUserCacheKey,
|
|
19636
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
19637
|
+
pushToCache(['communityUsers', 'get', communityUserCacheKey], Object.assign(Object.assign({}, cacheData), { user }));
|
|
19638
|
+
const community = (_b = pullFromCache(['community', 'get', communityId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
19639
|
+
callback(community, [
|
|
19640
|
+
Object.assign(Object.assign({}, cacheData), { user }),
|
|
19641
|
+
]);
|
|
19642
|
+
};
|
|
19643
|
+
return createEventSubscriber(client, 'user.deleted', 'user.deleted', filter);
|
|
19644
|
+
};
|
|
19645
|
+
|
|
19156
19646
|
class CommunityMembersLiveCollectionController extends LiveCollectionController {
|
|
19157
19647
|
constructor(query, callback) {
|
|
19158
19648
|
const queryStreamId = hash__default["default"](query);
|
|
@@ -19191,7 +19681,24 @@ class CommunityMembersLiveCollectionController extends LiveCollectionController
|
|
|
19191
19681
|
fn: onCommunityUserRoleRemoved,
|
|
19192
19682
|
action: EnumCommunityMemberActions$1.OnCommunityUserRoleRemoved,
|
|
19193
19683
|
},
|
|
19684
|
+
{
|
|
19685
|
+
fn: onLocalCommunityRoleAdded,
|
|
19686
|
+
action: EnumCommunityMemberActions$1.OnCommunityUserRoleAdded,
|
|
19687
|
+
},
|
|
19688
|
+
{
|
|
19689
|
+
fn: onLocalCommunityRoleRemoved,
|
|
19690
|
+
action: EnumCommunityMemberActions$1.OnCommunityUserRoleRemoved,
|
|
19691
|
+
},
|
|
19194
19692
|
{ fn: onCommunityUserUnbanned, action: EnumCommunityMemberActions$1.OnCommunityUserUnbanned },
|
|
19693
|
+
{ fn: onLocalCommunityUserAdded, action: EnumCommunityMemberActions$1.OnCommunityUserAdded },
|
|
19694
|
+
{
|
|
19695
|
+
fn: onLocalCommunityUserRemoved,
|
|
19696
|
+
action: EnumCommunityMemberActions$1.onCommunityUserRemoved,
|
|
19697
|
+
},
|
|
19698
|
+
{
|
|
19699
|
+
fn: onUserDeleted(this.query.communityId),
|
|
19700
|
+
action: EnumCommunityMemberActions$1.OnCommunityUserChanged,
|
|
19701
|
+
},
|
|
19195
19702
|
]);
|
|
19196
19703
|
}
|
|
19197
19704
|
notifyChange({ origin, loading, error }) {
|
|
@@ -19224,8 +19731,8 @@ class CommunityMembersLiveCollectionController extends LiveCollectionController
|
|
|
19224
19731
|
if (this.query.search) {
|
|
19225
19732
|
communityMembers = filterBySearchTerm(communityMembers, this.query.search);
|
|
19226
19733
|
}
|
|
19227
|
-
if (
|
|
19228
|
-
communityMembers = communityMembers.filter(({ user }) => (user === null || user === void 0 ? void 0 : user.isDeleted)
|
|
19734
|
+
if (this.query.includeDeleted === false) {
|
|
19735
|
+
communityMembers = communityMembers.filter(({ user }) => (user === null || user === void 0 ? void 0 : user.isDeleted) !== true);
|
|
19229
19736
|
}
|
|
19230
19737
|
switch (this.query.sortBy) {
|
|
19231
19738
|
case 'firstCreated':
|
|
@@ -19317,10 +19824,12 @@ const getMembers = (params, callback, config) => {
|
|
|
19317
19824
|
*/
|
|
19318
19825
|
class SearchCommunityMembersPaginationController extends PaginationController {
|
|
19319
19826
|
async getRequest(queryParams, token) {
|
|
19320
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
19827
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
19321
19828
|
const options = token ? { token } : { limit };
|
|
19829
|
+
const isDeleted = includeDeleted === false ? false : undefined;
|
|
19322
19830
|
const { data: queryResponse } = await this.http.get(`/api/v3/communities/${params.communityId}/users`, {
|
|
19323
|
-
params: Object.assign(Object.assign({}, params), { options
|
|
19831
|
+
params: Object.assign(Object.assign({}, params), { options,
|
|
19832
|
+
isDeleted }),
|
|
19324
19833
|
});
|
|
19325
19834
|
return queryResponse;
|
|
19326
19835
|
}
|
|
@@ -19427,11 +19936,19 @@ class SearchCommunityMembersLiveCollectionController extends LiveCollectionContr
|
|
|
19427
19936
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
|
|
19428
19937
|
{ fn: onCommunityUserBanned, action: EnumCommunityMemberActions.OnCommunityUserBanned },
|
|
19429
19938
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions.OnCommunityUserChanged },
|
|
19939
|
+
{
|
|
19940
|
+
fn: onLocalCommunityRoleRemoved,
|
|
19941
|
+
action: EnumCommunityMemberActions.OnCommunityUserRoleRemoved,
|
|
19942
|
+
},
|
|
19430
19943
|
{
|
|
19431
19944
|
fn: onCommunityUserRoleRemoved,
|
|
19432
19945
|
action: EnumCommunityMemberActions.OnCommunityUserRoleRemoved,
|
|
19433
19946
|
},
|
|
19434
19947
|
{ fn: onCommunityUserUnbanned, action: EnumCommunityMemberActions.OnCommunityUserUnbanned },
|
|
19948
|
+
{
|
|
19949
|
+
fn: onUserDeleted(this.query.communityId),
|
|
19950
|
+
action: EnumCommunityMemberActions.OnCommunityUserChanged,
|
|
19951
|
+
},
|
|
19435
19952
|
]);
|
|
19436
19953
|
}
|
|
19437
19954
|
notifyChange({ origin, loading, error }) {
|
|
@@ -19464,8 +19981,8 @@ class SearchCommunityMembersLiveCollectionController extends LiveCollectionContr
|
|
|
19464
19981
|
if (this.query.search) {
|
|
19465
19982
|
communityMembers = filterBySearchTerm(communityMembers, this.query.search);
|
|
19466
19983
|
}
|
|
19467
|
-
if (
|
|
19468
|
-
communityMembers = communityMembers.filter(({ user }) => (user === null || user === void 0 ? void 0 : user.isDeleted)
|
|
19984
|
+
if (this.query.includeDeleted === false) {
|
|
19985
|
+
communityMembers = communityMembers.filter(({ user }) => (user === null || user === void 0 ? void 0 : user.isDeleted) !== true);
|
|
19469
19986
|
}
|
|
19470
19987
|
return communityMembers;
|
|
19471
19988
|
}
|
|
@@ -19528,6 +20045,8 @@ var index$b = /*#__PURE__*/Object.freeze({
|
|
|
19528
20045
|
onCommunityUserUnbanned: onCommunityUserUnbanned,
|
|
19529
20046
|
onCommunityUserRoleAdded: onCommunityUserRoleAdded,
|
|
19530
20047
|
onCommunityUserRoleRemoved: onCommunityUserRoleRemoved,
|
|
20048
|
+
onLocalCommunityUserAdded: onLocalCommunityUserAdded,
|
|
20049
|
+
onLocalCommunityUserRemoved: onLocalCommunityUserRemoved,
|
|
19531
20050
|
onCommunityJoined: onCommunityJoined,
|
|
19532
20051
|
onCommunityLeft: onCommunityLeft
|
|
19533
20052
|
});
|
|
@@ -19791,11 +20310,11 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
19791
20310
|
if (!this.query.displayName) {
|
|
19792
20311
|
const sortFn = (() => {
|
|
19793
20312
|
switch (this.query.sortBy) {
|
|
19794
|
-
case
|
|
20313
|
+
case 'firstCreated':
|
|
19795
20314
|
return sortByFirstCreated;
|
|
19796
|
-
case
|
|
20315
|
+
case 'lastCreated':
|
|
19797
20316
|
return sortByLastCreated;
|
|
19798
|
-
case
|
|
20317
|
+
case 'displayName':
|
|
19799
20318
|
return sortByDisplayName;
|
|
19800
20319
|
default:
|
|
19801
20320
|
return sortByLastCreated;
|
|
@@ -20184,9 +20703,10 @@ const addRoles = async (communityId, roleIds, userIds) => {
|
|
|
20184
20703
|
const client = getActiveClient();
|
|
20185
20704
|
client.log('community/moderation/addRoles', communityId, roleIds, userIds);
|
|
20186
20705
|
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
20187
|
-
const data =
|
|
20706
|
+
const data = prepareCommunityMembershipPayload(payload);
|
|
20188
20707
|
if (client.cache)
|
|
20189
20708
|
ingestInCache(data);
|
|
20709
|
+
fireEvent('local.community.roleAdded', data);
|
|
20190
20710
|
const { communityUsers } = data;
|
|
20191
20711
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
20192
20712
|
roleIds.some(role => communityUser.roles.includes(role)));
|
|
@@ -20216,9 +20736,10 @@ const removeRoles = async (communityId, roleIds, userIds) => {
|
|
|
20216
20736
|
const client = getActiveClient();
|
|
20217
20737
|
client.log('community/moderation/removeRoles', communityId, roleIds, userIds);
|
|
20218
20738
|
const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
20219
|
-
const data =
|
|
20739
|
+
const data = prepareCommunityMembershipPayload(payload);
|
|
20220
20740
|
if (client.cache)
|
|
20221
20741
|
ingestInCache(data);
|
|
20742
|
+
fireEvent('local.community.roleRemoved', data);
|
|
20222
20743
|
const { communityUsers } = data;
|
|
20223
20744
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
20224
20745
|
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
@@ -20905,7 +21426,7 @@ const updatePost = async (postId, patch) => {
|
|
|
20905
21426
|
const cachedAt = client.cache && Date.now();
|
|
20906
21427
|
if (client.cache)
|
|
20907
21428
|
ingestInCache(data, { cachedAt });
|
|
20908
|
-
fireEvent('local.post.updated',
|
|
21429
|
+
fireEvent('local.post.updated', payload);
|
|
20909
21430
|
const { posts } = data;
|
|
20910
21431
|
return {
|
|
20911
21432
|
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
@@ -21005,7 +21526,15 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
21005
21526
|
}
|
|
21006
21527
|
// to support hard deletion
|
|
21007
21528
|
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
21008
|
-
|
|
21529
|
+
if (permanent) {
|
|
21530
|
+
setTimeout(() => {
|
|
21531
|
+
pushToTombstone('post', postId);
|
|
21532
|
+
}, 0);
|
|
21533
|
+
}
|
|
21534
|
+
else {
|
|
21535
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
21536
|
+
}
|
|
21537
|
+
fireEvent('local.post.deleted', {
|
|
21009
21538
|
posts: [deleted],
|
|
21010
21539
|
categories: [],
|
|
21011
21540
|
comments: [],
|
|
@@ -21016,14 +21545,6 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
21016
21545
|
postChildren: [],
|
|
21017
21546
|
users: [],
|
|
21018
21547
|
});
|
|
21019
|
-
if (permanent) {
|
|
21020
|
-
setTimeout(() => {
|
|
21021
|
-
pushToTombstone('post', postId);
|
|
21022
|
-
}, 0);
|
|
21023
|
-
}
|
|
21024
|
-
else {
|
|
21025
|
-
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
21026
|
-
}
|
|
21027
21548
|
return LinkedObject.post(deleted);
|
|
21028
21549
|
};
|
|
21029
21550
|
|
|
@@ -21411,6 +21932,7 @@ getCommentByIds.locally = (commentIds) => {
|
|
|
21411
21932
|
* @async
|
|
21412
21933
|
*/
|
|
21413
21934
|
const createComment = async (bundle) => {
|
|
21935
|
+
var _a;
|
|
21414
21936
|
const client = getActiveClient();
|
|
21415
21937
|
client.log('comment/createComment', bundle);
|
|
21416
21938
|
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
@@ -21422,18 +21944,21 @@ const createComment = async (bundle) => {
|
|
|
21422
21944
|
if (client.cache)
|
|
21423
21945
|
ingestInCache(data, { cachedAt });
|
|
21424
21946
|
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
21425
|
-
const post =
|
|
21426
|
-
|
|
21427
|
-
|
|
21428
|
-
|
|
21429
|
-
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
|
|
21433
|
-
|
|
21434
|
-
|
|
21435
|
-
|
|
21436
|
-
|
|
21947
|
+
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21948
|
+
if (post) {
|
|
21949
|
+
post.commentsCount += 1;
|
|
21950
|
+
fireEvent('local.post.updated', {
|
|
21951
|
+
posts: [post],
|
|
21952
|
+
categories: [],
|
|
21953
|
+
comments: [],
|
|
21954
|
+
communities: [],
|
|
21955
|
+
communityUsers: data.communityUsers,
|
|
21956
|
+
feeds: [],
|
|
21957
|
+
files: data.files,
|
|
21958
|
+
postChildren: [],
|
|
21959
|
+
users: data.users,
|
|
21960
|
+
});
|
|
21961
|
+
}
|
|
21437
21962
|
}
|
|
21438
21963
|
else if (bundle.referenceType === 'story') {
|
|
21439
21964
|
const storyIndex = pullFromCache([
|
|
@@ -21592,6 +22117,7 @@ getStoryByStoryId$1.locally = (storyId) => {
|
|
|
21592
22117
|
* @async
|
|
21593
22118
|
*/
|
|
21594
22119
|
const deleteComment = async (commentId, permanent = false) => {
|
|
22120
|
+
var _a;
|
|
21595
22121
|
const client = getActiveClient();
|
|
21596
22122
|
const comment = await getComment$2(commentId);
|
|
21597
22123
|
// API-FIX: This endpoint has not been implemented yet.
|
|
@@ -21616,18 +22142,28 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
21616
22142
|
});
|
|
21617
22143
|
}
|
|
21618
22144
|
else {
|
|
21619
|
-
const post =
|
|
21620
|
-
|
|
21621
|
-
|
|
21622
|
-
|
|
21623
|
-
|
|
21624
|
-
|
|
21625
|
-
|
|
21626
|
-
|
|
21627
|
-
|
|
21628
|
-
|
|
21629
|
-
|
|
21630
|
-
|
|
22145
|
+
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22146
|
+
if (post) {
|
|
22147
|
+
let removeCount;
|
|
22148
|
+
if (!deleted.parentId) {
|
|
22149
|
+
// NOTE: delete the parent comment will remove all children comments
|
|
22150
|
+
removeCount = deleted.childrenNumber + 1;
|
|
22151
|
+
}
|
|
22152
|
+
else
|
|
22153
|
+
removeCount = 1;
|
|
22154
|
+
post.commentsCount -= removeCount;
|
|
22155
|
+
fireEvent('local.post.updated', {
|
|
22156
|
+
posts: [post],
|
|
22157
|
+
categories: [],
|
|
22158
|
+
comments: [],
|
|
22159
|
+
communities: [],
|
|
22160
|
+
communityUsers: [],
|
|
22161
|
+
feeds: [],
|
|
22162
|
+
files: [],
|
|
22163
|
+
postChildren: [],
|
|
22164
|
+
users: [],
|
|
22165
|
+
});
|
|
22166
|
+
}
|
|
21631
22167
|
}
|
|
21632
22168
|
fireEvent('local.comment.deleted', {
|
|
21633
22169
|
comments: [deleted],
|
|
@@ -21893,6 +22429,81 @@ const observeComment = (commentId, callback, policy = 'cache_then_server') => {
|
|
|
21893
22429
|
};
|
|
21894
22430
|
};
|
|
21895
22431
|
|
|
22432
|
+
/**
|
|
22433
|
+
* ```js
|
|
22434
|
+
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
22435
|
+
* const dispose = onCommentDeleteLocal(comment => {
|
|
22436
|
+
* // ...
|
|
22437
|
+
* })
|
|
22438
|
+
* ```
|
|
22439
|
+
*
|
|
22440
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
22441
|
+
*
|
|
22442
|
+
* @param callback The function to call when the event was fired
|
|
22443
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22444
|
+
*
|
|
22445
|
+
* @category Comment Events
|
|
22446
|
+
*/
|
|
22447
|
+
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
22448
|
+
|
|
22449
|
+
/**
|
|
22450
|
+
* ```js
|
|
22451
|
+
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
|
|
22452
|
+
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
22453
|
+
* // ...
|
|
22454
|
+
* })
|
|
22455
|
+
* ```
|
|
22456
|
+
*
|
|
22457
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
22458
|
+
*
|
|
22459
|
+
* @param callback The function to call when the event was fired
|
|
22460
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22461
|
+
*
|
|
22462
|
+
* @category Comment Events
|
|
22463
|
+
*/
|
|
22464
|
+
const onLocalCommentReactionAdded = (callback) => {
|
|
22465
|
+
const client = getActiveClient();
|
|
22466
|
+
const filter = ({ comment }) => {
|
|
22467
|
+
if (!client.cache) {
|
|
22468
|
+
callback(comment);
|
|
22469
|
+
}
|
|
22470
|
+
else {
|
|
22471
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
22472
|
+
callback(commentLinkedObject(comment));
|
|
22473
|
+
}
|
|
22474
|
+
};
|
|
22475
|
+
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
22476
|
+
};
|
|
22477
|
+
|
|
22478
|
+
/**
|
|
22479
|
+
* ```js
|
|
22480
|
+
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
|
|
22481
|
+
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
22482
|
+
* // ...
|
|
22483
|
+
* })
|
|
22484
|
+
* ```
|
|
22485
|
+
*
|
|
22486
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
22487
|
+
*
|
|
22488
|
+
* @param callback The function to call when the event was fired
|
|
22489
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22490
|
+
*
|
|
22491
|
+
* @category Comment Events
|
|
22492
|
+
*/
|
|
22493
|
+
const onLocalCommentReactionRemoved = (callback) => {
|
|
22494
|
+
const client = getActiveClient();
|
|
22495
|
+
const filter = ({ comment }) => {
|
|
22496
|
+
if (!client.cache) {
|
|
22497
|
+
callback(comment);
|
|
22498
|
+
}
|
|
22499
|
+
else {
|
|
22500
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
22501
|
+
callback(commentLinkedObject(comment));
|
|
22502
|
+
}
|
|
22503
|
+
};
|
|
22504
|
+
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
22505
|
+
};
|
|
22506
|
+
|
|
21896
22507
|
/* begin_public_function
|
|
21897
22508
|
id: comment.get
|
|
21898
22509
|
*/
|
|
@@ -21917,26 +22528,15 @@ const observeComment = (commentId, callback, policy = 'cache_then_server') => {
|
|
|
21917
22528
|
*/
|
|
21918
22529
|
const getComment = (commentId, callback) => {
|
|
21919
22530
|
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
22531
|
+
onCommentDeleteLocal,
|
|
21920
22532
|
onCommentDeleted,
|
|
21921
22533
|
onCommentFlagged,
|
|
21922
22534
|
onCommentReactionAdded,
|
|
21923
22535
|
onCommentReactionRemoved,
|
|
21924
22536
|
onCommentUnflagged,
|
|
21925
22537
|
onCommentUpdated,
|
|
21926
|
-
|
|
21927
|
-
|
|
21928
|
-
if (comment.parentId !== commentId)
|
|
21929
|
-
return;
|
|
21930
|
-
const cacheParent = pullFromCache([
|
|
21931
|
-
'comment',
|
|
21932
|
-
'get',
|
|
21933
|
-
comment.parentId,
|
|
21934
|
-
]);
|
|
21935
|
-
if (!(cacheParent === null || cacheParent === void 0 ? void 0 : cacheParent.data))
|
|
21936
|
-
return;
|
|
21937
|
-
callback(Object.assign(Object.assign({}, cacheParent.data), { childrenNumber: cacheParent.data.childrenNumber + 1, children: [...new Set([...cacheParent.data.children, comment.commentId])] }));
|
|
21938
|
-
});
|
|
21939
|
-
},
|
|
22538
|
+
onLocalCommentReactionAdded,
|
|
22539
|
+
onLocalCommentReactionRemoved,
|
|
21940
22540
|
]);
|
|
21941
22541
|
};
|
|
21942
22542
|
/* end_public_function */
|
|
@@ -22020,6 +22620,25 @@ class CommentQueryStreamController extends QueryStreamController {
|
|
|
22020
22620
|
}
|
|
22021
22621
|
}
|
|
22022
22622
|
|
|
22623
|
+
/**
|
|
22624
|
+
* ```js
|
|
22625
|
+
* import { onCommentCreated } from '@amityco/ts-sdk'
|
|
22626
|
+
* const dispose = onCommentCreated(comment => {
|
|
22627
|
+
* // ...
|
|
22628
|
+
* })
|
|
22629
|
+
* ```
|
|
22630
|
+
*
|
|
22631
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
22632
|
+
*
|
|
22633
|
+
* @param callback The function to call when the event was fired
|
|
22634
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22635
|
+
*
|
|
22636
|
+
* @category Comment Events
|
|
22637
|
+
*/
|
|
22638
|
+
const onCommentCreatedLocal = (callback) => {
|
|
22639
|
+
return createLocalCommentEventSubscriber('local.comment.created', callback);
|
|
22640
|
+
};
|
|
22641
|
+
|
|
22023
22642
|
class CommentLiveCollectionController extends LiveCollectionController {
|
|
22024
22643
|
constructor(query, callback) {
|
|
22025
22644
|
const queryStreamId = hash__default["default"](query);
|
|
@@ -22049,6 +22668,8 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
22049
22668
|
}
|
|
22050
22669
|
startSubscription() {
|
|
22051
22670
|
return this.queryStreamController.subscribeRTE([
|
|
22671
|
+
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
22672
|
+
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
22052
22673
|
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
22053
22674
|
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
22054
22675
|
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
@@ -22056,6 +22677,8 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
22056
22677
|
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
22057
22678
|
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
22058
22679
|
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
22680
|
+
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
22681
|
+
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
22059
22682
|
]);
|
|
22060
22683
|
}
|
|
22061
22684
|
notifyChange({ origin, loading, error }) {
|
|
@@ -22187,6 +22810,98 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
22187
22810
|
getComments: getComments
|
|
22188
22811
|
});
|
|
22189
22812
|
|
|
22813
|
+
/**
|
|
22814
|
+
* ```js
|
|
22815
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk'
|
|
22816
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
22817
|
+
* // ...
|
|
22818
|
+
* })
|
|
22819
|
+
* ```
|
|
22820
|
+
*
|
|
22821
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
22822
|
+
*
|
|
22823
|
+
* @param callback The function to call when the event was fired
|
|
22824
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22825
|
+
*
|
|
22826
|
+
* @category Post Events
|
|
22827
|
+
*/
|
|
22828
|
+
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
22829
|
+
|
|
22830
|
+
/**
|
|
22831
|
+
* ```js
|
|
22832
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
22833
|
+
* const dispose = onPostReactionAdded(post => {
|
|
22834
|
+
* // ...
|
|
22835
|
+
* })
|
|
22836
|
+
* ```
|
|
22837
|
+
*
|
|
22838
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
22839
|
+
*
|
|
22840
|
+
* @param callback The function to call when the event was fired
|
|
22841
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22842
|
+
*
|
|
22843
|
+
* @category Post Events
|
|
22844
|
+
*/
|
|
22845
|
+
const onLocalPostReactionAdded = (callback) => {
|
|
22846
|
+
const client = getActiveClient();
|
|
22847
|
+
const filter = ({ post }) => {
|
|
22848
|
+
if (!client.cache) {
|
|
22849
|
+
callback(post);
|
|
22850
|
+
}
|
|
22851
|
+
else {
|
|
22852
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
22853
|
+
callback(post);
|
|
22854
|
+
}
|
|
22855
|
+
};
|
|
22856
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
22857
|
+
};
|
|
22858
|
+
|
|
22859
|
+
/**
|
|
22860
|
+
* ```js
|
|
22861
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
|
|
22862
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
22863
|
+
* // ...
|
|
22864
|
+
* })
|
|
22865
|
+
* ```
|
|
22866
|
+
*
|
|
22867
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
22868
|
+
*
|
|
22869
|
+
* @param callback The function to call when the event was fired
|
|
22870
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22871
|
+
*
|
|
22872
|
+
* @category Post Events
|
|
22873
|
+
*/
|
|
22874
|
+
const onLocalPostReactionRemoved = (callback) => {
|
|
22875
|
+
const client = getActiveClient();
|
|
22876
|
+
const filter = ({ post }) => {
|
|
22877
|
+
if (!client.cache) {
|
|
22878
|
+
callback(post);
|
|
22879
|
+
}
|
|
22880
|
+
else {
|
|
22881
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
22882
|
+
callback(post);
|
|
22883
|
+
}
|
|
22884
|
+
};
|
|
22885
|
+
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
22886
|
+
};
|
|
22887
|
+
|
|
22888
|
+
/**
|
|
22889
|
+
* ```js
|
|
22890
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
22891
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
22892
|
+
* // ...
|
|
22893
|
+
* })
|
|
22894
|
+
* ```
|
|
22895
|
+
*
|
|
22896
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
22897
|
+
*
|
|
22898
|
+
* @param callback The function to call when the event was fired
|
|
22899
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22900
|
+
*
|
|
22901
|
+
* @category Post Events
|
|
22902
|
+
*/
|
|
22903
|
+
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
22904
|
+
|
|
22190
22905
|
/* begin_public_function
|
|
22191
22906
|
id: post.get
|
|
22192
22907
|
*/
|
|
@@ -22217,6 +22932,8 @@ const getPost$1 = (postId, callback) => {
|
|
|
22217
22932
|
return liveObject(postId, responder, 'postId', getPost$2, [
|
|
22218
22933
|
onPostApproved,
|
|
22219
22934
|
onPostDeclined,
|
|
22935
|
+
onLocalPostReactionAdded,
|
|
22936
|
+
onLocalPostReactionRemoved,
|
|
22220
22937
|
(callback) => {
|
|
22221
22938
|
return onPostDeleted((post) => {
|
|
22222
22939
|
var _a;
|
|
@@ -22251,6 +22968,8 @@ const getPost$1 = (postId, callback) => {
|
|
|
22251
22968
|
},
|
|
22252
22969
|
onPostUnflagged,
|
|
22253
22970
|
onPostUpdated,
|
|
22971
|
+
onPostUpdatedLocal,
|
|
22972
|
+
onLocalPostDeleted,
|
|
22254
22973
|
convertEventPayload((callback) => {
|
|
22255
22974
|
return onCommentCreated(async (comment) => {
|
|
22256
22975
|
if (comment.referenceId === postId) {
|
|
@@ -22444,6 +23163,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
22444
23163
|
return this.queryStreamController.subscribeRTE([
|
|
22445
23164
|
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
22446
23165
|
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
23166
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
22447
23167
|
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
22448
23168
|
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
22449
23169
|
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
@@ -22451,6 +23171,9 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
22451
23171
|
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
22452
23172
|
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
22453
23173
|
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
23174
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
23175
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
23176
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
22454
23177
|
{
|
|
22455
23178
|
fn: convertEventPayload((callback) => {
|
|
22456
23179
|
return onCommentCreated(async (comment) => {
|
|
@@ -23621,7 +24344,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
23621
24344
|
getPoll: getPoll
|
|
23622
24345
|
});
|
|
23623
24346
|
|
|
23624
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
24347
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
|
|
23625
24348
|
/*
|
|
23626
24349
|
* The crypto algorithm used for importing key and signing string
|
|
23627
24350
|
*/
|