@amityco/ts-sdk-react-native 6.12.1 → 6.13.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/README.md +8 -9
- package/dist/@types/core/marker.d.ts +4 -4
- package/dist/@types/core/marker.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +6 -6
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +21 -21
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/analytics.d.ts +31 -0
- package/dist/@types/domains/analytics.d.ts.map +1 -0
- package/dist/@types/domains/block.d.ts +1 -1
- package/dist/@types/domains/block.d.ts.map +1 -1
- package/dist/@types/domains/category.d.ts +5 -2
- package/dist/@types/domains/category.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +3 -3
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +2 -1
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +5 -5
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts +4 -4
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -2
- package/dist/@types/domains/group.d.ts.map +1 -1
- package/dist/@types/domains/messagePreview.d.ts +2 -2
- package/dist/@types/domains/messagePreview.d.ts.map +1 -1
- package/dist/@types/domains/poll.d.ts +1 -1
- package/dist/@types/domains/poll.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +15 -7
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/reaction.d.ts +1 -1
- package/dist/@types/domains/reaction.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +2 -2
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +7 -3
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/analytic/api/queryReachUser.d.ts +6 -0
- package/dist/analytic/api/queryReachUser.d.ts.map +1 -0
- package/dist/analytic/api/syncEvent.d.ts +2 -0
- package/dist/analytic/api/syncEvent.d.ts.map +1 -0
- package/dist/analytic/constant.d.ts +2 -0
- package/dist/analytic/constant.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +15 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +9 -0
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts +8 -0
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsService.d.ts +10 -0
- package/dist/analytic/service/analytic/AnalyticsService.d.ts.map +1 -0
- package/dist/analytic/utils/analyticsEngineOnLoginHandler.d.ts +3 -0
- package/dist/analytic/utils/analyticsEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/cache/api/pushToCache.d.ts +1 -1
- package/dist/cache/api/upsertInCache.d.ts +1 -1
- package/dist/categoryRepository/api/getCategory.d.ts.map +1 -1
- package/dist/categoryRepository/api/queryCategories.d.ts.map +1 -1
- package/dist/categoryRepository/observers/getCategories.d.ts.map +1 -1
- package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts +4 -4
- package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelMembership/api/queryChannelMembers.d.ts +1 -1
- package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts +4 -4
- package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/addRole.d.ts +4 -4
- package/dist/channelRepsitory/channelModeration/api/addRole.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts +2 -2
- package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts +4 -4
- package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts +2 -2
- package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/events/onChannelMemberAdded.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberBanned.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberRemoved.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberUnbanned.d.ts +1 -1
- package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts +2 -0
- package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts.map +1 -0
- package/dist/channelRepsitory/observers/tests/getChannelWithMessagePreview.test.d.ts +2 -0
- package/dist/channelRepsitory/observers/tests/getChannelWithMessagePreview.test.d.ts.map +1 -0
- package/dist/channelRepsitory/observers/tests/getChannelsWithMessagePreview.test.d.ts +2 -0
- package/dist/channelRepsitory/observers/tests/getChannelsWithMessagePreview.test.d.ts.map +1 -0
- package/dist/client/api/getToken.d.ts +3 -3
- package/dist/client/api/getToken.d.ts.map +1 -1
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts +1 -1
- package/dist/commentRepository/api/getComment.d.ts +8 -8
- package/dist/commentRepository/api/getComment.d.ts.map +1 -1
- package/dist/commentRepository/api/getCommentByIds.d.ts +8 -8
- package/dist/commentRepository/api/getCommentByIds.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentCreated.d.ts +2 -2
- package/dist/commentRepository/events/onCommentCreated.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentDeleted.d.ts +2 -2
- package/dist/commentRepository/events/onCommentDeleted.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentFlagged.d.ts +2 -2
- package/dist/commentRepository/events/onCommentFlagged.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentReactionAdded.d.ts +2 -2
- package/dist/commentRepository/events/onCommentReactionAdded.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentReactionRemoved.d.ts +2 -2
- package/dist/commentRepository/events/onCommentReactionRemoved.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentUnflagged.d.ts +2 -2
- package/dist/commentRepository/events/onCommentUnflagged.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentUpdated.d.ts +2 -2
- package/dist/commentRepository/events/onCommentUpdated.d.ts.map +1 -1
- package/dist/commentRepository/events/utils.d.ts +1 -1
- package/dist/commentRepository/events/utils.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComment.d.ts +2 -2
- package/dist/commentRepository/observers/getComment.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/addMembers.d.ts +4 -4
- package/dist/communityRepository/communityMembership/api/addMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/queryCommunityMembers.d.ts +1 -1
- package/dist/communityRepository/communityMembership/api/removeMembers.d.ts +4 -4
- package/dist/communityRepository/communityMembership/api/removeMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts +4 -4
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts +2 -2
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts +4 -4
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts +2 -2
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/core/device.d.ts +1 -1
- package/dist/core/device.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +4 -4
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/external/api/createUserToken.d.ts +2 -2
- package/dist/external/api/createUserToken.d.ts.map +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/group/utils/withUser.d.ts +3 -3
- package/dist/group/utils/withUser.d.ts.map +1 -1
- package/dist/index.cjs.js +567 -217
- package/dist/index.esm.js +567 -217
- package/dist/index.umd.js +2 -2
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messagePreview/utils/updateMessagePreviewFromMessage.d.ts.map +1 -1
- package/dist/messageRepository/api/getDeliveredUsers.d.ts +6 -6
- package/dist/messageRepository/api/getDeliveredUsers.d.ts.map +1 -1
- package/dist/messageRepository/api/getReadUsers.d.ts +6 -6
- package/dist/messageRepository/api/getReadUsers.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/postRepository/api/approvePost.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts +1 -1
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/api/declinePost.d.ts.map +1 -1
- package/dist/postRepository/api/deletePost.d.ts.map +1 -1
- package/dist/postRepository/api/editPost.d.ts.map +1 -1
- package/dist/postRepository/api/getPost.d.ts.map +1 -1
- package/dist/postRepository/api/getPostByIds.d.ts.map +1 -1
- package/dist/postRepository/api/hardDeletePost.d.ts.map +1 -1
- package/dist/postRepository/api/queryPosts.d.ts.map +1 -1
- package/dist/postRepository/api/softDeletePost.d.ts.map +1 -1
- package/dist/postRepository/api/tests/getPost.test.d.ts.map +1 -0
- package/dist/postRepository/api/updatePost.d.ts.map +1 -1
- package/dist/postRepository/events/onPostApproved.d.ts +2 -2
- package/dist/postRepository/events/onPostApproved.d.ts.map +1 -1
- package/dist/postRepository/events/onPostCreated.d.ts +2 -2
- package/dist/postRepository/events/onPostCreated.d.ts.map +1 -1
- package/dist/postRepository/events/onPostDeclined.d.ts +2 -2
- package/dist/postRepository/events/onPostDeclined.d.ts.map +1 -1
- package/dist/postRepository/events/onPostDeleted.d.ts +2 -2
- package/dist/postRepository/events/onPostDeleted.d.ts.map +1 -1
- package/dist/postRepository/events/onPostFlagged.d.ts +2 -2
- package/dist/postRepository/events/onPostFlagged.d.ts.map +1 -1
- package/dist/postRepository/events/onPostReactionAdded.d.ts +2 -2
- package/dist/postRepository/events/onPostReactionAdded.d.ts.map +1 -1
- package/dist/postRepository/events/onPostReactionRemoved.d.ts +2 -2
- package/dist/postRepository/events/onPostReactionRemoved.d.ts.map +1 -1
- package/dist/postRepository/events/onPostUnflagged.d.ts +2 -2
- package/dist/postRepository/events/onPostUnflagged.d.ts.map +1 -1
- package/dist/postRepository/events/onPostUpdated.d.ts +2 -2
- package/dist/postRepository/events/onPostUpdated.d.ts.map +1 -1
- package/dist/postRepository/events/utils.d.ts +1 -1
- package/dist/postRepository/events/utils.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts.d.ts +3 -2
- package/dist/postRepository/observers/getPosts.d.ts.map +1 -1
- package/dist/postRepository/observers/observePost.d.ts +2 -2
- package/dist/postRepository/observers/observePost.d.ts.map +1 -1
- package/dist/postRepository/observers/observePosts.d.ts +2 -3
- package/dist/postRepository/observers/observePosts.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactionAdded.d.ts +1 -1
- package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactionRemoved.d.ts +1 -1
- package/dist/reactionRepository/events/onReactionRemoved.d.ts.map +1 -1
- package/dist/reactionRepository/utils/fetchReference.d.ts +1 -1
- package/dist/reactionRepository/utils/fetchReference.d.ts.map +1 -1
- package/dist/streamRepository/api/getStreams.d.ts +1 -1
- package/dist/streamRepository/api/getStreams.d.ts.map +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts.map +1 -1
- package/dist/subChannelRepository/observers/tests/getSubChannelWithMessagePreview.test.d.ts +2 -0
- package/dist/subChannelRepository/observers/tests/getSubChannelWithMessagePreview.test.d.ts.map +1 -0
- package/dist/subChannelRepository/observers/tests/getSubChannelsWithMessagePreview.test.d.ts +2 -0
- package/dist/subChannelRepository/observers/tests/getSubChannelsWithMessagePreview.test.d.ts.map +1 -0
- package/dist/subChannelRepository/utils/updateSubChannelCache.d.ts +1 -1
- package/dist/subChannelRepository/utils/updateSubChannelCache.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts +1 -1
- package/dist/userRepository/api/flagUser.d.ts.map +1 -1
- package/dist/userRepository/api/getUser.d.ts.map +1 -1
- package/dist/userRepository/api/getUserByIds.d.ts +1 -1
- package/dist/userRepository/api/getUserByIds.d.ts.map +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -1
- package/dist/userRepository/api/queryBlockedUsers.d.ts +5 -5
- package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/api/queryUsers.d.ts +6 -6
- package/dist/userRepository/api/queryUsers.d.ts.map +1 -1
- package/dist/userRepository/api/unflagUser.d.ts +1 -1
- package/dist/userRepository/api/unflagUser.d.ts.map +1 -1
- package/dist/userRepository/api/updateUser.d.ts +4 -4
- package/dist/userRepository/api/updateUser.d.ts.map +1 -1
- package/dist/userRepository/events/onUserDeleted.d.ts +2 -2
- package/dist/userRepository/events/onUserDeleted.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFetched.d.ts +2 -2
- package/dist/userRepository/events/onUserFetched.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFlagCleared.d.ts +2 -2
- package/dist/userRepository/events/onUserFlagCleared.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFlagged.d.ts +2 -2
- package/dist/userRepository/events/onUserFlagged.d.ts.map +1 -1
- package/dist/userRepository/events/onUserUnflagged.d.ts +2 -2
- package/dist/userRepository/events/onUserUnflagged.d.ts.map +1 -1
- package/dist/userRepository/events/onUserUpdated.d.ts +2 -2
- package/dist/userRepository/events/onUserUpdated.d.ts.map +1 -1
- package/dist/userRepository/events/utils.d.ts +1 -1
- package/dist/userRepository/events/utils.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/getUser.d.ts +2 -2
- package/dist/userRepository/observers/getUser.d.ts.map +1 -1
- package/dist/userRepository/observers/getUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/getViewedUsers.d.ts +2 -0
- package/dist/userRepository/observers/getViewedUsers.d.ts.map +1 -0
- package/dist/userRepository/observers/index.d.ts +1 -0
- package/dist/userRepository/observers/index.d.ts.map +1 -1
- package/dist/userRepository/observers/observeUser.d.ts +2 -2
- package/dist/userRepository/observers/observeUser.d.ts.map +1 -1
- package/dist/userRepository/observers/searchUserByDisplayName.d.ts +2 -2
- package/dist/userRepository/observers/searchUserByDisplayName.d.ts.map +1 -1
- package/dist/userRepository/observers/tests/getViewedUsers.test.d.ts +2 -0
- package/dist/userRepository/observers/tests/getViewedUsers.test.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/api/blockUser.d.ts +4 -4
- package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts +4 -4
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/follow.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts +4 -4
- package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts +3 -3
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts +2 -2
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts +2 -2
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts.map +1 -1
- package/dist/utils/linkedObject/categoryLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/categoryLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/index.d.ts +3 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/userLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/userLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/client.d.ts.map +1 -1
- package/dist/utils/tests/dummy/block.d.ts +4 -4
- package/dist/utils/tests/dummy/block.d.ts.map +1 -1
- package/dist/utils/tests/dummy/category.d.ts +7 -0
- package/dist/utils/tests/dummy/category.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +61 -1
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +7 -7
- package/dist/utils/tests/dummy/comment.d.ts.map +1 -1
- package/dist/utils/tests/dummy/follow.d.ts +1 -1
- package/dist/utils/tests/dummy/follow.d.ts.map +1 -1
- package/dist/utils/tests/dummy/message.d.ts.map +1 -1
- package/dist/utils/tests/dummy/messagePreviewChannel.d.ts +3 -0
- package/dist/utils/tests/dummy/messagePreviewChannel.d.ts.map +1 -0
- package/dist/utils/tests/dummy/post.d.ts +15 -2
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/dist/utils/tests/dummy/subChannel.d.ts +29 -0
- package/dist/utils/tests/dummy/subChannel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/user.d.ts +12 -1
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/@types/core/marker.ts +4 -4
- package/src/@types/core/model.ts +6 -6
- package/src/@types/core/payload.ts +22 -21
- package/src/@types/domains/analytics.ts +39 -0
- package/src/@types/domains/block.ts +1 -1
- package/src/@types/domains/category.ts +6 -2
- package/src/@types/domains/client.ts +3 -3
- package/src/@types/domains/comment.ts +5 -2
- package/src/@types/domains/community.ts +5 -5
- package/src/@types/domains/follow.ts +4 -4
- package/src/@types/domains/group.ts +2 -2
- package/src/@types/domains/messagePreview.ts +2 -2
- package/src/@types/domains/poll.ts +1 -1
- package/src/@types/domains/post.ts +18 -7
- package/src/@types/domains/reaction.ts +1 -1
- package/src/@types/domains/stream.ts +2 -2
- package/src/@types/domains/user.ts +8 -3
- package/src/analytic/api/queryReachUser.ts +31 -0
- package/src/analytic/api/syncEvent.ts +12 -0
- package/src/analytic/constant.ts +1 -0
- package/src/analytic/service/analytic/AnalyticsEngine.ts +54 -0
- package/src/analytic/service/analytic/AnalyticsEventCapturer.ts +48 -0
- package/src/analytic/service/analytic/AnalyticsEventSyncer.ts +45 -0
- package/src/analytic/service/analytic/AnalyticsService.ts +23 -0
- package/src/analytic/utils/analyticsEngineOnLoginHandler.ts +19 -0
- package/src/cache/api/pushToCache.ts +1 -1
- package/src/cache/api/upsertInCache.ts +1 -1
- package/src/categoryRepository/api/getCategory.ts +3 -2
- package/src/categoryRepository/api/queryCategories.ts +7 -1
- package/src/categoryRepository/observers/getCategories.ts +3 -2
- package/src/categoryRepository/observers/tests/getCategories.test.ts +2 -1
- package/src/channelRepsitory/api/createChannel.ts +1 -1
- package/src/channelRepsitory/channelMembership/api/addMembers.ts +4 -4
- package/src/channelRepsitory/channelMembership/api/queryChannelMembers.ts +1 -1
- package/src/channelRepsitory/channelMembership/api/removeMembers.ts +4 -4
- package/src/channelRepsitory/channelMembership/observers/tests/getMembers.test.ts +1 -1
- package/src/channelRepsitory/channelMembership/observers/tests/searchMembers.test.ts +1 -3
- package/src/channelRepsitory/channelModeration/api/addRole.ts +4 -4
- package/src/channelRepsitory/channelModeration/api/banMembers.ts +2 -2
- package/src/channelRepsitory/channelModeration/api/removeRole.ts +4 -4
- package/src/channelRepsitory/channelModeration/api/unbanMembers.ts +2 -2
- package/src/channelRepsitory/events/onChannelMemberAdded.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberBanned.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberRemoved.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberUnbanned.ts +1 -1
- package/src/channelRepsitory/observers/tests/getChannel.test.ts +73 -0
- package/src/channelRepsitory/observers/tests/getChannelWithMessagePreview.test.ts +575 -0
- package/src/channelRepsitory/observers/tests/getChannels.test.ts +505 -68
- package/src/channelRepsitory/observers/tests/getChannelsWithMessagePreview.test.ts +592 -0
- package/src/client/api/getToken.ts +3 -3
- package/src/client/api/login.ts +3 -1
- package/src/commentRepository/api/getComment.ts +11 -11
- package/src/commentRepository/api/getCommentByIds.ts +13 -12
- package/src/commentRepository/events/onCommentCreated.ts +4 -3
- package/src/commentRepository/events/onCommentDeleted.ts +4 -3
- package/src/commentRepository/events/onCommentFlagged.ts +4 -3
- package/src/commentRepository/events/onCommentReactionAdded.ts +2 -2
- package/src/commentRepository/events/onCommentReactionRemoved.ts +2 -2
- package/src/commentRepository/events/onCommentUnflagged.ts +4 -3
- package/src/commentRepository/events/onCommentUpdated.ts +4 -3
- package/src/commentRepository/events/utils.ts +1 -1
- package/src/commentRepository/observers/getComment.ts +2 -2
- package/src/communityRepository/communityMembership/api/addMembers.ts +4 -4
- package/src/communityRepository/communityMembership/api/queryCommunityMembers.ts +1 -1
- package/src/communityRepository/communityMembership/api/removeMembers.ts +4 -4
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/communityRepository/communityMembership/observers/getMembers.ts +2 -2
- package/src/communityRepository/communityMembership/observers/tests/getMembers.test.ts +1 -1
- package/src/communityRepository/communityModeration/api/addRoles.ts +4 -4
- package/src/communityRepository/communityModeration/api/banMembers.ts +2 -2
- package/src/communityRepository/communityModeration/api/removeRoles.ts +4 -4
- package/src/communityRepository/communityModeration/api/unbanMembers.ts +2 -2
- package/src/core/device.ts +1 -1
- package/src/core/query/filtering.ts +6 -4
- package/src/core/query/tests/filtering.test.ts +2 -2
- package/src/core/query/tests/runQuery.test.ts +35 -22
- package/src/external/api/createUserToken.ts +2 -2
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +8 -5
- package/src/feedRepository/api/queryGlobalFeed.ts +7 -4
- package/src/feedRepository/api/test/getCustomRankingGlobalFeed.test.ts +22 -14
- package/src/feedRepository/api/test/queryGlobalFeed.test.ts +21 -15
- package/src/group/utils/withUser.ts +8 -4
- package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +1 -1
- package/src/messagePreview/utils/getSubChannelMessagePreviewWithUser.ts +1 -1
- package/src/messagePreview/utils/updateMessagePreviewFromMessage.ts +8 -4
- package/src/messageRepository/api/getDeliveredUsers.ts +11 -9
- package/src/messageRepository/api/getReadUsers.ts +11 -9
- package/src/messageRepository/observers/tests/getMessages.test.ts +766 -0
- package/src/messageRepository/utils/prepareMessagePayload.ts +19 -2
- package/src/postRepository/api/approvePost.ts +2 -1
- package/src/postRepository/api/createPost.ts +8 -6
- package/src/postRepository/api/declinePost.ts +2 -1
- package/src/postRepository/api/deletePost.ts +2 -1
- package/src/postRepository/api/editPost.ts +2 -1
- package/src/postRepository/api/getPost.ts +6 -3
- package/src/postRepository/api/getPostByIds.ts +4 -3
- package/src/postRepository/api/hardDeletePost.ts +2 -1
- package/src/postRepository/api/queryPosts.ts +5 -4
- package/src/postRepository/api/softDeletePost.ts +2 -1
- package/src/postRepository/api/tests/getPost.test.ts +114 -0
- package/src/postRepository/api/tests/queryPosts.test.ts +2 -2
- package/src/postRepository/api/updatePost.ts +2 -1
- package/src/postRepository/events/onPostApproved.ts +2 -2
- package/src/postRepository/events/onPostCreated.ts +2 -2
- package/src/postRepository/events/onPostDeclined.ts +2 -2
- package/src/postRepository/events/onPostDeleted.ts +2 -2
- package/src/postRepository/events/onPostFlagged.ts +2 -2
- package/src/postRepository/events/onPostReactionAdded.ts +5 -3
- package/src/postRepository/events/onPostReactionRemoved.ts +5 -3
- package/src/postRepository/events/onPostUnflagged.ts +2 -2
- package/src/postRepository/events/onPostUpdated.ts +2 -2
- package/src/postRepository/events/utils.ts +2 -2
- package/src/postRepository/observers/getPosts.ts +7 -5
- package/src/postRepository/observers/observePost.ts +24 -9
- package/src/postRepository/observers/observePosts.ts +11 -12
- package/src/postRepository/observers/tests/getPost.test.ts +2 -2
- package/src/postRepository/observers/tests/getPosts.test.ts +36 -11
- package/src/streamRepository/api/getStreams.ts +1 -1
- package/src/streamRepository/api/queryStreams.ts +1 -1
- package/src/subChannelRepository/observers/getSubChannel.ts +1 -1
- package/src/subChannelRepository/observers/getSubChannels.ts +6 -6
- package/src/subChannelRepository/observers/tests/getSubChannelWithMessagePreview.test.ts +591 -0
- package/src/subChannelRepository/observers/tests/getSubChannels.test.ts +322 -14
- package/src/subChannelRepository/observers/tests/getSubChannelsWithMessagePreview.test.ts +643 -0
- package/src/subChannelRepository/utils/updateSubChannelCache.ts +3 -2
- package/src/userRepository/api/flagUser.ts +1 -1
- package/src/userRepository/api/getUser.ts +12 -2
- package/src/userRepository/api/getUserByIds.ts +5 -4
- package/src/userRepository/api/isUserFlaggedByMe.ts +1 -1
- package/src/userRepository/api/queryBlockedUsers.ts +10 -8
- package/src/userRepository/api/queryUsers.ts +12 -10
- package/src/userRepository/api/unflagUser.ts +1 -1
- package/src/userRepository/api/updateUser.ts +6 -6
- package/src/userRepository/events/onUserDeleted.ts +2 -2
- package/src/userRepository/events/onUserFetched.ts +2 -2
- package/src/userRepository/events/onUserFlagCleared.ts +2 -2
- package/src/userRepository/events/onUserFlagged.ts +2 -2
- package/src/userRepository/events/onUserUnflagged.ts +2 -2
- package/src/userRepository/events/onUserUpdated.ts +2 -2
- package/src/userRepository/events/utils.ts +1 -1
- package/src/userRepository/observers/getBlockedUsers.ts +8 -7
- package/src/userRepository/observers/getUser.ts +3 -3
- package/src/userRepository/observers/getUsers.ts +2 -2
- package/src/userRepository/observers/getViewedUsers.ts +93 -0
- package/src/userRepository/observers/index.ts +1 -0
- package/src/userRepository/observers/observeUser.ts +9 -6
- package/src/userRepository/observers/searchUserByDisplayName.ts +2 -2
- package/src/userRepository/observers/tests/getUser.test.ts +1 -1
- package/src/userRepository/observers/tests/getUsers.test.ts +12 -11
- package/src/userRepository/observers/tests/getViewedUsers.test.ts +39 -0
- package/src/userRepository/observers/tests/searchUserByDisplayName.test.ts +1 -1
- package/src/userRepository/relationship/block/api/blockUser.ts +6 -4
- package/src/userRepository/relationship/block/api/unBlockUser.ts +6 -4
- package/src/userRepository/relationship/block/observers/getBlockedUsers.ts +1 -1
- package/src/userRepository/relationship/follow/api/acceptFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/acceptMyFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/declineFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/declineMyFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/follow.ts +2 -2
- package/src/userRepository/relationship/follow/api/getFollowInfo.ts +4 -4
- package/src/userRepository/relationship/follow/api/unfollow.ts +3 -3
- package/src/userRepository/relationship/follow/api/utils.ts +1 -1
- package/src/userRepository/relationship/follow/observers/getFollowers.ts +1 -1
- package/src/userRepository/relationship/follow/observers/getFollowings.ts +1 -1
- package/src/userRepository/relationship/follow/observers/observeFollowInfo.ts +1 -1
- package/src/userRepository/relationship/follow/observers/observeFollowers.ts +2 -16
- package/src/userRepository/relationship/follow/observers/observeFollowings.ts +2 -16
- package/src/utils/linkedObject/categoryLinkedObject.ts +40 -0
- package/src/utils/linkedObject/commentLinkedObject.ts +4 -0
- package/src/utils/linkedObject/index.ts +6 -0
- package/src/utils/linkedObject/postLinkedObject.ts +37 -0
- package/src/utils/linkedObject/userLinkedObject.ts +36 -0
- package/src/utils/tests/client.ts +2 -1
- package/src/utils/tests/dummy/block.ts +3 -3
- package/src/utils/tests/dummy/category.ts +5 -0
- package/src/utils/tests/dummy/channel.ts +150 -1
- package/src/utils/tests/dummy/comment.ts +1 -1
- package/src/utils/tests/dummy/community.ts +1 -1
- package/src/utils/tests/dummy/follow.ts +1 -1
- package/src/utils/tests/dummy/message.ts +0 -1
- package/src/utils/tests/dummy/messagePreviewChannel.ts +37 -0
- package/src/utils/tests/dummy/post.ts +45 -3
- package/src/utils/tests/dummy/subChannel.ts +29 -0
- package/src/utils/tests/dummy/user.ts +11 -1
- package/tsconfig.json +18 -23
- package/dist/postRepository/tests/api/getPost.test.d.ts.map +0 -1
- package/src/postRepository/tests/api/getPost.test.ts +0 -98
- /package/dist/postRepository/{tests/api → api/tests}/getPost.test.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -83,8 +83,8 @@ const PostContentType = Object.freeze({
|
|
|
83
83
|
|
|
84
84
|
function getVersion() {
|
|
85
85
|
try {
|
|
86
|
-
// the string ''v6.
|
|
87
|
-
return 'v6.
|
|
86
|
+
// the string ''v6.13.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
87
|
+
return 'v6.13.0-esm';
|
|
88
88
|
}
|
|
89
89
|
catch (error) {
|
|
90
90
|
return '__dev__';
|
|
@@ -928,7 +928,7 @@ const pullFromCache = (key) => {
|
|
|
928
928
|
/**
|
|
929
929
|
* ```js
|
|
930
930
|
* import { pushToCache } from '@amityco/ts-sdk-react-native'
|
|
931
|
-
* pushToCache<Amity.
|
|
931
|
+
* pushToCache<Amity.InternalUser>(["user", "foobar"], user)
|
|
932
932
|
* ```
|
|
933
933
|
*
|
|
934
934
|
* Saves any provided value as {@link Amity.CacheEntry} for the matching {@link Amity.CacheKey}
|
|
@@ -994,7 +994,7 @@ const mergeInCache = (key, mutation, options) => {
|
|
|
994
994
|
/**
|
|
995
995
|
* ```js
|
|
996
996
|
* import { upsertInCache } from '@amityco/ts-sdk-react-native'
|
|
997
|
-
* upsertInCache<Amity.
|
|
997
|
+
* upsertInCache<Amity.InternalUser>(["user", "foobar"], user)
|
|
998
998
|
* ```
|
|
999
999
|
*
|
|
1000
1000
|
* Insert or update any provided value as {@link Amity.CacheEntry} for
|
|
@@ -20804,7 +20804,11 @@ const withUser = (member, userIdProp = 'userId', userProp = 'user') => {
|
|
|
20804
20804
|
const client = getActiveClient();
|
|
20805
20805
|
if (!client.cache)
|
|
20806
20806
|
return undefined;
|
|
20807
|
-
const userCache = (_a = pullFromCache([
|
|
20807
|
+
const userCache = (_a = pullFromCache([
|
|
20808
|
+
'user',
|
|
20809
|
+
'get',
|
|
20810
|
+
member[userIdProp],
|
|
20811
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
20808
20812
|
if (!userCache) {
|
|
20809
20813
|
return undefined;
|
|
20810
20814
|
}
|
|
@@ -21056,8 +21060,8 @@ function shallowClone(obj) {
|
|
|
21056
21060
|
return clone;
|
|
21057
21061
|
}
|
|
21058
21062
|
|
|
21059
|
-
function updateSubChannelCache(subChannel, params) {
|
|
21060
|
-
pushToCache(['subChannel', 'get',
|
|
21063
|
+
function updateSubChannelCache(subChannelId, subChannel, params) {
|
|
21064
|
+
pushToCache(['subChannel', 'get', subChannelId],
|
|
21061
21065
|
// eslint-disable-next-line prefer-object-spread
|
|
21062
21066
|
Object.assign(shallowClone(subChannel), params));
|
|
21063
21067
|
}
|
|
@@ -21095,6 +21099,9 @@ const handleMessageCreated = async (message) => {
|
|
|
21095
21099
|
subChannelUpdatedAt: subChannelCache === null || subChannelCache === void 0 ? void 0 : subChannelCache.updatedAt,
|
|
21096
21100
|
subChannelName: subChannelCache === null || subChannelCache === void 0 ? void 0 : subChannelCache.displayName,
|
|
21097
21101
|
});
|
|
21102
|
+
updateSubChannelCache(message.subChannelId, subChannelCache, {
|
|
21103
|
+
messagePreviewId,
|
|
21104
|
+
});
|
|
21098
21105
|
}
|
|
21099
21106
|
/**
|
|
21100
21107
|
* Channel Case
|
|
@@ -21151,7 +21158,7 @@ const handleMessageUpdated = async (message) => {
|
|
|
21151
21158
|
'get',
|
|
21152
21159
|
subChannelId,
|
|
21153
21160
|
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
21154
|
-
updateSubChannelCache(subChannelCache, {
|
|
21161
|
+
updateSubChannelCache(message.subChannelId, subChannelCache, {
|
|
21155
21162
|
messagePreviewId,
|
|
21156
21163
|
});
|
|
21157
21164
|
pushToCache(['messagePreviewSubChannel', 'get', message.subChannelId], {
|
|
@@ -21165,7 +21172,7 @@ const handleMessageUpdated = async (message) => {
|
|
|
21165
21172
|
dataType,
|
|
21166
21173
|
segment,
|
|
21167
21174
|
isDeleted,
|
|
21168
|
-
subChannelUpdatedAt:
|
|
21175
|
+
subChannelUpdatedAt: message === null || message === void 0 ? void 0 : message.updatedAt,
|
|
21169
21176
|
subChannelName: subChannelCache === null || subChannelCache === void 0 ? void 0 : subChannelCache.displayName,
|
|
21170
21177
|
});
|
|
21171
21178
|
}
|
|
@@ -21221,7 +21228,7 @@ const handleSubChannelUpdated = async (subChannel) => {
|
|
|
21221
21228
|
const messagePreviewSubChannelCache = (_c = pullFromCache([
|
|
21222
21229
|
'messagePreviewSubChannel',
|
|
21223
21230
|
'get',
|
|
21224
|
-
|
|
21231
|
+
subChannelId,
|
|
21225
21232
|
])) === null || _c === void 0 ? void 0 : _c.data;
|
|
21226
21233
|
if (messagePreviewSubChannelCache &&
|
|
21227
21234
|
new Date(messagePreviewSubChannelCache.updatedAt).valueOf() >
|
|
@@ -21231,7 +21238,7 @@ const handleSubChannelUpdated = async (subChannel) => {
|
|
|
21231
21238
|
'get',
|
|
21232
21239
|
subChannelId,
|
|
21233
21240
|
])) === null || _d === void 0 ? void 0 : _d.data;
|
|
21234
|
-
pushToCache(['messagePreviewSubChannel', 'get',
|
|
21241
|
+
pushToCache(['messagePreviewSubChannel', 'get', subChannelId], Object.assign(Object.assign({}, messagePreviewSubChannelCache), { subChannelName: subChannelCache === null || subChannelCache === void 0 ? void 0 : subChannelCache.displayName, subChannelUpdatedAt: subChannelCache === null || subChannelCache === void 0 ? void 0 : subChannelCache.updatedAt }));
|
|
21235
21242
|
}
|
|
21236
21243
|
};
|
|
21237
21244
|
|
|
@@ -21628,7 +21635,6 @@ const preUpdateMessageCache = (rawPayload) => {
|
|
|
21628
21635
|
});
|
|
21629
21636
|
};
|
|
21630
21637
|
const prepareMessagePayload = async (payload, event) => {
|
|
21631
|
-
var _a, _b;
|
|
21632
21638
|
const markerIds = payload.messages.map(({ messageId }) => messageId);
|
|
21633
21639
|
if (markerIds.length > 0) {
|
|
21634
21640
|
// since the get markers method requires a channel cache to function with the reducer.
|
|
@@ -21640,7 +21646,18 @@ const prepareMessagePayload = async (payload, event) => {
|
|
|
21640
21646
|
// empty block (from the spec, allow marker fetch to fail without having to do anything)
|
|
21641
21647
|
}
|
|
21642
21648
|
}
|
|
21643
|
-
|
|
21649
|
+
const { messageFeeds } = payload, restPayload = __rest(payload, ["messageFeeds"]);
|
|
21650
|
+
// upsert messageFeeds to subchannel cache because messageFeeds from event payload not include messagePreviewId
|
|
21651
|
+
if (messageFeeds && messageFeeds.length > 0) {
|
|
21652
|
+
messageFeeds === null || messageFeeds === void 0 ? void 0 : messageFeeds.forEach(messageFeed => {
|
|
21653
|
+
var _a, _b;
|
|
21654
|
+
const subChannelCache = (_b = (_a = pullFromCache(['subChannel', 'get', messageFeed.messageFeedId])) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {};
|
|
21655
|
+
// exclude getter properties from existing subChannel cache, update only other properties to existing subChannel cache
|
|
21656
|
+
const _c = convertFromRaw$1(messageFeed), restSubChannel = __rest(_c, ["unreadCount", "hasMentioned"]);
|
|
21657
|
+
updateSubChannelCache(messageFeed.messageFeedId, subChannelCache, restSubChannel);
|
|
21658
|
+
});
|
|
21659
|
+
}
|
|
21660
|
+
return Object.assign(Object.assign({}, restPayload), { messages: payload.messages.map(m => convertFromRaw(m, payload.reactions, event)) });
|
|
21644
21661
|
};
|
|
21645
21662
|
function convertParams(_a) {
|
|
21646
21663
|
var { subChannelId, mentionees, dataType, data } = _a, rest = __rest(_a, ["subChannelId", "mentionees", "dataType", "data"]);
|
|
@@ -22387,7 +22404,7 @@ const onChannelDeleted = (callback) => {
|
|
|
22387
22404
|
* })
|
|
22388
22405
|
* ```
|
|
22389
22406
|
*
|
|
22390
|
-
* Fired when any {@link Amity.
|
|
22407
|
+
* Fired when any {@link Amity.InternalUser} has been banned from any {@link Amity.Channel}
|
|
22391
22408
|
*
|
|
22392
22409
|
* @param callback The function to call when the event was fired
|
|
22393
22410
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22424,7 +22441,7 @@ const createUserEventSubscriber = (event, callback) => {
|
|
|
22424
22441
|
* })
|
|
22425
22442
|
* ```
|
|
22426
22443
|
*
|
|
22427
|
-
* Fired when a {@link Amity.
|
|
22444
|
+
* Fired when a {@link Amity.InternalUser} has been deleted
|
|
22428
22445
|
*
|
|
22429
22446
|
* @param callback The function to call when the event was fired
|
|
22430
22447
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22433,6 +22450,142 @@ const createUserEventSubscriber = (event, callback) => {
|
|
|
22433
22450
|
*/
|
|
22434
22451
|
const onUserDeleted = (callback) => createUserEventSubscriber('user.deleted', callback);
|
|
22435
22452
|
|
|
22453
|
+
const ANALYTIC_CACHE_KEY = ['analytic', 'post'];
|
|
22454
|
+
|
|
22455
|
+
const syncEvent = async (events) => {
|
|
22456
|
+
const client = getActiveClient();
|
|
22457
|
+
await client.http.post('/api/v1/analytics/activities', {
|
|
22458
|
+
activities: events,
|
|
22459
|
+
});
|
|
22460
|
+
};
|
|
22461
|
+
|
|
22462
|
+
class AnalyticsEventSyncer {
|
|
22463
|
+
constructor() {
|
|
22464
|
+
this._timer = undefined;
|
|
22465
|
+
}
|
|
22466
|
+
start() {
|
|
22467
|
+
this.syncCapturedEvent();
|
|
22468
|
+
this._timer = setInterval(() => {
|
|
22469
|
+
this.syncCapturedEvent();
|
|
22470
|
+
}, 1 * MINUTE);
|
|
22471
|
+
}
|
|
22472
|
+
stop() {
|
|
22473
|
+
if (!this._timer)
|
|
22474
|
+
return;
|
|
22475
|
+
clearInterval(this._timer);
|
|
22476
|
+
this._timer = undefined;
|
|
22477
|
+
}
|
|
22478
|
+
async syncCapturedEvent() {
|
|
22479
|
+
try {
|
|
22480
|
+
// Must query only objects that has same userId with current logged-in user.
|
|
22481
|
+
// Query captured event with maximum of 1000
|
|
22482
|
+
// Order by latest first
|
|
22483
|
+
// e.g. If there is 2000 events we will query 1000-2000 first
|
|
22484
|
+
const cache = pullFromCache(ANALYTIC_CACHE_KEY);
|
|
22485
|
+
if (!(cache === null || cache === void 0 ? void 0 : cache.data))
|
|
22486
|
+
return;
|
|
22487
|
+
if (cache.data.event.length === 0)
|
|
22488
|
+
return;
|
|
22489
|
+
const capturedEvents = cache.data.event;
|
|
22490
|
+
await syncEvent(capturedEvents);
|
|
22491
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
22492
|
+
}
|
|
22493
|
+
catch (error) {
|
|
22494
|
+
// stop and destroy all events
|
|
22495
|
+
this.stop();
|
|
22496
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
22497
|
+
}
|
|
22498
|
+
}
|
|
22499
|
+
}
|
|
22500
|
+
|
|
22501
|
+
class AnalyticsEventCapturer {
|
|
22502
|
+
constructor() {
|
|
22503
|
+
this._expireTime = 5 * MINUTE;
|
|
22504
|
+
this._poolLimit = 1000;
|
|
22505
|
+
this._recentViewed = {};
|
|
22506
|
+
}
|
|
22507
|
+
markPostAsViewed(postId) {
|
|
22508
|
+
var _a;
|
|
22509
|
+
const now = new Date();
|
|
22510
|
+
getActiveClient();
|
|
22511
|
+
const recentViewedPostDate = (_a = this._recentViewed[postId]) !== null && _a !== void 0 ? _a : new Date(-86400000);
|
|
22512
|
+
const timeDiff = now.getTime() - recentViewedPostDate.getTime();
|
|
22513
|
+
if (timeDiff < this._expireTime) {
|
|
22514
|
+
// just recently view this post, ignore the event.
|
|
22515
|
+
return;
|
|
22516
|
+
}
|
|
22517
|
+
const currentData = { event: [] };
|
|
22518
|
+
const cache = pullFromCache(ANALYTIC_CACHE_KEY);
|
|
22519
|
+
if (cache === null || cache === void 0 ? void 0 : cache.data) {
|
|
22520
|
+
currentData.event = cache.data.event;
|
|
22521
|
+
}
|
|
22522
|
+
// If the pool is full (Max 1000 items), remove the oldest data
|
|
22523
|
+
if (currentData.event.length >= this._poolLimit) {
|
|
22524
|
+
// Remove oldest data
|
|
22525
|
+
currentData.event.shift();
|
|
22526
|
+
}
|
|
22527
|
+
currentData.event.push({
|
|
22528
|
+
contentId: postId,
|
|
22529
|
+
contentType: 'post',
|
|
22530
|
+
activityType: 'view',
|
|
22531
|
+
timestamp: now.toISOString(),
|
|
22532
|
+
});
|
|
22533
|
+
upsertInCache(ANALYTIC_CACHE_KEY, currentData);
|
|
22534
|
+
this._recentViewed[postId] = now;
|
|
22535
|
+
}
|
|
22536
|
+
}
|
|
22537
|
+
|
|
22538
|
+
class AnalyticsEngine {
|
|
22539
|
+
constructor() {
|
|
22540
|
+
this._client = getActiveClient();
|
|
22541
|
+
this._eventCapturer = new AnalyticsEventCapturer();
|
|
22542
|
+
this._eventSyncer = new AnalyticsEventSyncer();
|
|
22543
|
+
}
|
|
22544
|
+
markPostAsViewed(postId) {
|
|
22545
|
+
if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
|
|
22546
|
+
this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */ // For case token_expired, we assume token is expired and gonna re-connect soon
|
|
22547
|
+
) {
|
|
22548
|
+
this._eventCapturer.markPostAsViewed(postId);
|
|
22549
|
+
}
|
|
22550
|
+
}
|
|
22551
|
+
established() {
|
|
22552
|
+
this._eventSyncer.start();
|
|
22553
|
+
}
|
|
22554
|
+
handleTokenExpired() {
|
|
22555
|
+
this._eventSyncer.stop();
|
|
22556
|
+
}
|
|
22557
|
+
destroy() {
|
|
22558
|
+
this._eventSyncer.stop();
|
|
22559
|
+
// query and destroy all objects.
|
|
22560
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
22561
|
+
}
|
|
22562
|
+
}
|
|
22563
|
+
let instance;
|
|
22564
|
+
var AnalyticsEngine$1 = {
|
|
22565
|
+
getInstance: () => {
|
|
22566
|
+
if (!instance) {
|
|
22567
|
+
instance = new AnalyticsEngine();
|
|
22568
|
+
}
|
|
22569
|
+
return instance;
|
|
22570
|
+
},
|
|
22571
|
+
};
|
|
22572
|
+
|
|
22573
|
+
var analyticsEngineOnLoginHandler = () => {
|
|
22574
|
+
const analyticsEngine = AnalyticsEngine$1.getInstance();
|
|
22575
|
+
analyticsEngine.established();
|
|
22576
|
+
onSessionStateChange(state => {
|
|
22577
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
22578
|
+
analyticsEngine.established();
|
|
22579
|
+
}
|
|
22580
|
+
else {
|
|
22581
|
+
analyticsEngine.handleTokenExpired();
|
|
22582
|
+
}
|
|
22583
|
+
});
|
|
22584
|
+
return () => {
|
|
22585
|
+
analyticsEngine.destroy();
|
|
22586
|
+
};
|
|
22587
|
+
};
|
|
22588
|
+
|
|
22436
22589
|
/* begin_public_function
|
|
22437
22590
|
id: client.logout
|
|
22438
22591
|
*/
|
|
@@ -22733,7 +22886,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
22733
22886
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
22734
22887
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
22735
22888
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
22736
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler());
|
|
22889
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler());
|
|
22737
22890
|
}
|
|
22738
22891
|
return true;
|
|
22739
22892
|
};
|
|
@@ -23868,7 +24021,7 @@ const onChannelMuted = (callback) => {
|
|
|
23868
24021
|
* })
|
|
23869
24022
|
* ```
|
|
23870
24023
|
*
|
|
23871
|
-
* Fired when any {@link Amity.
|
|
24024
|
+
* Fired when any {@link Amity.InternalUser} has been added to any {@link Amity.Channel}
|
|
23872
24025
|
*
|
|
23873
24026
|
* @param callback The function to call when the event was fired
|
|
23874
24027
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -23894,7 +24047,7 @@ const onChannelMemberAdded = (callback) => {
|
|
|
23894
24047
|
* })
|
|
23895
24048
|
* ```
|
|
23896
24049
|
*
|
|
23897
|
-
* Fired when any {@link Amity.
|
|
24050
|
+
* Fired when any {@link Amity.InternalUser} has been removed from any {@link Amity.Channel}
|
|
23898
24051
|
*
|
|
23899
24052
|
* @param callback The function to call when the event was fired
|
|
23900
24053
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -23920,7 +24073,7 @@ const onChannelMemberRemoved = (callback) => {
|
|
|
23920
24073
|
* })
|
|
23921
24074
|
* ```
|
|
23922
24075
|
*
|
|
23923
|
-
* Fired when any {@link Amity.
|
|
24076
|
+
* Fired when any {@link Amity.InternalUser} has been unbanned from any {@link Amity.Channel}
|
|
23924
24077
|
*
|
|
23925
24078
|
* @param callback The function to call when the event was fired
|
|
23926
24079
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -24694,11 +24847,11 @@ const getChannels = (params, callback, config) => {
|
|
|
24694
24847
|
* const updated = await addMembers(channelId, ['foo', 'bar'])
|
|
24695
24848
|
* ```
|
|
24696
24849
|
*
|
|
24697
|
-
* Adds a list of {@link Amity.
|
|
24850
|
+
* Adds a list of {@link Amity.InternalUser} to a {@link Amity.Channel}
|
|
24698
24851
|
*
|
|
24699
24852
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
24700
|
-
* @param userIds The list of IDs {@link Amity.
|
|
24701
|
-
* @returns A success boolean if the {@link Amity.
|
|
24853
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to add
|
|
24854
|
+
* @returns A success boolean if the {@link Amity.InternalUser} were added to the {@link Amity.Channel}
|
|
24702
24855
|
*
|
|
24703
24856
|
* @category Channel API
|
|
24704
24857
|
* @async
|
|
@@ -24728,11 +24881,11 @@ const addMembers$1 = async (channelId, userIds) => {
|
|
|
24728
24881
|
* const updated = await removeMembers(channelId, ['foo', 'bar'])
|
|
24729
24882
|
* ```
|
|
24730
24883
|
*
|
|
24731
|
-
* Removes a list of {@link Amity.
|
|
24884
|
+
* Removes a list of {@link Amity.InternalUser} from a {@link Amity.Channel}
|
|
24732
24885
|
*
|
|
24733
24886
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
24734
|
-
* @param userIds The list of IDs {@link Amity.
|
|
24735
|
-
* @returns A success boolean if the list of {@link Amity.
|
|
24887
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to remove
|
|
24888
|
+
* @returns A success boolean if the list of {@link Amity.InternalUser} were removed from the {@link Amity.Channel}
|
|
24736
24889
|
*
|
|
24737
24890
|
* @category Channel API
|
|
24738
24891
|
* @async
|
|
@@ -24807,7 +24960,7 @@ const queryChannelMembers = async (query) => {
|
|
|
24807
24960
|
* const channelMembers = await queryChannelMembers(query)
|
|
24808
24961
|
* ```
|
|
24809
24962
|
*
|
|
24810
|
-
* Queries a paginable list of {@link Amity.
|
|
24963
|
+
* Queries a paginable list of {@link Amity.InternalPost} objects from cache
|
|
24811
24964
|
*
|
|
24812
24965
|
* @param query The query parameters
|
|
24813
24966
|
* @returns posts
|
|
@@ -25024,12 +25177,12 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
25024
25177
|
* const updated = await addRole(channelId, 'foo', ['bar'])
|
|
25025
25178
|
* ```
|
|
25026
25179
|
*
|
|
25027
|
-
* Adds an {@link Amity.Role} to a list of {@link Amity.
|
|
25180
|
+
* Adds an {@link Amity.Role} to a list of {@link Amity.InternalUser} on a {@link Amity.Channel}
|
|
25028
25181
|
*
|
|
25029
25182
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
25030
25183
|
* @param roleId The ID of the {@link Amity.Role} to apply
|
|
25031
|
-
* @param userId Array of IDs of the {@link Amity.
|
|
25032
|
-
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.
|
|
25184
|
+
* @param userId Array of IDs of the {@link Amity.InternalUser} to perform
|
|
25185
|
+
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.InternalUser} in the {@link Amity.Channel}
|
|
25033
25186
|
*
|
|
25034
25187
|
* @category Channel API
|
|
25035
25188
|
* @async
|
|
@@ -25056,12 +25209,12 @@ const addRole = async (channelId, roleId, userIds) => {
|
|
|
25056
25209
|
* const updated = await removeRole(channelId, 'foo', ['bar'])
|
|
25057
25210
|
* ```
|
|
25058
25211
|
*
|
|
25059
|
-
* Removes an {@link Amity.Role} from a list of {@link Amity.
|
|
25212
|
+
* Removes an {@link Amity.Role} from a list of {@link Amity.InternalUser} on a {@link Amity.Channel}
|
|
25060
25213
|
*
|
|
25061
25214
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
25062
25215
|
* @param roleId The ID of the {@link Amity.Role} to apply
|
|
25063
|
-
* @param userIds Array of IDs of the {@link Amity.
|
|
25064
|
-
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.
|
|
25216
|
+
* @param userIds Array of IDs of the {@link Amity.InternalUser} to perform
|
|
25217
|
+
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.InternalUser} in the {@link Amity.Channel}
|
|
25065
25218
|
*
|
|
25066
25219
|
* @category Channel API
|
|
25067
25220
|
* @async
|
|
@@ -25090,7 +25243,7 @@ const removeRole = async (channelId, roleId, userIds) => {
|
|
|
25090
25243
|
* ```
|
|
25091
25244
|
*
|
|
25092
25245
|
* @param channelId of {@link Amity.Channel} from which the users should be banned
|
|
25093
|
-
* @param userIds of the {@link Amity.
|
|
25246
|
+
* @param userIds of the {@link Amity.InternalUser}'s to be banned
|
|
25094
25247
|
* @returns the updated {@link Amity.Membership}'s object
|
|
25095
25248
|
*
|
|
25096
25249
|
* @category Channel API
|
|
@@ -25125,7 +25278,7 @@ const banMembers$1 = async (channelId, userIds) => {
|
|
|
25125
25278
|
* ```
|
|
25126
25279
|
*
|
|
25127
25280
|
* @param channelId of {@link Amity.Channel} where the users should be unbanned
|
|
25128
|
-
* @param userIds of the {@link Amity.
|
|
25281
|
+
* @param userIds of the {@link Amity.InternalUser}'s to be unbanned
|
|
25129
25282
|
* @returns the updated {@link Amity.Membership}'s object
|
|
25130
25283
|
*
|
|
25131
25284
|
* @category Channel API
|
|
@@ -25578,10 +25731,10 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
25578
25731
|
* const blockedUser = await UserRepository.blockUser('userId')
|
|
25579
25732
|
* ```
|
|
25580
25733
|
*
|
|
25581
|
-
* Blocks a {@link Amity.
|
|
25734
|
+
* Blocks a {@link Amity.InternalUser}
|
|
25582
25735
|
*
|
|
25583
|
-
* @param userId The ID of the {@link Amity.
|
|
25584
|
-
* @returns the blocked {@link Amity.
|
|
25736
|
+
* @param userId The ID of the {@link Amity.InternalUser} to block
|
|
25737
|
+
* @returns the blocked {@link Amity.InternalUser} object
|
|
25585
25738
|
*
|
|
25586
25739
|
* @category Post API
|
|
25587
25740
|
* @async
|
|
@@ -25611,10 +25764,10 @@ const blockUser = async (userId) => {
|
|
|
25611
25764
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
25612
25765
|
* ```
|
|
25613
25766
|
*
|
|
25614
|
-
* Blocks a {@link Amity.
|
|
25767
|
+
* Blocks a {@link Amity.InternalUser}
|
|
25615
25768
|
*
|
|
25616
|
-
* @param userId The ID of the {@link Amity.
|
|
25617
|
-
* @returns the unblocked {@link Amity.
|
|
25769
|
+
* @param userId The ID of the {@link Amity.InternalUser} to unblock
|
|
25770
|
+
* @returns the unblocked {@link Amity.InternalUser} object
|
|
25618
25771
|
*
|
|
25619
25772
|
* @category Post API
|
|
25620
25773
|
* @async
|
|
@@ -25642,7 +25795,7 @@ const unBlockUser = async (userId) => {
|
|
|
25642
25795
|
* ```
|
|
25643
25796
|
*
|
|
25644
25797
|
* @param query The query parameters
|
|
25645
|
-
* @returns A page of {@link Amity.
|
|
25798
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
25646
25799
|
*
|
|
25647
25800
|
* @category Block API
|
|
25648
25801
|
* @async
|
|
@@ -25680,11 +25833,11 @@ const queryBlockedUsers = async (query) => {
|
|
|
25680
25833
|
* const { data: users } = queryBlockedUsers.locally({ page: 'page_token' })
|
|
25681
25834
|
* ```
|
|
25682
25835
|
*
|
|
25683
|
-
* Queries a paginable list of {@link Amity.
|
|
25836
|
+
* Queries a paginable list of {@link Amity.InternalUser} objects from cache
|
|
25684
25837
|
* Search is performed by displayName such as `.startsWith(search)`
|
|
25685
25838
|
*
|
|
25686
25839
|
* @param query The query parameters
|
|
25687
|
-
* @returns A page of {@link Amity.
|
|
25840
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
25688
25841
|
*
|
|
25689
25842
|
* @category Block API
|
|
25690
25843
|
*/
|
|
@@ -25712,6 +25865,139 @@ queryBlockedUsers.locally = (query = {}) => {
|
|
|
25712
25865
|
: undefined;
|
|
25713
25866
|
};
|
|
25714
25867
|
|
|
25868
|
+
const categoryLinkedObject = (category) => {
|
|
25869
|
+
return Object.assign(Object.assign({}, category), { get avatar() {
|
|
25870
|
+
var _a;
|
|
25871
|
+
if (!category.avatarFileId)
|
|
25872
|
+
return null;
|
|
25873
|
+
let avatar = {
|
|
25874
|
+
fileId: ((_a = category.avatarFileId) === null || _a === void 0 ? void 0 : _a.toString()) ? category.avatarFileId.toString() : '',
|
|
25875
|
+
type: 'image',
|
|
25876
|
+
fileUrl: '',
|
|
25877
|
+
createdAt: '',
|
|
25878
|
+
attributes: {
|
|
25879
|
+
name: '',
|
|
25880
|
+
extension: '',
|
|
25881
|
+
size: '',
|
|
25882
|
+
mimeType: '',
|
|
25883
|
+
metadata: {
|
|
25884
|
+
exif: {},
|
|
25885
|
+
gps: {},
|
|
25886
|
+
width: 0,
|
|
25887
|
+
height: 0,
|
|
25888
|
+
isFull: false,
|
|
25889
|
+
},
|
|
25890
|
+
},
|
|
25891
|
+
};
|
|
25892
|
+
const cacheData = pullFromCache([
|
|
25893
|
+
'file',
|
|
25894
|
+
'get',
|
|
25895
|
+
`${category.avatarFileId}`,
|
|
25896
|
+
]);
|
|
25897
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data) {
|
|
25898
|
+
avatar = cacheData === null || cacheData === void 0 ? void 0 : cacheData.data;
|
|
25899
|
+
}
|
|
25900
|
+
return avatar;
|
|
25901
|
+
} });
|
|
25902
|
+
};
|
|
25903
|
+
|
|
25904
|
+
const commentLinkedObject = (comment) => {
|
|
25905
|
+
return Object.assign(Object.assign({}, comment), { get target() {
|
|
25906
|
+
const commentTypes = {
|
|
25907
|
+
type: comment.targetType,
|
|
25908
|
+
};
|
|
25909
|
+
if (comment.targetType === 'user') {
|
|
25910
|
+
return Object.assign(Object.assign({}, commentTypes), { userId: comment.targetId });
|
|
25911
|
+
}
|
|
25912
|
+
if (commentTypes.type === 'content') {
|
|
25913
|
+
return Object.assign(Object.assign({}, commentTypes), { contentId: comment.targetId });
|
|
25914
|
+
}
|
|
25915
|
+
if (commentTypes.type === 'community') {
|
|
25916
|
+
const cacheData = pullFromCache([
|
|
25917
|
+
'communityUsers',
|
|
25918
|
+
'get',
|
|
25919
|
+
`${comment.targetId}#${comment.userId}`,
|
|
25920
|
+
]);
|
|
25921
|
+
return Object.assign(Object.assign({}, commentTypes), { communityId: comment.targetId, creatorMember: cacheData === null || cacheData === void 0 ? void 0 : cacheData.data });
|
|
25922
|
+
}
|
|
25923
|
+
return {
|
|
25924
|
+
type: 'unknown',
|
|
25925
|
+
};
|
|
25926
|
+
},
|
|
25927
|
+
get creator() {
|
|
25928
|
+
const cacheData = pullFromCache(['user', 'get', comment.userId]);
|
|
25929
|
+
return cacheData === null || cacheData === void 0 ? void 0 : cacheData.data;
|
|
25930
|
+
} });
|
|
25931
|
+
};
|
|
25932
|
+
|
|
25933
|
+
const userLinkedObject = (user) => {
|
|
25934
|
+
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
25935
|
+
var _a;
|
|
25936
|
+
if (!user.avatarFileId)
|
|
25937
|
+
return null;
|
|
25938
|
+
let avatar = {
|
|
25939
|
+
fileId: ((_a = user.avatarFileId) === null || _a === void 0 ? void 0 : _a.toString()) ? user.avatarFileId.toString() : '',
|
|
25940
|
+
type: 'image',
|
|
25941
|
+
fileUrl: '',
|
|
25942
|
+
createdAt: '',
|
|
25943
|
+
attributes: {
|
|
25944
|
+
name: '',
|
|
25945
|
+
extension: '',
|
|
25946
|
+
size: '',
|
|
25947
|
+
mimeType: '',
|
|
25948
|
+
metadata: {
|
|
25949
|
+
exif: {},
|
|
25950
|
+
gps: {},
|
|
25951
|
+
width: 0,
|
|
25952
|
+
height: 0,
|
|
25953
|
+
isFull: false,
|
|
25954
|
+
},
|
|
25955
|
+
},
|
|
25956
|
+
};
|
|
25957
|
+
const cacheData = pullFromCache(['file', 'get', `${user.avatarFileId}`]);
|
|
25958
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data) {
|
|
25959
|
+
avatar = cacheData === null || cacheData === void 0 ? void 0 : cacheData.data;
|
|
25960
|
+
}
|
|
25961
|
+
return avatar;
|
|
25962
|
+
} });
|
|
25963
|
+
};
|
|
25964
|
+
|
|
25965
|
+
const postLinkedObject = (post) => {
|
|
25966
|
+
return Object.assign(Object.assign({}, post), { analytics: {
|
|
25967
|
+
markAsViewed: () => {
|
|
25968
|
+
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
25969
|
+
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
25970
|
+
},
|
|
25971
|
+
}, get latestComments() {
|
|
25972
|
+
if (!post.comments)
|
|
25973
|
+
return [];
|
|
25974
|
+
return (post.comments
|
|
25975
|
+
.map(commentId => {
|
|
25976
|
+
var _a;
|
|
25977
|
+
const commentCached = (_a = pullFromCache([
|
|
25978
|
+
'comment',
|
|
25979
|
+
'get',
|
|
25980
|
+
commentId,
|
|
25981
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
25982
|
+
if (!commentCached)
|
|
25983
|
+
return null;
|
|
25984
|
+
return commentLinkedObject(commentCached);
|
|
25985
|
+
})
|
|
25986
|
+
.filter(Boolean) || []);
|
|
25987
|
+
},
|
|
25988
|
+
get creator() {
|
|
25989
|
+
const cacheData = pullFromCache(['user', 'get', post.postedUserId]);
|
|
25990
|
+
return (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data) || null;
|
|
25991
|
+
} });
|
|
25992
|
+
};
|
|
25993
|
+
|
|
25994
|
+
const LinkedObject = {
|
|
25995
|
+
comment: commentLinkedObject,
|
|
25996
|
+
post: postLinkedObject,
|
|
25997
|
+
user: userLinkedObject,
|
|
25998
|
+
category: categoryLinkedObject,
|
|
25999
|
+
};
|
|
26000
|
+
|
|
25715
26001
|
/* eslint-disable no-use-before-define */
|
|
25716
26002
|
/* begin_public_function
|
|
25717
26003
|
id: user.get_blocked_users
|
|
@@ -25722,10 +26008,10 @@ queryBlockedUsers.locally = (query = {}) => {
|
|
|
25722
26008
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
25723
26009
|
* ```
|
|
25724
26010
|
*
|
|
25725
|
-
* Blocks a {@link Amity.
|
|
26011
|
+
* Blocks a {@link Amity.InternalUser}
|
|
25726
26012
|
*
|
|
25727
|
-
* @param params The params to get blocked {@link Amity.
|
|
25728
|
-
* @param callback to recieve updates on unblocked {@link Amity.
|
|
26013
|
+
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
26014
|
+
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
25729
26015
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
25730
26016
|
*
|
|
25731
26017
|
* @category Post API
|
|
@@ -25748,7 +26034,7 @@ const getBlockedUsers$1 = (params, callback, config) => {
|
|
|
25748
26034
|
const users = (_a = data.data
|
|
25749
26035
|
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
25750
26036
|
.filter(Boolean)
|
|
25751
|
-
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
26037
|
+
.map(({ data }) => LinkedObject.user(data))) !== null && _a !== void 0 ? _a : [];
|
|
25752
26038
|
callback({
|
|
25753
26039
|
onNextPage: onFetch,
|
|
25754
26040
|
data: users,
|
|
@@ -25818,7 +26104,7 @@ const getBlockedUsers = (params, callback, config) => {
|
|
|
25818
26104
|
*
|
|
25819
26105
|
* Follow the user
|
|
25820
26106
|
*
|
|
25821
|
-
* @param userId the ID of the {@link Amity.
|
|
26107
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
25822
26108
|
* @returns the status {@link Amity.FollowStatus}
|
|
25823
26109
|
*
|
|
25824
26110
|
* @category Follow API
|
|
@@ -25851,8 +26137,8 @@ const follow = async (userId) => {
|
|
|
25851
26137
|
*
|
|
25852
26138
|
* Cancel the follow request or unfollow the user
|
|
25853
26139
|
*
|
|
25854
|
-
* @param userId the ID of the {@link Amity.
|
|
25855
|
-
* @returns A success boolean if the user {@link Amity.
|
|
26140
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26141
|
+
* @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
|
|
25856
26142
|
*
|
|
25857
26143
|
* @category Follow API
|
|
25858
26144
|
* @async
|
|
@@ -25880,7 +26166,7 @@ const unfollow = async (userId) => {
|
|
|
25880
26166
|
*
|
|
25881
26167
|
* Accept the follow request
|
|
25882
26168
|
*
|
|
25883
|
-
* @param userId the ID of the {@link Amity.
|
|
26169
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
25884
26170
|
* @returns A success boolean if the follow request was accepted
|
|
25885
26171
|
*
|
|
25886
26172
|
* @category Follow API
|
|
@@ -25908,7 +26194,7 @@ const acceptFollower = async (userId) => {
|
|
|
25908
26194
|
*
|
|
25909
26195
|
* Accept the follow request
|
|
25910
26196
|
*
|
|
25911
|
-
* @param userId the ID of the {@link Amity.
|
|
26197
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
25912
26198
|
* @returns A success boolean if the follow request was accepted
|
|
25913
26199
|
*
|
|
25914
26200
|
* @category Follow API
|
|
@@ -25937,7 +26223,7 @@ const acceptMyFollower = async (userId) => {
|
|
|
25937
26223
|
*
|
|
25938
26224
|
* Decline the follow request or delete the follower
|
|
25939
26225
|
*
|
|
25940
|
-
* @param userId the ID of the {@link Amity.
|
|
26226
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
25941
26227
|
* @returns A success boolean if the follow request was decline
|
|
25942
26228
|
*
|
|
25943
26229
|
* @category Follow API
|
|
@@ -25965,7 +26251,7 @@ const declineFollower = async (userId) => {
|
|
|
25965
26251
|
*
|
|
25966
26252
|
* Decline the follow request or delete the follower
|
|
25967
26253
|
*
|
|
25968
|
-
* @param userId the ID of the {@link Amity.
|
|
26254
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
25969
26255
|
* @returns A success boolean if the follow request was decline
|
|
25970
26256
|
*
|
|
25971
26257
|
* @category Follow API
|
|
@@ -26134,7 +26420,7 @@ const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follo
|
|
|
26134
26420
|
*
|
|
26135
26421
|
* Fetches the number of followers, followings, pending requests and the follow status for current user
|
|
26136
26422
|
*
|
|
26137
|
-
* @param userId the ID of the {@link Amity.
|
|
26423
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26138
26424
|
* @returns the associated {@link Amity.FollowInfo} object
|
|
26139
26425
|
*
|
|
26140
26426
|
* @category Follow API
|
|
@@ -26166,7 +26452,7 @@ const getFollowInfo$1 = async (userId) => {
|
|
|
26166
26452
|
*
|
|
26167
26453
|
* Fetches the number of followers, followings, pending requests and the follow status for current user from cache
|
|
26168
26454
|
*
|
|
26169
|
-
* @param userId the ID of the {@link Amity.
|
|
26455
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26170
26456
|
* @returns the associated {@link Amity.FollowInfo} object
|
|
26171
26457
|
*
|
|
26172
26458
|
* @category Follow API
|
|
@@ -26278,7 +26564,7 @@ const observeFollowInfo = (userId, callback, policy = 'cache_then_server') => {
|
|
|
26278
26564
|
*
|
|
26279
26565
|
* Observe all mutations on a list of followers {@link Amity.FollowStatus} for a given user
|
|
26280
26566
|
*
|
|
26281
|
-
* @param userId the ID of the {@link Amity.
|
|
26567
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26282
26568
|
* @param callback the function to call when new data are available
|
|
26283
26569
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
26284
26570
|
*
|
|
@@ -26291,9 +26577,6 @@ const observeFollowers = (userId, callback) => {
|
|
|
26291
26577
|
const disposers = [];
|
|
26292
26578
|
const router = (status, action) => {
|
|
26293
26579
|
var _a, _b;
|
|
26294
|
-
if (status.from !== userId) {
|
|
26295
|
-
return;
|
|
26296
|
-
}
|
|
26297
26580
|
if (callback instanceof Function) {
|
|
26298
26581
|
return callback(status);
|
|
26299
26582
|
}
|
|
@@ -26317,7 +26600,7 @@ const observeFollowers = (userId, callback) => {
|
|
|
26317
26600
|
*
|
|
26318
26601
|
* Observe all mutations on a list of followings {@link Amity.FollowStatus} for a given user
|
|
26319
26602
|
*
|
|
26320
|
-
* @param userId the ID of the {@link Amity.
|
|
26603
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26321
26604
|
* @param callback the function to call when new data are available
|
|
26322
26605
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
26323
26606
|
*
|
|
@@ -26330,9 +26613,6 @@ const observeFollowings = (userId, callback) => {
|
|
|
26330
26613
|
const disposers = [];
|
|
26331
26614
|
const router = (status, action) => {
|
|
26332
26615
|
var _a, _b;
|
|
26333
|
-
if (status.to !== userId) {
|
|
26334
|
-
return;
|
|
26335
|
-
}
|
|
26336
26616
|
if (callback instanceof Function) {
|
|
26337
26617
|
return callback(status);
|
|
26338
26618
|
}
|
|
@@ -26435,7 +26715,7 @@ queryFollowers.locally = (query) => queryFollows.locally('followers', query);
|
|
|
26435
26715
|
*
|
|
26436
26716
|
* let followers = []
|
|
26437
26717
|
* const unsub = getFollowers({
|
|
26438
|
-
* userId: Amity.
|
|
26718
|
+
* userId: Amity.InternalUser['userId'];
|
|
26439
26719
|
* }, response => merge(followers, response.data))
|
|
26440
26720
|
* ```
|
|
26441
26721
|
*
|
|
@@ -26559,7 +26839,7 @@ queryFollowings.locally = (query) => queryFollows.locally('following', query);
|
|
|
26559
26839
|
*
|
|
26560
26840
|
* let followings = []
|
|
26561
26841
|
* const unsub = getFollowings({
|
|
26562
|
-
* userId: Amity.
|
|
26842
|
+
* userId: Amity.InternalUser['userId'];
|
|
26563
26843
|
* }, response => merge(followings, response.data))
|
|
26564
26844
|
* ```
|
|
26565
26845
|
*
|
|
@@ -26763,7 +27043,7 @@ const getUserByIds = async (userIds) => {
|
|
|
26763
27043
|
ingestInCache(data, { cachedAt });
|
|
26764
27044
|
fireEvent('user.fetched', data);
|
|
26765
27045
|
return {
|
|
26766
|
-
data: data.users,
|
|
27046
|
+
data: data.users.map(user => LinkedObject.user(user)),
|
|
26767
27047
|
cachedAt,
|
|
26768
27048
|
};
|
|
26769
27049
|
};
|
|
@@ -26790,7 +27070,7 @@ getUserByIds.locally = (userIds) => {
|
|
|
26790
27070
|
const cached = userIds
|
|
26791
27071
|
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
26792
27072
|
.filter(Boolean);
|
|
26793
|
-
const users = cached.map(({ data }) => data);
|
|
27073
|
+
const users = cached.map(({ data }) => LinkedObject.user(data));
|
|
26794
27074
|
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
26795
27075
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < userIds.length)
|
|
26796
27076
|
return;
|
|
@@ -26809,11 +27089,11 @@ getUserByIds.locally = (userIds) => {
|
|
|
26809
27089
|
* const updated = await updateUser(userId, { displayName: 'foobar' })
|
|
26810
27090
|
* ```
|
|
26811
27091
|
*
|
|
26812
|
-
* Updates an {@link Amity.
|
|
27092
|
+
* Updates an {@link Amity.InternalUser}
|
|
26813
27093
|
*
|
|
26814
|
-
* @param userId The ID of the {@link Amity.
|
|
27094
|
+
* @param userId The ID of the {@link Amity.InternalUser} to update
|
|
26815
27095
|
* @param patch The patch data to apply
|
|
26816
|
-
* @returns the updated {@link Amity.
|
|
27096
|
+
* @returns the updated {@link Amity.InternalUser} object
|
|
26817
27097
|
*
|
|
26818
27098
|
* @category User API
|
|
26819
27099
|
* @async
|
|
@@ -26925,7 +27205,7 @@ const isUserFlaggedByMe = async (userId) => {
|
|
|
26925
27205
|
* })
|
|
26926
27206
|
* ```
|
|
26927
27207
|
*
|
|
26928
|
-
* Fired when a {@link Amity.
|
|
27208
|
+
* Fired when a {@link Amity.InternalUser} has been updated
|
|
26929
27209
|
*
|
|
26930
27210
|
* @param callback The function to call when the event was fired
|
|
26931
27211
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -26942,7 +27222,7 @@ const onUserUpdated = (callback) => createUserEventSubscriber('user.updated', ca
|
|
|
26942
27222
|
* })
|
|
26943
27223
|
* ```
|
|
26944
27224
|
*
|
|
26945
|
-
* Fired when a {@link Amity.
|
|
27225
|
+
* Fired when a {@link Amity.InternalUser} has been flagged
|
|
26946
27226
|
*
|
|
26947
27227
|
* @param callback The function to call when the event was fired
|
|
26948
27228
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -26959,7 +27239,7 @@ const onUserFlagged = (callback) => createUserEventSubscriber('user.flagged', ca
|
|
|
26959
27239
|
* })
|
|
26960
27240
|
* ```
|
|
26961
27241
|
*
|
|
26962
|
-
* Fired when a flag has been removed from a {@link Amity.
|
|
27242
|
+
* Fired when a flag has been removed from a {@link Amity.InternalUser}
|
|
26963
27243
|
*
|
|
26964
27244
|
* @param callback The function to call when the event was fired
|
|
26965
27245
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -26976,7 +27256,7 @@ const onUserUnflagged = (callback) => createUserEventSubscriber('user.unflagged'
|
|
|
26976
27256
|
* })
|
|
26977
27257
|
* ```
|
|
26978
27258
|
*
|
|
26979
|
-
* Fired when flags have been cleared for a {@link Amity.
|
|
27259
|
+
* Fired when flags have been cleared for a {@link Amity.InternalUser}
|
|
26980
27260
|
*
|
|
26981
27261
|
* @param callback The function to call when the event was fired
|
|
26982
27262
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -26993,7 +27273,7 @@ const onUserFlagCleared = (callback) => createUserEventSubscriber('user.flagClea
|
|
|
26993
27273
|
* })
|
|
26994
27274
|
* ```
|
|
26995
27275
|
*
|
|
26996
|
-
* Fired when a {@link Amity.
|
|
27276
|
+
* Fired when a {@link Amity.InternalUser} has been fetched
|
|
26997
27277
|
*
|
|
26998
27278
|
* @param callback The function to call when the event was fired
|
|
26999
27279
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -27037,7 +27317,7 @@ const getUser$1 = async (userId) => {
|
|
|
27037
27317
|
const { users } = data;
|
|
27038
27318
|
fireEvent('user.fetched', data);
|
|
27039
27319
|
return {
|
|
27040
|
-
data: users.find(user => user.userId === userId),
|
|
27320
|
+
data: LinkedObject.user(users.find(user => user.userId === userId)),
|
|
27041
27321
|
cachedAt,
|
|
27042
27322
|
};
|
|
27043
27323
|
};
|
|
@@ -27057,7 +27337,15 @@ const getUser$1 = async (userId) => {
|
|
|
27057
27337
|
getUser$1.locally = (userId) => {
|
|
27058
27338
|
const client = getActiveClient();
|
|
27059
27339
|
client.log('user/getUser.locally', userId);
|
|
27060
|
-
|
|
27340
|
+
if (!client.cache)
|
|
27341
|
+
return;
|
|
27342
|
+
const cached = pullFromCache(['user', 'get', userId]);
|
|
27343
|
+
if (!cached)
|
|
27344
|
+
return;
|
|
27345
|
+
return {
|
|
27346
|
+
data: LinkedObject.user(cached.data),
|
|
27347
|
+
cachedAt: cached.cachedAt,
|
|
27348
|
+
};
|
|
27061
27349
|
};
|
|
27062
27350
|
|
|
27063
27351
|
/* begin_public_function
|
|
@@ -27074,7 +27362,7 @@ getUser$1.locally = (userId) => {
|
|
|
27074
27362
|
* });
|
|
27075
27363
|
* ```
|
|
27076
27364
|
*
|
|
27077
|
-
* Observe all mutation on a given {@link Amity.
|
|
27365
|
+
* Observe all mutation on a given {@link Amity.InternalUser}
|
|
27078
27366
|
*
|
|
27079
27367
|
* @param userId the ID of the user to observe
|
|
27080
27368
|
* @param callback the function to call when new data are available
|
|
@@ -27100,11 +27388,11 @@ const getUser = (userId, callback) => {
|
|
|
27100
27388
|
* const { data: users, prevPage, nextPage } = await queryUsers({ displayName: 'foo' })
|
|
27101
27389
|
* ```
|
|
27102
27390
|
*
|
|
27103
|
-
* Queries a paginable list of {@link Amity.
|
|
27391
|
+
* Queries a paginable list of {@link Amity.InternalUser} objects
|
|
27104
27392
|
* Search is performed by displayName such as `.startsWith(search)`
|
|
27105
27393
|
*
|
|
27106
27394
|
* @param query The query parameters
|
|
27107
|
-
* @returns A page of {@link Amity.
|
|
27395
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
27108
27396
|
*
|
|
27109
27397
|
* @category User API
|
|
27110
27398
|
* @async
|
|
@@ -27135,7 +27423,7 @@ const queryUsers = async (query = {}) => {
|
|
|
27135
27423
|
fireEvent('user.fetched', data);
|
|
27136
27424
|
const prevPage = toPage(paging.previous);
|
|
27137
27425
|
const nextPage = toPage(paging.next);
|
|
27138
|
-
return { data: users, cachedAt, prevPage, nextPage };
|
|
27426
|
+
return { data: users.map(user => LinkedObject.user(user)), cachedAt, prevPage, nextPage };
|
|
27139
27427
|
};
|
|
27140
27428
|
/**
|
|
27141
27429
|
* ```js
|
|
@@ -27143,11 +27431,11 @@ const queryUsers = async (query = {}) => {
|
|
|
27143
27431
|
* const { data: users } = queryUsers.locally({ keyword: 'foo' })
|
|
27144
27432
|
* ```
|
|
27145
27433
|
*
|
|
27146
|
-
* Queries a paginable list of {@link Amity.
|
|
27434
|
+
* Queries a paginable list of {@link Amity.InternalUser} objects from cache
|
|
27147
27435
|
* Search is performed by displayName such as `.startsWith(search)`
|
|
27148
27436
|
*
|
|
27149
27437
|
* @param query The query parameters
|
|
27150
|
-
* @returns A page of {@link Amity.
|
|
27438
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
27151
27439
|
*
|
|
27152
27440
|
* @category User API
|
|
27153
27441
|
*/
|
|
@@ -27231,7 +27519,7 @@ const getUsers = (params, callback, config) => {
|
|
|
27231
27519
|
const users = (_a = data.data
|
|
27232
27520
|
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
27233
27521
|
.filter(Boolean)
|
|
27234
|
-
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
27522
|
+
.map(({ data }) => LinkedObject.user(data))) !== null && _a !== void 0 ? _a : [];
|
|
27235
27523
|
callback({
|
|
27236
27524
|
onNextPage: onFetch,
|
|
27237
27525
|
/*
|
|
@@ -27294,7 +27582,7 @@ const getUsers = (params, callback, config) => {
|
|
|
27294
27582
|
* @param callback the function to call when new data are available
|
|
27295
27583
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the user
|
|
27296
27584
|
*
|
|
27297
|
-
* Observe all mutation on a given {@link Amity.
|
|
27585
|
+
* Observe all mutation on a given {@link Amity.InternalUser}
|
|
27298
27586
|
* @category User Observer
|
|
27299
27587
|
*/
|
|
27300
27588
|
const observeUser = (userId, callback) => {
|
|
@@ -27307,11 +27595,12 @@ const observeUser = (userId, callback) => {
|
|
|
27307
27595
|
// filter function
|
|
27308
27596
|
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.userId) !== userId)
|
|
27309
27597
|
return;
|
|
27598
|
+
const newResult = Object.assign(Object.assign({}, result), { data: LinkedObject.user(result.data) });
|
|
27310
27599
|
if (callback instanceof Function)
|
|
27311
|
-
return callback(
|
|
27600
|
+
return callback(newResult);
|
|
27312
27601
|
if (action !== 'onFetch')
|
|
27313
|
-
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action,
|
|
27314
|
-
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback,
|
|
27602
|
+
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, newResult);
|
|
27603
|
+
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, newResult);
|
|
27315
27604
|
};
|
|
27316
27605
|
const disposers = [];
|
|
27317
27606
|
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')));
|
|
@@ -27333,7 +27622,7 @@ const observeUser = (userId, callback) => {
|
|
|
27333
27622
|
* const unsub = UserRepository.searchUserByDisplayName({}, response => merge(users, response.data))
|
|
27334
27623
|
* ```
|
|
27335
27624
|
*
|
|
27336
|
-
* Observe all mutations on a list of {@link Amity.
|
|
27625
|
+
* Observe all mutations on a list of {@link Amity.InternalUser}s
|
|
27337
27626
|
*
|
|
27338
27627
|
* @param params for searching users
|
|
27339
27628
|
* @param callback the function to call when new data are available
|
|
@@ -27347,6 +27636,86 @@ const searchUserByDisplayName = (params, callback, config) => {
|
|
|
27347
27636
|
};
|
|
27348
27637
|
/* end_public_function */
|
|
27349
27638
|
|
|
27639
|
+
const queryReachUser = async ({ postId, limit, token, }) => {
|
|
27640
|
+
const client = getActiveClient();
|
|
27641
|
+
const params = {};
|
|
27642
|
+
if (token) {
|
|
27643
|
+
// If it's not a first query, we can use token to get next user list from previous query.
|
|
27644
|
+
params.token = token;
|
|
27645
|
+
}
|
|
27646
|
+
else {
|
|
27647
|
+
// First query.
|
|
27648
|
+
params.limit = limit;
|
|
27649
|
+
}
|
|
27650
|
+
const response = await client.http.get(`/api/v1/analytics/views/posts/${postId}/users`, {
|
|
27651
|
+
params,
|
|
27652
|
+
});
|
|
27653
|
+
ingestInCache(response.data);
|
|
27654
|
+
return response.data;
|
|
27655
|
+
};
|
|
27656
|
+
|
|
27657
|
+
const getViewedUsers = (params, callback) => {
|
|
27658
|
+
const { log, cache } = getActiveClient();
|
|
27659
|
+
const cacheKey = ['postViewedUsers', 'collection', { postId: params.postId }];
|
|
27660
|
+
if (!cache) {
|
|
27661
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
27662
|
+
}
|
|
27663
|
+
const timestamp = Date.now();
|
|
27664
|
+
log(`getViewedUsers(tmpid: ${timestamp}) > listen`);
|
|
27665
|
+
const { limit: queryLimit, postId } = params;
|
|
27666
|
+
const responder = (snapshot) => {
|
|
27667
|
+
var _a, _b;
|
|
27668
|
+
let users = [];
|
|
27669
|
+
if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.data) {
|
|
27670
|
+
users =
|
|
27671
|
+
snapshot.data
|
|
27672
|
+
.map((userId) => pullFromCache(['user', 'get', userId]))
|
|
27673
|
+
.filter(Boolean)
|
|
27674
|
+
.map(data => data === null || data === void 0 ? void 0 : data.data) || [];
|
|
27675
|
+
}
|
|
27676
|
+
callback({
|
|
27677
|
+
// eslint-disable-next-line no-use-before-define
|
|
27678
|
+
onNextPage: onFetch,
|
|
27679
|
+
data: users,
|
|
27680
|
+
hasNextPage: !!((_b = (_a = snapshot.params) === null || _a === void 0 ? void 0 : _a.page) === null || _b === void 0 ? void 0 : _b.next),
|
|
27681
|
+
loading: snapshot.loading || false,
|
|
27682
|
+
});
|
|
27683
|
+
};
|
|
27684
|
+
const onFetch = (initial = false) => {
|
|
27685
|
+
var _a, _b, _c;
|
|
27686
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27687
|
+
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27688
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27689
|
+
return;
|
|
27690
|
+
const query = createQuery(queryReachUser, {
|
|
27691
|
+
postId,
|
|
27692
|
+
limit: queryLimit || 10,
|
|
27693
|
+
token: !initial ? (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) === null || _c === void 0 ? void 0 : _c.next : undefined,
|
|
27694
|
+
});
|
|
27695
|
+
runQuery(query, result => {
|
|
27696
|
+
var _a, _b, _c, _d, _e;
|
|
27697
|
+
let userIds = (_c = (_b = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : [];
|
|
27698
|
+
if ((_d = result.data) === null || _d === void 0 ? void 0 : _d.users) {
|
|
27699
|
+
userIds = [
|
|
27700
|
+
...new Set([...userIds, ...result.data.users.map(({ userId }) => userId)]),
|
|
27701
|
+
];
|
|
27702
|
+
}
|
|
27703
|
+
const saveToCache = {
|
|
27704
|
+
loading: result.loading,
|
|
27705
|
+
params: { page: (_e = result.data) === null || _e === void 0 ? void 0 : _e.paging },
|
|
27706
|
+
data: userIds || [],
|
|
27707
|
+
};
|
|
27708
|
+
pushToCache(cacheKey, saveToCache);
|
|
27709
|
+
responder(saveToCache);
|
|
27710
|
+
}, queryOptions(COLLECTION_DEFAULT_CACHING_POLICY, CACHE_SHORTEN_LIFESPAN));
|
|
27711
|
+
};
|
|
27712
|
+
onFetch(true);
|
|
27713
|
+
return () => {
|
|
27714
|
+
log(`getViewedUsers(tmpid: ${timestamp}) > dispose`);
|
|
27715
|
+
dropFromCache(cacheKey);
|
|
27716
|
+
};
|
|
27717
|
+
};
|
|
27718
|
+
|
|
27350
27719
|
var index$e = /*#__PURE__*/Object.freeze({
|
|
27351
27720
|
__proto__: null,
|
|
27352
27721
|
Relationship: index$f,
|
|
@@ -27364,7 +27733,8 @@ var index$e = /*#__PURE__*/Object.freeze({
|
|
|
27364
27733
|
getUsers: getUsers,
|
|
27365
27734
|
observeUser: observeUser,
|
|
27366
27735
|
getBlockedUsers: getBlockedUsers$1,
|
|
27367
|
-
searchUserByDisplayName: searchUserByDisplayName
|
|
27736
|
+
searchUserByDisplayName: searchUserByDisplayName,
|
|
27737
|
+
getViewedUsers: getViewedUsers
|
|
27368
27738
|
});
|
|
27369
27739
|
|
|
27370
27740
|
/* begin_public_function
|
|
@@ -28002,8 +28372,9 @@ const getPost$1 = async (postId) => {
|
|
|
28002
28372
|
if (client.cache)
|
|
28003
28373
|
ingestInCache(data, { cachedAt });
|
|
28004
28374
|
const { posts } = data;
|
|
28375
|
+
const result = posts.find(post => post.postId === postId);
|
|
28005
28376
|
return {
|
|
28006
|
-
data:
|
|
28377
|
+
data: LinkedObject.post(result),
|
|
28007
28378
|
cachedAt,
|
|
28008
28379
|
};
|
|
28009
28380
|
};
|
|
@@ -28029,50 +28400,21 @@ getPost$1.locally = (postId) => {
|
|
|
28029
28400
|
if (!cached)
|
|
28030
28401
|
return;
|
|
28031
28402
|
return {
|
|
28032
|
-
data: cached.data,
|
|
28403
|
+
data: LinkedObject.post(cached.data),
|
|
28033
28404
|
cachedAt: cached.cachedAt,
|
|
28034
28405
|
};
|
|
28035
28406
|
};
|
|
28036
28407
|
|
|
28037
|
-
const commentLinkedObject = (comment) => {
|
|
28038
|
-
return Object.assign(Object.assign({}, comment), { get target() {
|
|
28039
|
-
const commentTypes = {
|
|
28040
|
-
type: comment.targetType,
|
|
28041
|
-
};
|
|
28042
|
-
if (comment.targetType === 'user') {
|
|
28043
|
-
return Object.assign(Object.assign({}, commentTypes), { userId: comment.targetId });
|
|
28044
|
-
}
|
|
28045
|
-
if (commentTypes.type === 'content') {
|
|
28046
|
-
return Object.assign(Object.assign({}, commentTypes), { contentId: comment.targetId });
|
|
28047
|
-
}
|
|
28048
|
-
if (commentTypes.type === 'community') {
|
|
28049
|
-
const cacheData = pullFromCache([
|
|
28050
|
-
'communityUsers',
|
|
28051
|
-
'get',
|
|
28052
|
-
`${comment.targetId}#${comment.userId}`,
|
|
28053
|
-
]);
|
|
28054
|
-
return Object.assign(Object.assign({}, commentTypes), { communityId: comment.targetId, creatorMember: cacheData === null || cacheData === void 0 ? void 0 : cacheData.data });
|
|
28055
|
-
}
|
|
28056
|
-
return {
|
|
28057
|
-
type: 'unknown',
|
|
28058
|
-
};
|
|
28059
|
-
} });
|
|
28060
|
-
};
|
|
28061
|
-
|
|
28062
|
-
const LinkedObject = {
|
|
28063
|
-
comment: commentLinkedObject,
|
|
28064
|
-
};
|
|
28065
|
-
|
|
28066
28408
|
/**
|
|
28067
28409
|
* ```js
|
|
28068
28410
|
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
28069
28411
|
* const comment = await CommentRepository.getComment('foobar')
|
|
28070
28412
|
* ```
|
|
28071
28413
|
*
|
|
28072
|
-
* Fetches a {@link Amity.
|
|
28414
|
+
* Fetches a {@link Amity.Comment} object
|
|
28073
28415
|
*
|
|
28074
|
-
* @param commentId the ID of the {@link Amity.
|
|
28075
|
-
* @returns the associated {@link Amity.
|
|
28416
|
+
* @param commentId the ID of the {@link Amity.Comment} to fetch
|
|
28417
|
+
* @returns the associated {@link Amity.Comment} object
|
|
28076
28418
|
*
|
|
28077
28419
|
* @category Comment API
|
|
28078
28420
|
* @async
|
|
@@ -28108,10 +28450,10 @@ const getComment$1 = async (commentId) => {
|
|
|
28108
28450
|
* const comment = getComment.locally('foobar')
|
|
28109
28451
|
* ```
|
|
28110
28452
|
*
|
|
28111
|
-
* Fetches a {@link Amity.
|
|
28453
|
+
* Fetches a {@link Amity.Comment} object
|
|
28112
28454
|
*
|
|
28113
|
-
* @param commentId the ID of the {@link Amity.
|
|
28114
|
-
* @returns the associated {@link Amity.
|
|
28455
|
+
* @param commentId the ID of the {@link Amity.Comment} to fetch
|
|
28456
|
+
* @returns the associated {@link Amity.Comment} object
|
|
28115
28457
|
*
|
|
28116
28458
|
* @category Comment API
|
|
28117
28459
|
*/
|
|
@@ -28124,7 +28466,7 @@ getComment$1.locally = (commentId) => {
|
|
|
28124
28466
|
if (!cached)
|
|
28125
28467
|
return;
|
|
28126
28468
|
return {
|
|
28127
|
-
data: cached.data,
|
|
28469
|
+
data: LinkedObject.comment(cached.data),
|
|
28128
28470
|
cachedAt: cached.cachedAt,
|
|
28129
28471
|
};
|
|
28130
28472
|
};
|
|
@@ -28404,7 +28746,7 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
28404
28746
|
* })
|
|
28405
28747
|
* ```
|
|
28406
28748
|
*
|
|
28407
|
-
* Fired when a {@link Amity.
|
|
28749
|
+
* Fired when a {@link Amity.InternalPost} has been created
|
|
28408
28750
|
*
|
|
28409
28751
|
* @param callback The function to call when the event was fired
|
|
28410
28752
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28421,7 +28763,7 @@ const onPostCreated = (callback) => createPostEventSubscriber('post.created', ca
|
|
|
28421
28763
|
* })
|
|
28422
28764
|
* ```
|
|
28423
28765
|
*
|
|
28424
|
-
* Fired when a {@link Amity.
|
|
28766
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
28425
28767
|
*
|
|
28426
28768
|
* @param callback The function to call when the event was fired
|
|
28427
28769
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28438,7 +28780,7 @@ const onPostUpdated = (callback) => createPostEventSubscriber('post.updated', ca
|
|
|
28438
28780
|
* })
|
|
28439
28781
|
* ```
|
|
28440
28782
|
*
|
|
28441
|
-
* Fired when a {@link Amity.
|
|
28783
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
28442
28784
|
*
|
|
28443
28785
|
* @param callback The function to call when the event was fired
|
|
28444
28786
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28455,7 +28797,7 @@ const onPostDeleted = (callback) => createPostEventSubscriber('post.deleted', ca
|
|
|
28455
28797
|
* })
|
|
28456
28798
|
* ```
|
|
28457
28799
|
*
|
|
28458
|
-
* Fired when a {@link Amity.
|
|
28800
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
28459
28801
|
*
|
|
28460
28802
|
* @param callback The function to call when the event was fired
|
|
28461
28803
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28472,7 +28814,7 @@ const onPostApproved = (callback) => createPostEventSubscriber('post.approved',
|
|
|
28472
28814
|
* })
|
|
28473
28815
|
* ```
|
|
28474
28816
|
*
|
|
28475
|
-
* Fired when a {@link Amity.
|
|
28817
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
28476
28818
|
*
|
|
28477
28819
|
* @param callback The function to call when the event was fired
|
|
28478
28820
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28489,7 +28831,7 @@ const onPostDeclined = (callback) => createPostEventSubscriber('post.declined',
|
|
|
28489
28831
|
* })
|
|
28490
28832
|
* ```
|
|
28491
28833
|
*
|
|
28492
|
-
* Fired when a {@link Amity.
|
|
28834
|
+
* Fired when a {@link Amity.InternalPost} has been flagged
|
|
28493
28835
|
*
|
|
28494
28836
|
* @param callback The function to call when the event was fired
|
|
28495
28837
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28506,7 +28848,7 @@ const onPostFlagged = (callback) => createPostEventSubscriber('post.flagged', ca
|
|
|
28506
28848
|
* })
|
|
28507
28849
|
* ```
|
|
28508
28850
|
*
|
|
28509
|
-
* Fired when a flag has been removed from a {@link Amity.
|
|
28851
|
+
* Fired when a flag has been removed from a {@link Amity.InternalPost}
|
|
28510
28852
|
*
|
|
28511
28853
|
* @param callback The function to call when the event was fired
|
|
28512
28854
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28523,7 +28865,7 @@ const onPostUnflagged = (callback) => createPostEventSubscriber('post.unflagged'
|
|
|
28523
28865
|
* })
|
|
28524
28866
|
* ```
|
|
28525
28867
|
*
|
|
28526
|
-
* Fired when a {@link Amity.
|
|
28868
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
28527
28869
|
*
|
|
28528
28870
|
* @param callback The function to call when the event was fired
|
|
28529
28871
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28555,7 +28897,7 @@ const onPostReactionAdded = (callback) => {
|
|
|
28555
28897
|
* })
|
|
28556
28898
|
* ```
|
|
28557
28899
|
*
|
|
28558
|
-
* Fired when a reaction has been removed from a {@link Amity.
|
|
28900
|
+
* Fired when a reaction has been removed from a {@link Amity.InternalPost}
|
|
28559
28901
|
*
|
|
28560
28902
|
* @param callback The function to call when the event was fired
|
|
28561
28903
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28612,7 +28954,7 @@ const createCommentEventSubscriber = (event, callback) => {
|
|
|
28612
28954
|
* })
|
|
28613
28955
|
* ```
|
|
28614
28956
|
*
|
|
28615
|
-
* Fired when a {@link Amity.
|
|
28957
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
28616
28958
|
*
|
|
28617
28959
|
* @param callback The function to call when the event was fired
|
|
28618
28960
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28629,7 +28971,7 @@ const onCommentCreated = (callback) => createCommentEventSubscriber('comment.cre
|
|
|
28629
28971
|
* })
|
|
28630
28972
|
* ```
|
|
28631
28973
|
*
|
|
28632
|
-
* Fired when a {@link Amity.
|
|
28974
|
+
* Fired when a {@link Amity.InternalComment} has been updated
|
|
28633
28975
|
*
|
|
28634
28976
|
* @param callback The function to call when the event was fired
|
|
28635
28977
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28646,7 +28988,7 @@ const onCommentUpdated = (callback) => createCommentEventSubscriber('comment.upd
|
|
|
28646
28988
|
* })
|
|
28647
28989
|
* ```
|
|
28648
28990
|
*
|
|
28649
|
-
* Fired when a {@link Amity.
|
|
28991
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
28650
28992
|
*
|
|
28651
28993
|
* @param callback The function to call when the event was fired
|
|
28652
28994
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28663,7 +29005,7 @@ const onCommentDeleted = (callback) => createCommentEventSubscriber('comment.del
|
|
|
28663
29005
|
* })
|
|
28664
29006
|
* ```
|
|
28665
29007
|
*
|
|
28666
|
-
* Fired when a {@link Amity.
|
|
29008
|
+
* Fired when a {@link Amity.InternalComment} has been flagged
|
|
28667
29009
|
*
|
|
28668
29010
|
* @param callback The function to call when the event was fired
|
|
28669
29011
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28680,7 +29022,7 @@ const onCommentFlagged = (callback) => createCommentEventSubscriber('comment.fla
|
|
|
28680
29022
|
* })
|
|
28681
29023
|
* ```
|
|
28682
29024
|
*
|
|
28683
|
-
* Fired when a flag has been removed from a {@link Amity.
|
|
29025
|
+
* Fired when a flag has been removed from a {@link Amity.InternalComment}
|
|
28684
29026
|
*
|
|
28685
29027
|
* @param callback The function to call when the event was fired
|
|
28686
29028
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28697,7 +29039,7 @@ const onCommentUnflagged = (callback) => createCommentEventSubscriber('comment.u
|
|
|
28697
29039
|
* })
|
|
28698
29040
|
* ```
|
|
28699
29041
|
*
|
|
28700
|
-
* Fired when a {@link Amity.
|
|
29042
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
28701
29043
|
*
|
|
28702
29044
|
* @param callback The function to call when the event was fired
|
|
28703
29045
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -28733,7 +29075,7 @@ const onCommentReactionAdded = (callback) => {
|
|
|
28733
29075
|
* })
|
|
28734
29076
|
* ```
|
|
28735
29077
|
*
|
|
28736
|
-
* Fired when a reaction has been removed from a {@link Amity.
|
|
29078
|
+
* Fired when a reaction has been removed from a {@link Amity.InternalComment}
|
|
28737
29079
|
*
|
|
28738
29080
|
* @param callback The function to call when the event was fired
|
|
28739
29081
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -29729,10 +30071,10 @@ const markAsDelivered = async (subChannelId, messageId) => {
|
|
|
29729
30071
|
* })
|
|
29730
30072
|
* ```
|
|
29731
30073
|
*
|
|
29732
|
-
* Queries a paginable list of read {@link Amity.
|
|
30074
|
+
* Queries a paginable list of read {@link Amity.InternalUser} by messageId
|
|
29733
30075
|
*
|
|
29734
30076
|
* @param query The query parameters
|
|
29735
|
-
* @returns A page of {@link Amity.
|
|
30077
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
29736
30078
|
*
|
|
29737
30079
|
* @category Message API
|
|
29738
30080
|
* @async
|
|
@@ -29774,10 +30116,10 @@ const getReadUsers = async (query) => {
|
|
|
29774
30116
|
* })
|
|
29775
30117
|
* ```
|
|
29776
30118
|
*
|
|
29777
|
-
* Queries a paginable list of read {@link Amity.
|
|
30119
|
+
* Queries a paginable list of read {@link Amity.InternalUser} objects from cache
|
|
29778
30120
|
*
|
|
29779
30121
|
* @param query The query parameters
|
|
29780
|
-
* @returns A page of {@link Amity.
|
|
30122
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
29781
30123
|
*
|
|
29782
30124
|
* @category Message API
|
|
29783
30125
|
*/
|
|
@@ -29810,10 +30152,10 @@ getReadUsers.locally = (query) => {
|
|
|
29810
30152
|
* })
|
|
29811
30153
|
* ```
|
|
29812
30154
|
*
|
|
29813
|
-
* Queries a paginable list of delivered {@link Amity.
|
|
30155
|
+
* Queries a paginable list of delivered {@link Amity.InternalUser} by messageId
|
|
29814
30156
|
*
|
|
29815
30157
|
* @param query The query parameters
|
|
29816
|
-
* @returns A page of {@link Amity.
|
|
30158
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
29817
30159
|
*
|
|
29818
30160
|
* @category Message API
|
|
29819
30161
|
* @async
|
|
@@ -29854,10 +30196,10 @@ const getDeliveredUsers = async (query) => {
|
|
|
29854
30196
|
* })
|
|
29855
30197
|
* ```
|
|
29856
30198
|
*
|
|
29857
|
-
* Queries a paginable list of delivered {@link Amity.
|
|
30199
|
+
* Queries a paginable list of delivered {@link Amity.InternalUser} objects from cache
|
|
29858
30200
|
*
|
|
29859
30201
|
* @param query The query parameters
|
|
29860
|
-
* @returns A page of {@link Amity.
|
|
30202
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
29861
30203
|
*
|
|
29862
30204
|
* @category Message API
|
|
29863
30205
|
*/
|
|
@@ -30564,7 +30906,7 @@ const getSubChannel = (subChannelId, callback) => {
|
|
|
30564
30906
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
30565
30907
|
if (!subChannel)
|
|
30566
30908
|
return;
|
|
30567
|
-
updateSubChannelCache(subChannel, {
|
|
30909
|
+
updateSubChannelCache(message.subChannelId, subChannel, {
|
|
30568
30910
|
messagePreviewId: message.messageId,
|
|
30569
30911
|
});
|
|
30570
30912
|
callback(message);
|
|
@@ -30831,13 +31173,13 @@ const getSubChannels = (params, callback, config) => {
|
|
|
30831
31173
|
return;
|
|
30832
31174
|
handleMessageCreated(message);
|
|
30833
31175
|
realtimeRouter('onUpdate')(Object.assign(Object.assign({}, cacheData.data), { messagePreviewId: message.messageId, subChannelId: message.subChannelId, lastActivity: message.createdAt }));
|
|
30834
|
-
}), onSubChannelCreated(realtimeRouter('onCreate')), onSubChannelDeleted(realtimeRouter('onDelete')), onSubChannelFetched(realtimeRouter('onFetch')), onSubChannelUpdated((subChannel) => {
|
|
31176
|
+
}), onSubChannelCreated(realtimeRouter('onCreate')), onSubChannelDeleted(realtimeRouter('onDelete')), onSubChannelFetched(realtimeRouter('onFetch')), onSubChannelUpdated(async (subChannel) => {
|
|
30835
31177
|
var _a;
|
|
31178
|
+
const client = getActiveClient();
|
|
31179
|
+
const messagePreviewSetting = await client.getMessagePreviewSetting(false);
|
|
31180
|
+
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
31181
|
+
return false;
|
|
30836
31182
|
const targetSubChannel = (_a = snapshot.data) === null || _a === void 0 ? void 0 : _a.find(async (item) => {
|
|
30837
|
-
const client = getActiveClient();
|
|
30838
|
-
const messagePreviewSetting = await client.getMessagePreviewSetting(false);
|
|
30839
|
-
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
30840
|
-
return false;
|
|
30841
31183
|
const messagePreview = getSubChannelMessagePreview(item.subChannelId);
|
|
30842
31184
|
if ((messagePreview === null || messagePreview === void 0 ? void 0 : messagePreview.subChannelId) === item.subChannelId) {
|
|
30843
31185
|
pushToCache(['messagePreviewSubChannel', 'get', item.subChannelId], Object.assign(Object.assign({}, messagePreview), { subChannelName: subChannel.displayName, subChannelUpdatedAt: subChannel.updatedAt }));
|
|
@@ -30847,6 +31189,7 @@ const getSubChannels = (params, callback, config) => {
|
|
|
30847
31189
|
});
|
|
30848
31190
|
if (!targetSubChannel)
|
|
30849
31191
|
return;
|
|
31192
|
+
return realtimeRouter('onUpdate')(subChannel);
|
|
30850
31193
|
}), convertEventPayload(onSubChannelMarkerFetched, 'feedId', 'subChannel')(realtimeRouter('onUpdate')), onSubChannelMarkerUpdated((subChannelMarkers) => {
|
|
30851
31194
|
var _a;
|
|
30852
31195
|
const subChannelWithMarkerUpdated = (_a = subChannelMarkers
|
|
@@ -32150,12 +32493,12 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
32150
32493
|
* const updated = await CommunityRepository.moderation.addRoles(communityId, ['foo', 'bar'])
|
|
32151
32494
|
* ```
|
|
32152
32495
|
*
|
|
32153
|
-
* Adds a list of {@link Amity.Role} to a list of {@link Amity.
|
|
32496
|
+
* Adds a list of {@link Amity.Role} to a list of {@link Amity.InternalUser} on a {@link Amity.Community}
|
|
32154
32497
|
*
|
|
32155
32498
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
32156
32499
|
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
32157
|
-
* @param userIds Array of IDs of the {@link Amity.
|
|
32158
|
-
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.
|
|
32500
|
+
* @param userIds Array of IDs of the {@link Amity.InternalUser} to perform
|
|
32501
|
+
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.InternalUser} in the {@link Amity.Community}
|
|
32159
32502
|
*
|
|
32160
32503
|
* @category Community API
|
|
32161
32504
|
* @async
|
|
@@ -32182,12 +32525,12 @@ const addRoles = async (communityId, roleIds, userIds) => {
|
|
|
32182
32525
|
* const updated = await CommunityRepository.moderation.removeRoles(communityId, ['foo', 'bar'])
|
|
32183
32526
|
* ```
|
|
32184
32527
|
*
|
|
32185
|
-
* Removes a list of {@link Amity.Role} from a list of {@link Amity.
|
|
32528
|
+
* Removes a list of {@link Amity.Role} from a list of {@link Amity.InternalUser} on a {@link Amity.Community}
|
|
32186
32529
|
*
|
|
32187
32530
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
32188
32531
|
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
32189
|
-
* @param userIds Array of IDs of the {@link Amity.
|
|
32190
|
-
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.
|
|
32532
|
+
* @param userIds Array of IDs of the {@link Amity.InternalUser} to perform
|
|
32533
|
+
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.InternalUser} in the {@link Amity.Community}
|
|
32191
32534
|
*
|
|
32192
32535
|
* @category Community API
|
|
32193
32536
|
* @async
|
|
@@ -32216,7 +32559,7 @@ const removeRoles = async (communityId, roleIds, userIds) => {
|
|
|
32216
32559
|
* ```
|
|
32217
32560
|
*
|
|
32218
32561
|
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
32219
|
-
* @param userIds of the {@link Amity.
|
|
32562
|
+
* @param userIds of the {@link Amity.InternalUser}'s to be banned
|
|
32220
32563
|
* @returns the updated {@link Amity.Membership}'s object
|
|
32221
32564
|
*
|
|
32222
32565
|
* @category Community API
|
|
@@ -32251,7 +32594,7 @@ const banMembers = async (communityId, userIds) => {
|
|
|
32251
32594
|
* ```
|
|
32252
32595
|
*
|
|
32253
32596
|
* @param communityId of {@link Amity.Community} from which the users should be unbanned
|
|
32254
|
-
* @param userIds of the {@link Amity.
|
|
32597
|
+
* @param userIds of the {@link Amity.InternalUser}'s to be unbanned
|
|
32255
32598
|
* @returns the updated {@link Amity.Membership}'s object
|
|
32256
32599
|
*
|
|
32257
32600
|
* @category Community API
|
|
@@ -32292,11 +32635,11 @@ var index$9 = /*#__PURE__*/Object.freeze({
|
|
|
32292
32635
|
* const updated = await CommunityRepository.moderation.addMembers(communityId, ['foo', 'bar'])
|
|
32293
32636
|
* ```
|
|
32294
32637
|
*
|
|
32295
|
-
* Adds a list of {@link Amity.
|
|
32638
|
+
* Adds a list of {@link Amity.InternalUser} to a {@link Amity.Community} to add users to
|
|
32296
32639
|
*
|
|
32297
32640
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
32298
|
-
* @param userIds The list of IDs {@link Amity.
|
|
32299
|
-
* @returns A success boolean if the {@link Amity.
|
|
32641
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to add
|
|
32642
|
+
* @returns A success boolean if the {@link Amity.InternalUser} were added to the {@link Amity.Community}
|
|
32300
32643
|
*
|
|
32301
32644
|
* @category Community API
|
|
32302
32645
|
* @async
|
|
@@ -32323,11 +32666,11 @@ const addMembers = async (communityId, userIds) => {
|
|
|
32323
32666
|
* const updated = await CommunityRepository.moderation.removeMembers(communityId, ['foo', 'bar'])
|
|
32324
32667
|
* ```
|
|
32325
32668
|
*
|
|
32326
|
-
* Removes a list of {@link Amity.
|
|
32669
|
+
* Removes a list of {@link Amity.InternalUser} from a {@link Amity.Community}
|
|
32327
32670
|
*
|
|
32328
32671
|
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
32329
|
-
* @param userIds The list of IDs {@link Amity.
|
|
32330
|
-
* @returns A success boolean if the list of {@link Amity.
|
|
32672
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to remove
|
|
32673
|
+
* @returns A success boolean if the list of {@link Amity.InternalUser} were removed from the {@link Amity.Community}
|
|
32331
32674
|
*
|
|
32332
32675
|
* @category Community API
|
|
32333
32676
|
* @async
|
|
@@ -32394,7 +32737,7 @@ const queryCommunityMembers = async (query) => {
|
|
|
32394
32737
|
* const communityMembers = await queryCommunityMembers(query)
|
|
32395
32738
|
* ```
|
|
32396
32739
|
*
|
|
32397
|
-
* Queries a paginable list of {@link Amity.
|
|
32740
|
+
* Queries a paginable list of {@link Amity.InternalPost} objects from cache
|
|
32398
32741
|
*
|
|
32399
32742
|
* @param query The query parameters
|
|
32400
32743
|
* @returns posts
|
|
@@ -32433,10 +32776,10 @@ queryCommunityMembers.locally = (query) => {
|
|
|
32433
32776
|
*/
|
|
32434
32777
|
const applyFilter = (data, params) => {
|
|
32435
32778
|
let communityMembers = filterByPropIntersection(data, 'roles', params.roles);
|
|
32436
|
-
if (params.
|
|
32779
|
+
if (params.memberships) {
|
|
32437
32780
|
communityMembers = communityMembers.filter(({ communityMembership }) =>
|
|
32438
32781
|
// @ts-ignore
|
|
32439
|
-
params.
|
|
32782
|
+
params.memberships.includes(communityMembership));
|
|
32440
32783
|
}
|
|
32441
32784
|
if (params.search) {
|
|
32442
32785
|
communityMembers = filterBySearchTerm(communityMembers, params.search);
|
|
@@ -32612,7 +32955,7 @@ const getCategory = async (categoryId) => {
|
|
|
32612
32955
|
ingestInCache(data, { cachedAt });
|
|
32613
32956
|
const { categories } = data;
|
|
32614
32957
|
return {
|
|
32615
|
-
data: categories.find(category => category.categoryId === categoryId),
|
|
32958
|
+
data: categoryLinkedObject(categories.find(category => category.categoryId === categoryId)),
|
|
32616
32959
|
cachedAt,
|
|
32617
32960
|
};
|
|
32618
32961
|
};
|
|
@@ -32681,7 +33024,12 @@ const queryCategories = async (query) => {
|
|
|
32681
33024
|
}
|
|
32682
33025
|
const nextPage = toPage(paging.next);
|
|
32683
33026
|
const prevPage = toPage(paging.previous);
|
|
32684
|
-
return {
|
|
33027
|
+
return {
|
|
33028
|
+
data: categories.map(category => LinkedObject.category(category)),
|
|
33029
|
+
cachedAt,
|
|
33030
|
+
prevPage,
|
|
33031
|
+
nextPage,
|
|
33032
|
+
};
|
|
32685
33033
|
};
|
|
32686
33034
|
/**
|
|
32687
33035
|
* ```js
|
|
@@ -32754,7 +33102,7 @@ const getCategories = (params, callback, config) => {
|
|
|
32754
33102
|
let categories = (_a = data.data
|
|
32755
33103
|
.map(categoryId => pullFromCache(['category', 'get', categoryId]))
|
|
32756
33104
|
.filter(Boolean)
|
|
32757
|
-
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
33105
|
+
.map(({ data }) => LinkedObject.category(data))) !== null && _a !== void 0 ? _a : [];
|
|
32758
33106
|
if (!params.includeDeleted) {
|
|
32759
33107
|
categories = filterByPropEquality(categories, 'isDeleted', false);
|
|
32760
33108
|
}
|
|
@@ -32866,7 +33214,7 @@ const queryGlobalFeed = async (query) => {
|
|
|
32866
33214
|
}
|
|
32867
33215
|
const nextPage = toPage(paging.next);
|
|
32868
33216
|
const prevPage = toPage(paging.previous);
|
|
32869
|
-
return { data: posts, cachedAt, prevPage, nextPage };
|
|
33217
|
+
return { data: posts.map(LinkedObject.post), cachedAt, prevPage, nextPage };
|
|
32870
33218
|
};
|
|
32871
33219
|
/* end_public_function */
|
|
32872
33220
|
/**
|
|
@@ -32901,7 +33249,8 @@ queryGlobalFeed.locally = (query) => {
|
|
|
32901
33249
|
const posts = data.posts
|
|
32902
33250
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
32903
33251
|
.filter(Boolean)
|
|
32904
|
-
.map(({ data }) => data)
|
|
33252
|
+
.map(({ data }) => data)
|
|
33253
|
+
.map(LinkedObject.post);
|
|
32905
33254
|
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
32906
33255
|
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
32907
33256
|
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
@@ -32950,7 +33299,7 @@ const getCustomRankingGlobalFeed = async (query) => {
|
|
|
32950
33299
|
}
|
|
32951
33300
|
const nextPage = toPage(paging.next);
|
|
32952
33301
|
const prevPage = toPage(paging.previous);
|
|
32953
|
-
return { data: posts, cachedAt, prevPage, nextPage };
|
|
33302
|
+
return { data: posts.map(LinkedObject.post), cachedAt, prevPage, nextPage };
|
|
32954
33303
|
};
|
|
32955
33304
|
/* end_public_function */
|
|
32956
33305
|
/**
|
|
@@ -32989,7 +33338,7 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
32989
33338
|
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
32990
33339
|
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
32991
33340
|
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
32992
|
-
? { data: posts, cachedAt, prevPage, nextPage }
|
|
33341
|
+
? { data: posts.map(LinkedObject.post), cachedAt, prevPage, nextPage }
|
|
32993
33342
|
: undefined;
|
|
32994
33343
|
};
|
|
32995
33344
|
|
|
@@ -33041,7 +33390,7 @@ const getPostByIds = async (postIds) => {
|
|
|
33041
33390
|
if (client.cache)
|
|
33042
33391
|
ingestInCache(data, { cachedAt });
|
|
33043
33392
|
return {
|
|
33044
|
-
data: data.posts,
|
|
33393
|
+
data: data.posts.map(LinkedObject.post),
|
|
33045
33394
|
cachedAt,
|
|
33046
33395
|
};
|
|
33047
33396
|
};
|
|
@@ -33073,7 +33422,7 @@ getPostByIds.locally = (postIds) => {
|
|
|
33073
33422
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
33074
33423
|
return;
|
|
33075
33424
|
return {
|
|
33076
|
-
data: posts,
|
|
33425
|
+
data: posts.map(LinkedObject.post),
|
|
33077
33426
|
cachedAt: oldest.cachedAt,
|
|
33078
33427
|
};
|
|
33079
33428
|
};
|
|
@@ -33115,7 +33464,7 @@ const createPost = async (bundle) => {
|
|
|
33115
33464
|
ingestInCache(data, { cachedAt });
|
|
33116
33465
|
const { posts } = data;
|
|
33117
33466
|
return {
|
|
33118
|
-
data: posts[0],
|
|
33467
|
+
data: LinkedObject.post(posts[0]),
|
|
33119
33468
|
cachedAt,
|
|
33120
33469
|
};
|
|
33121
33470
|
};
|
|
@@ -33153,7 +33502,7 @@ const updatePost = async (postId, patch) => {
|
|
|
33153
33502
|
fireEvent('post.updated', data);
|
|
33154
33503
|
const { posts } = data;
|
|
33155
33504
|
return {
|
|
33156
|
-
data: posts.find(post => post.postId === postId),
|
|
33505
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
33157
33506
|
cachedAt,
|
|
33158
33507
|
};
|
|
33159
33508
|
};
|
|
@@ -33190,7 +33539,7 @@ const editPost = async (postId, patch) => {
|
|
|
33190
33539
|
fireEvent('post.updated', data);
|
|
33191
33540
|
const { posts } = data;
|
|
33192
33541
|
return {
|
|
33193
|
-
data: posts.find(post => post.postId === postId),
|
|
33542
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
33194
33543
|
cachedAt,
|
|
33195
33544
|
};
|
|
33196
33545
|
};
|
|
@@ -33255,7 +33604,7 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
33255
33604
|
else {
|
|
33256
33605
|
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
33257
33606
|
}
|
|
33258
|
-
return deleted;
|
|
33607
|
+
return LinkedObject.post(deleted);
|
|
33259
33608
|
};
|
|
33260
33609
|
|
|
33261
33610
|
/* begin_public_function
|
|
@@ -33279,7 +33628,7 @@ const softDeletePost = async (postId) => {
|
|
|
33279
33628
|
const client = getActiveClient();
|
|
33280
33629
|
client.log('post/softDeletePost', postId);
|
|
33281
33630
|
const softDeleted = await deletePost(postId, false);
|
|
33282
|
-
return softDeleted;
|
|
33631
|
+
return LinkedObject.post(softDeleted);
|
|
33283
33632
|
};
|
|
33284
33633
|
/* end_public_function */
|
|
33285
33634
|
|
|
@@ -33304,7 +33653,7 @@ const hardDeletePost = async (postId) => {
|
|
|
33304
33653
|
const client = getActiveClient();
|
|
33305
33654
|
client.log('post/hardDeletePost', postId);
|
|
33306
33655
|
const hardDeleted = await deletePost(postId, true);
|
|
33307
|
-
return hardDeleted;
|
|
33656
|
+
return LinkedObject.post(hardDeleted);
|
|
33308
33657
|
};
|
|
33309
33658
|
/* end_public_function */
|
|
33310
33659
|
|
|
@@ -33340,7 +33689,7 @@ const approvePost = async (postId) => {
|
|
|
33340
33689
|
if (client.cache)
|
|
33341
33690
|
ingestInCache(data, { cachedAt });
|
|
33342
33691
|
return {
|
|
33343
|
-
data: data.posts.find(post => post.postId === postId),
|
|
33692
|
+
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
33344
33693
|
cachedAt,
|
|
33345
33694
|
};
|
|
33346
33695
|
};
|
|
@@ -33378,7 +33727,7 @@ const declinePost = async (postId) => {
|
|
|
33378
33727
|
if (client.cache)
|
|
33379
33728
|
ingestInCache(data, { cachedAt });
|
|
33380
33729
|
return {
|
|
33381
|
-
data: payload.posts.find(post => post.postId === postId),
|
|
33730
|
+
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
33382
33731
|
cachedAt,
|
|
33383
33732
|
};
|
|
33384
33733
|
};
|
|
@@ -33468,14 +33817,13 @@ const isPostFlaggedByMe = async (postId) => {
|
|
|
33468
33817
|
* let posts = []
|
|
33469
33818
|
* const unsub = PostRepository.observePosts({
|
|
33470
33819
|
* targetType: Amity.PostTargetType,
|
|
33471
|
-
* targetId: Amity.
|
|
33820
|
+
* targetId: Amity.InternalPost['targetId'],
|
|
33472
33821
|
* }, post => merge(posts, post))
|
|
33473
33822
|
* ```
|
|
33474
33823
|
*
|
|
33475
33824
|
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
33476
33825
|
*
|
|
33477
|
-
* @param
|
|
33478
|
-
* @param targetId the ID of the target
|
|
33826
|
+
* @param params
|
|
33479
33827
|
* @param callback the function to call when new data are available
|
|
33480
33828
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
33481
33829
|
*
|
|
@@ -33491,9 +33839,9 @@ const observePosts = (params, callback) => {
|
|
|
33491
33839
|
if (params.targetId !== post.targetId || params.targetType !== post.targetType)
|
|
33492
33840
|
return;
|
|
33493
33841
|
if (callback instanceof Function)
|
|
33494
|
-
return callback(post);
|
|
33495
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, post);
|
|
33496
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, post);
|
|
33842
|
+
return callback(LinkedObject.post(post));
|
|
33843
|
+
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, LinkedObject.post(post));
|
|
33844
|
+
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, LinkedObject.post(post));
|
|
33497
33845
|
};
|
|
33498
33846
|
disposers.push(onPostCreated(post => router(post, 'onCreate')), onPostUpdated(post => router(post, 'onUpdate')), onPostDeleted(post => router(post, 'onDelete')), onPostApproved(post => router(post, 'onApproved')), onPostDeclined(post => router(post, 'onDeclined')), onPostFlagged(post => router(post, 'onFlagged')), onPostUnflagged(post => router(post, 'onUnflagged')), onPostReactionAdded(post => router(post, 'onReactionAdded')), onPostReactionRemoved(post => router(post, 'onReactionRemoved')));
|
|
33499
33847
|
return () => {
|
|
@@ -33510,7 +33858,7 @@ const observePosts = (params, callback) => {
|
|
|
33510
33858
|
* const dispose = observePost(postId, updated => post = updated)
|
|
33511
33859
|
* ```
|
|
33512
33860
|
*
|
|
33513
|
-
* Observe all
|
|
33861
|
+
* Observe all mutations on a given {@link Amity.Post}
|
|
33514
33862
|
*
|
|
33515
33863
|
* @param postId the ID of the post to observe
|
|
33516
33864
|
* @param callback the function to call when new data are available
|
|
@@ -33535,11 +33883,12 @@ const observePost = (postId, callback, policy = 'cache_then_server') => {
|
|
|
33535
33883
|
var _a;
|
|
33536
33884
|
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.postId) !== postId)
|
|
33537
33885
|
return;
|
|
33538
|
-
router(result, action);
|
|
33886
|
+
router(Object.assign(Object.assign({}, result), { data: result.data && LinkedObject.post(result.data) }), action);
|
|
33539
33887
|
};
|
|
33540
33888
|
const disposers = [];
|
|
33541
33889
|
disposers.push(onPostUpdated(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUpdate')), onPostDeleted(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onDelete')), onPostApproved(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onApproved')), onPostDeclined(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onDeclined')), onPostFlagged(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onFlagged')), onPostUnflagged(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUnflagged')), onPostReactionAdded(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onReactionAdded')), onPostReactionRemoved(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onReactionRemoved')));
|
|
33542
|
-
runQuery(createQuery(getPost$1, postId), result => (result.data || result.error) &&
|
|
33890
|
+
runQuery(createQuery(getPost$1, postId), result => (result.data || result.error) &&
|
|
33891
|
+
router(Object.assign(Object.assign({}, result), { data: result.data && LinkedObject.post(result.data) }), 'onFetch'), queryOptions(policy));
|
|
33543
33892
|
return () => {
|
|
33544
33893
|
log(`observePosts(tmpid: ${timestamp}) > dispose`);
|
|
33545
33894
|
disposers.forEach(fn => fn());
|
|
@@ -33611,7 +33960,7 @@ const queryPosts = async (query) => {
|
|
|
33611
33960
|
* 1. parent post to store text with dataType=text
|
|
33612
33961
|
* 2. child post to store dataTypes post data
|
|
33613
33962
|
*
|
|
33614
|
-
* By default BE queries only parent post
|
|
33963
|
+
* By default, BE queries only parent post
|
|
33615
33964
|
*/
|
|
33616
33965
|
matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length), options: {
|
|
33617
33966
|
token: toToken(page, 'afterbeforeraw'),
|
|
@@ -33631,7 +33980,7 @@ const queryPosts = async (query) => {
|
|
|
33631
33980
|
}
|
|
33632
33981
|
const nextPage = toPageRaw(paging.next);
|
|
33633
33982
|
const prevPage = toPageRaw(paging.previous);
|
|
33634
|
-
return { data: posts, cachedAt, prevPage, nextPage };
|
|
33983
|
+
return { data: posts.map(LinkedObject.post), cachedAt, prevPage, nextPage };
|
|
33635
33984
|
};
|
|
33636
33985
|
|
|
33637
33986
|
/* begin_public_function
|
|
@@ -33650,9 +33999,10 @@ const queryPosts = async (query) => {
|
|
|
33650
33999
|
*
|
|
33651
34000
|
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
33652
34001
|
*
|
|
33653
|
-
* @param
|
|
33654
|
-
* @param
|
|
34002
|
+
* @param params.targetType the type of the target
|
|
34003
|
+
* @param params.targetId the ID of the target
|
|
33655
34004
|
* @param callback the function to call when new data are available
|
|
34005
|
+
* @param config
|
|
33656
34006
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
33657
34007
|
*
|
|
33658
34008
|
* @category Posts Live Collection
|
|
@@ -33678,7 +34028,7 @@ const getPosts = (params, callback, config) => {
|
|
|
33678
34028
|
let posts = (_a = data.data
|
|
33679
34029
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
33680
34030
|
.filter(Boolean)
|
|
33681
|
-
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
34031
|
+
.map(({ data }) => LinkedObject.post(data))) !== null && _a !== void 0 ? _a : [];
|
|
33682
34032
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
33683
34033
|
posts = posts.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
33684
34034
|
if (!params.includeDeleted) {
|
|
@@ -33788,10 +34138,10 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
33788
34138
|
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
33789
34139
|
* ```
|
|
33790
34140
|
*
|
|
33791
|
-
* Fetches a collection of {@link Amity.
|
|
34141
|
+
* Fetches a collection of {@link Amity.Comment} objects
|
|
33792
34142
|
*
|
|
33793
|
-
* @param commentIds the IDs of the {@link Amity.
|
|
33794
|
-
* @returns the associated collection of {@link Amity.
|
|
34143
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
34144
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
33795
34145
|
*
|
|
33796
34146
|
* @category Comment API
|
|
33797
34147
|
* @async
|
|
@@ -33820,7 +34170,7 @@ const getCommentByIds = async (commentIds) => {
|
|
|
33820
34170
|
if (client.cache)
|
|
33821
34171
|
ingestInCache(data, { cachedAt });
|
|
33822
34172
|
return {
|
|
33823
|
-
data: data.comments,
|
|
34173
|
+
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
33824
34174
|
cachedAt,
|
|
33825
34175
|
};
|
|
33826
34176
|
};
|
|
@@ -33831,10 +34181,10 @@ const getCommentByIds = async (commentIds) => {
|
|
|
33831
34181
|
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
33832
34182
|
* ```
|
|
33833
34183
|
*
|
|
33834
|
-
* Fetches a collection of {@link Amity.
|
|
34184
|
+
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
33835
34185
|
*
|
|
33836
|
-
* @param commentIds the IDs of the {@link Amity.
|
|
33837
|
-
* @returns the associated collection of {@link Amity.
|
|
34186
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
34187
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
33838
34188
|
*
|
|
33839
34189
|
* @category Comment API
|
|
33840
34190
|
*/
|
|
@@ -33852,7 +34202,7 @@ getCommentByIds.locally = (commentIds) => {
|
|
|
33852
34202
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
33853
34203
|
return;
|
|
33854
34204
|
return {
|
|
33855
|
-
data: comments,
|
|
34205
|
+
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
33856
34206
|
cachedAt: oldest.cachedAt,
|
|
33857
34207
|
};
|
|
33858
34208
|
};
|
|
@@ -34224,7 +34574,7 @@ const observeComment = (commentId, callback, policy = 'cache_then_server') => {
|
|
|
34224
34574
|
* @param callback the function to call when new data are available
|
|
34225
34575
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
34226
34576
|
*
|
|
34227
|
-
* @category
|
|
34577
|
+
* @category Comment Live Object
|
|
34228
34578
|
*/
|
|
34229
34579
|
const getComment = (commentId, callback) => {
|
|
34230
34580
|
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
@@ -35560,7 +35910,7 @@ const getPlayer = async (parameters) => {
|
|
|
35560
35910
|
hls.loadSource(url);
|
|
35561
35911
|
}
|
|
35562
35912
|
else {
|
|
35563
|
-
const recording = recordings
|
|
35913
|
+
const recording = recordings.find(rec => !!rec.mp4);
|
|
35564
35914
|
if (!recording || !recording.mp4) {
|
|
35565
35915
|
throw new Error('No playable recording available');
|
|
35566
35916
|
}
|