@amityco/ts-sdk 6.35.3-fa3d4ac.0 → 7.0.1-fbbf78f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +6 -6
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/domains/analytics.d.ts +0 -3
- package/dist/@types/domains/analytics.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +9 -33
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +0 -4
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +2 -10
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +0 -11
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +0 -12
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/subChannel.d.ts +0 -4
- package/dist/@types/domains/subChannel.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +1 -5
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/channelRepository/api/deleteChannel.d.ts.map +1 -1
- package/dist/channelRepository/api/index.d.ts +0 -1
- package/dist/channelRepository/api/index.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/getMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/searchMembers.d.ts.map +1 -1
- package/dist/channelRepository/{api → internalApi}/getChannel.d.ts +2 -2
- package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -0
- package/dist/channelRepository/internalApi/getChannelByIds.d.ts +32 -0
- package/dist/channelRepository/internalApi/getChannelByIds.d.ts.map +1 -0
- package/dist/channelRepository/{api → internalApi}/markAsRead.d.ts +0 -3
- package/dist/channelRepository/internalApi/markAsRead.d.ts.map +1 -0
- package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/index.d.ts +0 -2
- package/dist/channelRepository/observers/index.d.ts.map +1 -1
- package/dist/channelRepository/utils/constructChannelDynamicValue.d.ts.map +1 -1
- package/dist/channelRepository/utils/constructChannelObject.d.ts +2 -0
- package/dist/channelRepository/utils/constructChannelObject.d.ts.map +1 -0
- package/dist/channelRepository/utils/getChannelIsMentioned.d.ts +1 -1
- package/dist/channelRepository/utils/getChannelIsMentioned.d.ts.map +1 -1
- package/dist/channelRepository/utils/getSubChannelsUnreadCount.d.ts +1 -1
- package/dist/channelRepository/utils/getSubChannelsUnreadCount.d.ts.map +1 -1
- package/dist/channelRepository/utils/resolveChannels.d.ts.map +1 -1
- package/dist/channelRepository/utils/updateChannelCache.d.ts +1 -1
- package/dist/channelRepository/utils/updateChannelCache.d.ts.map +1 -1
- package/dist/client/observers/index.d.ts +0 -1
- package/dist/client/observers/index.d.ts.map +1 -1
- package/dist/client/utils/endpoints.d.ts +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts +0 -4
- package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
- package/dist/client/utils/subscribeGlobalTopic.d.ts.map +1 -1
- package/dist/commentRepository/observers/index.d.ts +0 -2
- package/dist/commentRepository/observers/index.d.ts.map +1 -1
- package/dist/communityRepository/api/index.d.ts +0 -1
- package/dist/communityRepository/api/index.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersPaginationController.d.ts +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/index.d.ts +0 -1
- package/dist/communityRepository/observers/index.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities.d.ts +1 -1
- package/dist/communityRepository/observers/searchCommunities.d.ts.map +1 -1
- package/dist/communityRepository/utils/communityQueryFilter.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/subscription.d.ts +1 -0
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +2 -35
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts +2 -24
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/fileRepository/api/index.d.ts +0 -3
- package/dist/fileRepository/api/index.d.ts.map +1 -1
- package/dist/fileRepository/index.d.ts +0 -1
- package/dist/fileRepository/index.d.ts.map +1 -1
- package/dist/index.cjs.js +1265 -2692
- package/dist/index.esm.js +1210 -2638
- package/dist/index.umd.js +4 -4
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -5
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +0 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messageRepository/api/createMessage.d.ts.map +1 -1
- package/dist/messageRepository/api/index.d.ts +0 -1
- package/dist/messageRepository/api/index.d.ts.map +1 -1
- package/dist/messageRepository/internalApi/getMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/getMessages.d.ts +0 -1
- package/dist/messageRepository/observers/getMessages/getMessages.d.ts.map +1 -1
- package/dist/messageRepository/observers/index.d.ts +0 -2
- package/dist/messageRepository/observers/index.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/pollRepository/observers/index.d.ts +0 -1
- package/dist/pollRepository/observers/index.d.ts.map +1 -1
- package/dist/postRepository/api/index.d.ts +0 -1
- package/dist/postRepository/api/index.d.ts.map +1 -1
- package/dist/postRepository/observers/index.d.ts +0 -2
- package/dist/postRepository/observers/index.d.ts.map +1 -1
- package/dist/role/api/queryRoles.d.ts +0 -7
- package/dist/role/api/queryRoles.d.ts.map +1 -1
- package/dist/streamRepository/api/index.d.ts +0 -2
- package/dist/streamRepository/api/index.d.ts.map +1 -1
- package/dist/streamRepository/events/onStreamFlagged.d.ts.map +1 -1
- package/dist/streamRepository/internalApi/getStream.d.ts.map +1 -0
- package/dist/subChannelRepository/utils/markReadEngine.d.ts +0 -34
- package/dist/subChannelRepository/utils/markReadEngine.d.ts.map +1 -1
- package/dist/userRepository/internalApi/queryUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/getUsers/UserLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/observers/getUsers/UserPaginationController.d.ts.map +1 -1
- package/dist/userRepository/observers/index.d.ts +0 -2
- package/dist/userRepository/observers/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/index.d.ts +0 -1
- package/dist/userRepository/relationship/block/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/index.d.ts +0 -2
- package/dist/userRepository/relationship/follow/api/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/index.d.ts +0 -3
- package/dist/userRepository/relationship/follow/observers/index.d.ts.map +1 -1
- package/dist/utils/liveObject.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +8 -9
- package/src/@types/domains/analytics.ts +0 -7
- package/src/@types/domains/channel.ts +15 -46
- package/src/@types/domains/client.ts +0 -4
- package/src/@types/domains/community.ts +0 -8
- package/src/@types/domains/feed.ts +0 -11
- package/src/@types/domains/message.ts +0 -12
- package/src/@types/domains/subChannel.ts +0 -4
- package/src/@types/domains/user.ts +0 -4
- package/src/analytic/api/queryReachUser.ts +1 -1
- package/src/channelRepository/api/deleteChannel.ts +3 -2
- package/src/channelRepository/api/getChannelByIds.ts +5 -5
- package/src/channelRepository/api/index.ts +0 -2
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +0 -8
- package/src/channelRepository/channelMembership/observers/getMembers/getMembers.ts +0 -8
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.ts +0 -8
- package/src/channelRepository/channelMembership/observers/searchMembers/searchMembers.ts +0 -8
- package/src/channelRepository/{api → internalApi}/getChannel.ts +4 -4
- package/src/channelRepository/internalApi/getChannelByIds.ts +105 -0
- package/src/channelRepository/{api → internalApi}/markAsRead.ts +0 -3
- package/src/channelRepository/observers/getChannel.ts +36 -15
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +11 -12
- package/src/channelRepository/observers/index.ts +0 -2
- package/src/channelRepository/utils/constructChannelDynamicValue.ts +4 -9
- package/src/channelRepository/utils/constructChannelObject.ts +16 -0
- package/src/channelRepository/utils/getChannelIsMentioned.ts +4 -1
- package/src/channelRepository/utils/getSubChannelsUnreadCount.ts +1 -1
- package/src/channelRepository/utils/resolveChannels.ts +7 -2
- package/src/channelRepository/utils/updateChannelCache.ts +4 -1
- package/src/client/observers/getUserUnread.ts +1 -1
- package/src/client/observers/index.ts +0 -1
- package/src/client/utils/endpoints.ts +1 -1
- package/src/client/utils/markerSyncEngine.ts +0 -9
- package/src/client/utils/subscribeGlobalTopic.ts +3 -0
- package/src/commentRepository/observers/index.ts +0 -2
- package/src/communityRepository/api/index.ts +0 -3
- package/src/communityRepository/api/queryCommunities.ts +1 -2
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.ts +0 -12
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +0 -7
- package/src/communityRepository/communityMembership/observers/getMembers.ts +0 -4
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersPaginationController.ts +1 -1
- package/src/communityRepository/communityMembership/observers/tests/getMembers.test.ts +0 -1
- package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +12 -16
- package/src/communityRepository/observers/getCommunities/CommunitiesPaginationController.ts +0 -1
- package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +0 -4
- package/src/communityRepository/observers/index.ts +0 -2
- package/src/communityRepository/observers/searchCommunities.ts +1 -1
- package/src/communityRepository/observers/tests/getCommunities.test.ts +0 -1
- package/src/communityRepository/utils/communityQueryFilter.ts +1 -8
- package/src/core/events.ts +7 -5
- package/src/core/subscription.ts +6 -0
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +8 -55
- package/src/feedRepository/api/queryGlobalFeed.ts +6 -58
- package/src/feedRepository/api/test/getCustomRankingGlobalFeed.test.ts +1 -1
- package/src/feedRepository/api/test/queryGlobalFeed.test.ts +1 -1
- package/src/fileRepository/api/index.ts +0 -5
- package/src/fileRepository/index.ts +0 -1
- package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +2 -2
- package/src/messageRepository/api/createMessage.ts +5 -1
- package/src/messageRepository/api/index.ts +0 -2
- package/src/messageRepository/api/tests/createMessage.test.ts +6 -1
- package/src/messageRepository/api/tests/deleteMessage.test.ts +5 -1
- package/src/messageRepository/internalApi/getMessage.ts +0 -6
- package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +0 -20
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +0 -10
- package/src/messageRepository/observers/getMessages/getMessages.ts +0 -54
- package/src/messageRepository/observers/index.ts +0 -3
- package/src/messageRepository/utils/prepareMessagePayload.ts +1 -7
- package/src/pollRepository/observers/index.ts +0 -1
- package/src/postRepository/api/index.ts +0 -1
- package/src/postRepository/observers/index.ts +0 -2
- package/src/role/api/queryRoles.ts +1 -13
- package/src/streamRepository/api/deleteStream.ts +1 -1
- package/src/streamRepository/api/index.ts +0 -4
- package/src/streamRepository/api/tests/getStream.test.ts +1 -1
- package/src/streamRepository/events/onStreamFlagged.ts +1 -6
- package/src/streamRepository/events/onStreamRecorded.ts +1 -1
- package/src/streamRepository/events/onStreamStarted.ts +1 -1
- package/src/streamRepository/events/onStreamStopped.ts +1 -1
- package/src/streamRepository/events/onStreamTerminated.ts +1 -1
- package/src/streamRepository/observers/getStreamById.ts +1 -1
- package/src/subChannelRepository/utils/markReadEngine.ts +0 -106
- package/src/userRepository/internalApi/queryUsers.ts +1 -9
- package/src/userRepository/observers/getUsers/UserLiveCollectionController.ts +12 -16
- package/src/userRepository/observers/getUsers/UserPaginationController.ts +1 -2
- package/src/userRepository/observers/index.ts +0 -2
- package/src/userRepository/observers/tests/getUsers.test.ts +1 -43
- package/src/userRepository/relationship/block/index.ts +0 -1
- package/src/userRepository/relationship/follow/api/index.ts +0 -4
- package/src/userRepository/relationship/follow/observers/index.ts +0 -4
- package/src/utils/linkedObject/channelLinkedObject.ts +1 -1
- package/src/utils/liveObject.ts +2 -2
- package/dist/channelRepository/api/getChannel.d.ts.map +0 -1
- package/dist/channelRepository/api/markAsRead.d.ts.map +0 -1
- package/dist/channelRepository/observers/observeChannel.d.ts +0 -18
- package/dist/channelRepository/observers/observeChannel.d.ts.map +0 -1
- package/dist/channelRepository/observers/observeChannels.d.ts +0 -17
- package/dist/channelRepository/observers/observeChannels.d.ts.map +0 -1
- package/dist/client/observers/getTotalUnreadCount.d.ts +0 -20
- package/dist/client/observers/getTotalUnreadCount.d.ts.map +0 -1
- package/dist/client/observers/tests/getTotalUnreadCount.test.d.ts +0 -2
- package/dist/client/observers/tests/getTotalUnreadCount.test.d.ts.map +0 -1
- package/dist/commentRepository/observers/observeComment.d.ts +0 -18
- package/dist/commentRepository/observers/observeComment.d.ts.map +0 -1
- package/dist/commentRepository/observers/observeComments.d.ts +0 -26
- package/dist/commentRepository/observers/observeComments.d.ts.map +0 -1
- package/dist/communityRepository/api/getTopTrendingCommunities.d.ts +0 -35
- package/dist/communityRepository/api/getTopTrendingCommunities.d.ts.map +0 -1
- package/dist/communityRepository/api/test/getTopTrendingCommunities.test.d.ts +0 -2
- package/dist/communityRepository/api/test/getTopTrendingCommunities.test.d.ts.map +0 -1
- package/dist/communityRepository/observers/observeCommunity.d.ts +0 -18
- package/dist/communityRepository/observers/observeCommunity.d.ts.map +0 -1
- package/dist/feedRepository/internalApi/getCustomRankingGlobalFeed.d.ts +0 -8
- package/dist/feedRepository/internalApi/getCustomRankingGlobalFeed.d.ts.map +0 -1
- package/dist/feedRepository/internalApi/index.d.ts +0 -3
- package/dist/feedRepository/internalApi/index.d.ts.map +0 -1
- package/dist/feedRepository/internalApi/queryGlobalFeed.d.ts +0 -9
- package/dist/feedRepository/internalApi/queryGlobalFeed.d.ts.map +0 -1
- package/dist/feedRepository/internalApi/test/getCustomRankingGlobalFeed.test.d.ts +0 -2
- package/dist/feedRepository/internalApi/test/getCustomRankingGlobalFeed.test.d.ts.map +0 -1
- package/dist/feedRepository/internalApi/test/queryGlobalFeed.test.d.ts +0 -2
- package/dist/feedRepository/internalApi/test/queryGlobalFeed.test.d.ts.map +0 -1
- package/dist/fileRepository/api/createFile.d.ts +0 -17
- package/dist/fileRepository/api/createFile.d.ts.map +0 -1
- package/dist/fileRepository/api/createImage.d.ts +0 -17
- package/dist/fileRepository/api/createImage.d.ts.map +0 -1
- package/dist/fileRepository/api/createVideo.d.ts +0 -18
- package/dist/fileRepository/api/createVideo.d.ts.map +0 -1
- package/dist/fileRepository/observers/index.d.ts +0 -2
- package/dist/fileRepository/observers/index.d.ts.map +0 -1
- package/dist/fileRepository/observers/observeFile.d.ts +0 -18
- package/dist/fileRepository/observers/observeFile.d.ts.map +0 -1
- package/dist/messageRepository/api/getMessage.d.ts +0 -32
- package/dist/messageRepository/api/getMessage.d.ts.map +0 -1
- package/dist/messageRepository/api/getMessages.d.ts +0 -32
- package/dist/messageRepository/api/getMessages.d.ts.map +0 -1
- package/dist/messageRepository/observers/observeMessage.d.ts +0 -21
- package/dist/messageRepository/observers/observeMessage.d.ts.map +0 -1
- package/dist/messageRepository/observers/observeMessages.d.ts +0 -23
- package/dist/messageRepository/observers/observeMessages.d.ts.map +0 -1
- package/dist/pollRepository/observers/observePoll.d.ts +0 -18
- package/dist/pollRepository/observers/observePoll.d.ts.map +0 -1
- package/dist/postRepository/api/updatePost.d.ts +0 -24
- package/dist/postRepository/api/updatePost.d.ts.map +0 -1
- package/dist/postRepository/observers/observePost.d.ts +0 -18
- package/dist/postRepository/observers/observePost.d.ts.map +0 -1
- package/dist/postRepository/observers/observePosts.d.ts +0 -34
- package/dist/postRepository/observers/observePosts.d.ts.map +0 -1
- package/dist/streamRepository/api/getStream.d.ts.map +0 -1
- package/dist/streamRepository/api/queryStreams.d.ts +0 -25
- package/dist/streamRepository/api/queryStreams.d.ts.map +0 -1
- package/dist/userRepository/observers/getViewedUsers.d.ts +0 -7
- package/dist/userRepository/observers/getViewedUsers.d.ts.map +0 -1
- package/dist/userRepository/observers/observeUser.d.ts +0 -17
- package/dist/userRepository/observers/observeUser.d.ts.map +0 -1
- package/dist/userRepository/observers/tests/getViewedUsers.test.d.ts +0 -2
- package/dist/userRepository/observers/tests/getViewedUsers.test.d.ts.map +0 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts +0 -2
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts.map +0 -1
- package/dist/userRepository/relationship/block/observers/index.d.ts +0 -2
- package/dist/userRepository/relationship/block/observers/index.d.ts.map +0 -1
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts +0 -19
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts.map +0 -1
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts +0 -19
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts.map +0 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts +0 -18
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts.map +0 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts +0 -18
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts.map +0 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts +0 -18
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts.map +0 -1
- package/src/channelRepository/observers/observeChannel.ts +0 -109
- package/src/channelRepository/observers/observeChannels.ts +0 -74
- package/src/client/observers/getTotalUnreadCount.ts +0 -53
- package/src/client/observers/tests/getTotalUnreadCount.test.ts +0 -101
- package/src/commentRepository/observers/observeComment.ts +0 -102
- package/src/commentRepository/observers/observeComments.ts +0 -77
- package/src/communityRepository/api/getTopTrendingCommunities.ts +0 -97
- package/src/communityRepository/api/test/getTopTrendingCommunities.test.ts +0 -102
- package/src/communityRepository/observers/observeCommunity.ts +0 -103
- package/src/feedRepository/internalApi/getCustomRankingGlobalFeed.ts +0 -87
- package/src/feedRepository/internalApi/index.ts +0 -2
- package/src/feedRepository/internalApi/queryGlobalFeed.ts +0 -95
- package/src/feedRepository/internalApi/test/getCustomRankingGlobalFeed.test.ts +0 -138
- package/src/feedRepository/internalApi/test/queryGlobalFeed.test.ts +0 -130
- package/src/fileRepository/api/createFile.ts +0 -59
- package/src/fileRepository/api/createImage.ts +0 -59
- package/src/fileRepository/api/createVideo.ts +0 -69
- package/src/fileRepository/observers/index.ts +0 -1
- package/src/fileRepository/observers/observeFile.ts +0 -49
- package/src/messageRepository/api/getMessage.ts +0 -102
- package/src/messageRepository/api/getMessages.ts +0 -83
- package/src/messageRepository/observers/observeMessage.ts +0 -94
- package/src/messageRepository/observers/observeMessages.ts +0 -89
- package/src/pollRepository/observers/observePoll.ts +0 -67
- package/src/postRepository/api/updatePost.ts +0 -63
- package/src/postRepository/observers/observePost.ts +0 -115
- package/src/postRepository/observers/observePosts.ts +0 -86
- package/src/streamRepository/api/queryStreams.ts +0 -63
- package/src/userRepository/observers/getViewedUsers.ts +0 -99
- package/src/userRepository/observers/observeUser.ts +0 -71
- package/src/userRepository/observers/tests/getViewedUsers.test.ts +0 -39
- package/src/userRepository/relationship/block/observers/getBlockedUsers.ts +0 -13
- package/src/userRepository/relationship/block/observers/index.ts +0 -1
- package/src/userRepository/relationship/follow/api/acceptFollower.ts +0 -40
- package/src/userRepository/relationship/follow/api/declineFollower.ts +0 -40
- package/src/userRepository/relationship/follow/observers/observeFollowInfo.ts +0 -64
- package/src/userRepository/relationship/follow/observers/observeFollowers.ts +0 -74
- package/src/userRepository/relationship/follow/observers/observeFollowings.ts +0 -74
- /package/dist/streamRepository/{api → internalApi}/getStream.d.ts +0 -0
- /package/src/streamRepository/{api → internalApi}/getStream.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -87,8 +87,8 @@ const PostContentType = Object.freeze({
|
|
|
87
87
|
|
|
88
88
|
function getVersion() {
|
|
89
89
|
try {
|
|
90
|
-
// the string ''
|
|
91
|
-
return '
|
|
90
|
+
// the string ''v7.0.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
91
|
+
return 'v7.0.0-esm';
|
|
92
92
|
}
|
|
93
93
|
catch (error) {
|
|
94
94
|
return '__dev__';
|
|
@@ -1304,9 +1304,6 @@ const WS_EVENTS = [
|
|
|
1304
1304
|
'sessionStateChange',
|
|
1305
1305
|
// for internal use by accessTokenExpiryWatcher
|
|
1306
1306
|
'tokenExpired',
|
|
1307
|
-
'v3.video-streaming.didRecord',
|
|
1308
|
-
'v3.video-streaming.didStart',
|
|
1309
|
-
'v3.video-streaming.didStop',
|
|
1310
1307
|
];
|
|
1311
1308
|
const MQTT_EVENTS = [
|
|
1312
1309
|
'connect',
|
|
@@ -1316,7 +1313,12 @@ const MQTT_EVENTS = [
|
|
|
1316
1313
|
'close',
|
|
1317
1314
|
'end',
|
|
1318
1315
|
'reconnect',
|
|
1319
|
-
'
|
|
1316
|
+
'video-streaming.didStart',
|
|
1317
|
+
'video-streaming.didRecord',
|
|
1318
|
+
'video-streaming.didStop',
|
|
1319
|
+
'video-streaming.didFlag',
|
|
1320
|
+
'video-streaming.didTerminate',
|
|
1321
|
+
// 'user.didGlobalBan' remove due to message event,
|
|
1320
1322
|
];
|
|
1321
1323
|
/** @hidden */
|
|
1322
1324
|
const createEventEmitter = () => {
|
|
@@ -1515,7 +1517,11 @@ function subscribeTopic(topic, callback) {
|
|
|
1515
1517
|
return () => null;
|
|
1516
1518
|
modifyMqttConnection();
|
|
1517
1519
|
return mqtt.subscribe(topic, callback);
|
|
1518
|
-
}
|
|
1520
|
+
}
|
|
1521
|
+
const getLiveStreamTopic = () => {
|
|
1522
|
+
const user = getActiveUser();
|
|
1523
|
+
return `${getNetworkId(user)}/videostreaming`;
|
|
1524
|
+
};
|
|
1519
1525
|
|
|
1520
1526
|
var _a;
|
|
1521
1527
|
/* eslint-disable no-undef */
|
|
@@ -1551,7 +1557,7 @@ const API_REGIONS = {
|
|
|
1551
1557
|
US: 'us',
|
|
1552
1558
|
};
|
|
1553
1559
|
const URLS = {
|
|
1554
|
-
http: 'https://
|
|
1560
|
+
http: 'https://apix.{region}.amity.co',
|
|
1555
1561
|
mqtt: 'wss://sse.{region}.amity.co:443/mqtt',
|
|
1556
1562
|
};
|
|
1557
1563
|
function computeUrl(type, region) {
|
|
@@ -20460,6 +20466,7 @@ const subscribeGlobalTopic = () => {
|
|
|
20460
20466
|
// subscribing to user topic is necessary to handle ban event
|
|
20461
20467
|
subscribeTopic(getUserTopic(getActiveUser())),
|
|
20462
20468
|
subscribeTopic(getMarkerUserFeedTopic()),
|
|
20469
|
+
subscribeTopic(getLiveStreamTopic()),
|
|
20463
20470
|
];
|
|
20464
20471
|
return () => disposers.forEach(fn => fn());
|
|
20465
20472
|
};
|
|
@@ -21972,9 +21979,6 @@ const reactorLinkedObject = (reactor) => {
|
|
|
21972
21979
|
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
21973
21980
|
* const success = await ChannelRepository.markAsRead('channelId')
|
|
21974
21981
|
* ```
|
|
21975
|
-
*
|
|
21976
|
-
* @deprecated Please use the {@link Amity.Channel.markAsRead} method instead
|
|
21977
|
-
*
|
|
21978
21982
|
* Updating all {@link Amity.SubChannel} in specify {@link Amity.Channel} as read
|
|
21979
21983
|
*
|
|
21980
21984
|
* @param channelId the ID of to specify {@link Amity.Channel}
|
|
@@ -22587,7 +22591,7 @@ const prepareMessagePayload = async (payload, event) => {
|
|
|
22587
22591
|
var _a, _b;
|
|
22588
22592
|
const subChannelCache = (_b = (_a = pullFromCache(['subChannel', 'get', messageFeed.messageFeedId])) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {};
|
|
22589
22593
|
// exclude getter properties from existing subChannel cache, update only other properties to existing subChannel cache
|
|
22590
|
-
const _c = convertFromRaw$2(messageFeed), restSubChannel = __rest(_c, ["unreadCount", "
|
|
22594
|
+
const _c = convertFromRaw$2(messageFeed), restSubChannel = __rest(_c, ["unreadCount", "isMentioned"]);
|
|
22591
22595
|
updateSubChannelCache(messageFeed.messageFeedId, subChannelCache, restSubChannel);
|
|
22592
22596
|
});
|
|
22593
22597
|
}
|
|
@@ -22601,15 +22605,12 @@ function convertParams(_a) {
|
|
|
22601
22605
|
return Object.assign({ messageFeedId: subChannelId, mentionedUsers: mentionees, dataType, data }, rest);
|
|
22602
22606
|
}
|
|
22603
22607
|
function convertQueryParams$1(_a) {
|
|
22604
|
-
var { sortBy, subChannelId,
|
|
22608
|
+
var { sortBy, subChannelId, includingTags, excludingTags, includeDeleted, aroundMessageId, limit, type } = _a, rest = __rest(_a, ["sortBy", "subChannelId", "includingTags", "excludingTags", "includeDeleted", "aroundMessageId", "limit", "type"]);
|
|
22605
22609
|
const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
22606
22610
|
sortBy,
|
|
22607
22611
|
limit: limit || COLLECTION_DEFAULT_PAGINATION_LIMIT,
|
|
22608
22612
|
around: aroundMessageId,
|
|
22609
22613
|
} });
|
|
22610
|
-
if (tags) {
|
|
22611
|
-
out.includeTags = tags;
|
|
22612
|
-
}
|
|
22613
22614
|
if (includingTags) {
|
|
22614
22615
|
out.includeTags = includingTags;
|
|
22615
22616
|
}
|
|
@@ -23093,22 +23094,27 @@ const getSubChannelsUnreadCount = (channel, marker) => {
|
|
|
23093
23094
|
};
|
|
23094
23095
|
|
|
23095
23096
|
const constructChannelDynamicValue = (channel) => {
|
|
23096
|
-
|
|
23097
|
-
|
|
23098
|
-
return getSubChannelsUnreadCount(channel);
|
|
23099
|
-
},
|
|
23100
|
-
get hasMentioned() {
|
|
23101
|
-
return getChannelIsMentioned(channel);
|
|
23102
|
-
},
|
|
23097
|
+
const rest = __rest(channel, ["messageCount"]);
|
|
23098
|
+
return shallowClone(rest, {
|
|
23103
23099
|
get isMentioned() {
|
|
23104
|
-
return getChannelIsMentioned(
|
|
23100
|
+
return getChannelIsMentioned(rest);
|
|
23105
23101
|
},
|
|
23106
23102
|
get subChannelsUnreadCount() {
|
|
23107
|
-
return getSubChannelsUnreadCount(
|
|
23103
|
+
return getSubChannelsUnreadCount(rest);
|
|
23108
23104
|
},
|
|
23109
23105
|
});
|
|
23110
23106
|
};
|
|
23111
23107
|
|
|
23108
|
+
const constructChannelObject = (channel) => {
|
|
23109
|
+
/**
|
|
23110
|
+
* convert internal cache data to be public channel data
|
|
23111
|
+
* 1. [getChannelMessagePreviewWithUser] add messagePreview >> Amity.InternalChannel -> Amity.InternalChannel
|
|
23112
|
+
* 2. [constructChannelDynamicValue] construct getter value >> Amity.StaticInternalChannel -> Amity.Channel
|
|
23113
|
+
* 3. [LinkedObject.channel] add markAsRead >> Amity.InternalChannel -> Amity.Channel
|
|
23114
|
+
*/
|
|
23115
|
+
return LinkedObject.channel(constructChannelDynamicValue(getChannelMessagePreviewWithUser(channel)));
|
|
23116
|
+
};
|
|
23117
|
+
|
|
23112
23118
|
/**
|
|
23113
23119
|
* ```js
|
|
23114
23120
|
* import { getChannelByIds } from '@amityco/ts-sdk'
|
|
@@ -23123,7 +23129,7 @@ const constructChannelDynamicValue = (channel) => {
|
|
|
23123
23129
|
* @category Channel API
|
|
23124
23130
|
* @async
|
|
23125
23131
|
*/
|
|
23126
|
-
const getChannelByIds = async (channelIds) => {
|
|
23132
|
+
const getChannelByIds$1 = async (channelIds) => {
|
|
23127
23133
|
const client = getActiveClient();
|
|
23128
23134
|
client.log('channel/getChannelByIds', channelIds);
|
|
23129
23135
|
const encodedChannelIds = channelIds.map(channelId => encodeURIComponent(channelId));
|
|
@@ -23153,7 +23159,7 @@ const getChannelByIds = async (channelIds) => {
|
|
|
23153
23159
|
ingestInCache(data, { cachedAt });
|
|
23154
23160
|
fireEvent('local.channel.fetched', data.channels);
|
|
23155
23161
|
return {
|
|
23156
|
-
data: data.channels.map(channel =>
|
|
23162
|
+
data: data.channels.map(channel => constructChannelObject(channel)),
|
|
23157
23163
|
cachedAt,
|
|
23158
23164
|
};
|
|
23159
23165
|
};
|
|
@@ -23170,7 +23176,7 @@ const getChannelByIds = async (channelIds) => {
|
|
|
23170
23176
|
*
|
|
23171
23177
|
* @category Channel API
|
|
23172
23178
|
*/
|
|
23173
|
-
getChannelByIds.locally = (channelIds) => {
|
|
23179
|
+
getChannelByIds$1.locally = (channelIds) => {
|
|
23174
23180
|
var _a, _b;
|
|
23175
23181
|
const client = getActiveClient();
|
|
23176
23182
|
client.log('channel/getChannelByIds.locally', channelIds);
|
|
@@ -23184,7 +23190,7 @@ getChannelByIds.locally = (channelIds) => {
|
|
|
23184
23190
|
const channels = cached.map(({ data }) => data);
|
|
23185
23191
|
const oldest = (_b = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _b === void 0 ? void 0 : _b[0];
|
|
23186
23192
|
return {
|
|
23187
|
-
data: channels.map(channel =>
|
|
23193
|
+
data: channels.map(channel => constructChannelObject(channel)),
|
|
23188
23194
|
cachedAt: oldest.cachedAt,
|
|
23189
23195
|
};
|
|
23190
23196
|
};
|
|
@@ -23242,20 +23248,6 @@ const setIntervalTask = (handler, timeout) => {
|
|
|
23242
23248
|
return () => clearInterval(timer);
|
|
23243
23249
|
};
|
|
23244
23250
|
|
|
23245
|
-
const onOnline = (callback) => {
|
|
23246
|
-
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
23247
|
-
window.addEventListener('online', callback);
|
|
23248
|
-
return () => window.removeEventListener('online', callback);
|
|
23249
|
-
}
|
|
23250
|
-
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
23251
|
-
document.addEventListener('online', callback);
|
|
23252
|
-
return () => document.removeEventListener('online', callback);
|
|
23253
|
-
}
|
|
23254
|
-
// Handle unsupported environment
|
|
23255
|
-
console.error('Unsupported environment');
|
|
23256
|
-
return () => console.error('Unsupported environment');
|
|
23257
|
-
};
|
|
23258
|
-
|
|
23259
23251
|
/**
|
|
23260
23252
|
* ```js
|
|
23261
23253
|
* import { SubChannel } from '@amityco/ts-sdk'
|
|
@@ -23288,73 +23280,8 @@ const readingAPI = async (messageFeedIds) => {
|
|
|
23288
23280
|
return true;
|
|
23289
23281
|
};
|
|
23290
23282
|
|
|
23291
|
-
/**
|
|
23292
|
-
* ```js
|
|
23293
|
-
* import { SubChannel } from '@amityco/ts-sdk'
|
|
23294
|
-
* const success = await SubChannel('foo')
|
|
23295
|
-
* ```
|
|
23296
|
-
*
|
|
23297
|
-
* Mark all messages as read and start reading message inside channel
|
|
23298
|
-
*
|
|
23299
|
-
* @param messageFeedId - Sub channel ID to start reading.
|
|
23300
|
-
* @return A success boolean if reading of the sub channel had begun.
|
|
23301
|
-
*
|
|
23302
|
-
* @category Channel API
|
|
23303
|
-
* @async
|
|
23304
|
-
* @private
|
|
23305
|
-
*/
|
|
23306
|
-
const startReadingAPI = async (messageFeedId) => {
|
|
23307
|
-
const client = getActiveClient();
|
|
23308
|
-
client.log('subChannel/startReadingAPI', messageFeedId);
|
|
23309
|
-
const { data: payload } = await client.http.post(`/api/v1/markers/message-feeds/${messageFeedId}/start-reading`);
|
|
23310
|
-
const { userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload, feedMarkers, userMarkers, } = payload;
|
|
23311
|
-
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
23312
|
-
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
23313
|
-
const cachedAt = client.cache && Date.now();
|
|
23314
|
-
if (client.cache)
|
|
23315
|
-
ingestInCache({ userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
23316
|
-
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
23317
|
-
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
23318
|
-
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
23319
|
-
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
23320
|
-
return true;
|
|
23321
|
-
};
|
|
23322
|
-
|
|
23323
|
-
/**
|
|
23324
|
-
* ```js
|
|
23325
|
-
* import { stopReading } from '@amityco/ts-sdk'
|
|
23326
|
-
* const success = await stopReading('foo')
|
|
23327
|
-
* ```
|
|
23328
|
-
*
|
|
23329
|
-
* Mark all messages as read and stop reading message inside channel
|
|
23330
|
-
*
|
|
23331
|
-
* @param messageFeedId - The sub channel ID to stop reading.
|
|
23332
|
-
* @return A success boolean if reading of the sub channel had begun.
|
|
23333
|
-
*
|
|
23334
|
-
* @category Channel API
|
|
23335
|
-
* @async
|
|
23336
|
-
* @private
|
|
23337
|
-
*/
|
|
23338
|
-
const stopReadingAPI = async (messageFeedId) => {
|
|
23339
|
-
const client = getActiveClient();
|
|
23340
|
-
client.log('channel/stopReadingAPI', messageFeedId);
|
|
23341
|
-
const { data: payload } = await client.http.post(`/api/v1/markers/message-feeds/${messageFeedId}/stop-reading`);
|
|
23342
|
-
const { userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload, feedMarkers, userMarkers, } = payload;
|
|
23343
|
-
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
23344
|
-
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
23345
|
-
const cachedAt = client.cache && Date.now();
|
|
23346
|
-
if (client.cache)
|
|
23347
|
-
ingestInCache({ userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
23348
|
-
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
23349
|
-
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
23350
|
-
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
23351
|
-
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
23352
|
-
return true;
|
|
23353
|
-
};
|
|
23354
|
-
|
|
23355
23283
|
const START_READING_INTERVAL_TIME = 30000;
|
|
23356
23284
|
let isSyncRunning$1 = false;
|
|
23357
|
-
let disposers$2 = [];
|
|
23358
23285
|
/**
|
|
23359
23286
|
* map contains subChannelId and isReading flag to determine which subChannel is on reading state
|
|
23360
23287
|
*/
|
|
@@ -23398,91 +23325,6 @@ const markReadEngineOnLoginHandler = () => {
|
|
|
23398
23325
|
stopIntervalTask();
|
|
23399
23326
|
};
|
|
23400
23327
|
};
|
|
23401
|
-
const getParentChannelId$1 = async (subChannelId) => {
|
|
23402
|
-
const cached = getSubChannel$1.locally(subChannelId);
|
|
23403
|
-
if (cached) {
|
|
23404
|
-
return cached.data.channelId;
|
|
23405
|
-
}
|
|
23406
|
-
const { data } = await getSubChannel$1(subChannelId);
|
|
23407
|
-
return data.channelId;
|
|
23408
|
-
};
|
|
23409
|
-
const registerEventListeners$1 = () => {
|
|
23410
|
-
if (disposers$2.length > 0) {
|
|
23411
|
-
return;
|
|
23412
|
-
}
|
|
23413
|
-
disposers$2.push(onOnline(() => {
|
|
23414
|
-
// Start reading the reading subChannel again when resume from offline state
|
|
23415
|
-
startReadingFromReadingList();
|
|
23416
|
-
}));
|
|
23417
|
-
};
|
|
23418
|
-
const registerTopicSubscribers$1 = async (subChannelId) => {
|
|
23419
|
-
const channelId = await getParentChannelId$1(subChannelId);
|
|
23420
|
-
const markedMessageTopic = getMarkedMessageTopic({ channelId, subChannelId });
|
|
23421
|
-
disposers$2.push(subscribeTopic(markedMessageTopic));
|
|
23422
|
-
};
|
|
23423
|
-
const disposeAll = () => {
|
|
23424
|
-
disposers$2.forEach(fn => fn());
|
|
23425
|
-
disposers$2 = [];
|
|
23426
|
-
};
|
|
23427
|
-
/* begin_public_function
|
|
23428
|
-
id: subchannel.start_reading
|
|
23429
|
-
*/
|
|
23430
|
-
/**
|
|
23431
|
-
* @deprecated Use {@link startMessageReceiptSync} instead.
|
|
23432
|
-
* ```js
|
|
23433
|
-
* import { startReading } from '@amityco/ts-sdk'
|
|
23434
|
-
* const success = await startReading('foo')
|
|
23435
|
-
* ```
|
|
23436
|
-
*
|
|
23437
|
-
* Set local reading state of channel to `true` and then call mark all
|
|
23438
|
-
* messages as read API.
|
|
23439
|
-
*
|
|
23440
|
-
* @param subChannelId - The sub channel ID to start reading.
|
|
23441
|
-
* @return A success boolean if reading of the sub channel had begun.
|
|
23442
|
-
*
|
|
23443
|
-
* @category Channel API
|
|
23444
|
-
* @async
|
|
23445
|
-
*/
|
|
23446
|
-
const startReading = async (subChannelId) => {
|
|
23447
|
-
isReadingMap[subChannelId] = true;
|
|
23448
|
-
if (disposers$2.length === 0) {
|
|
23449
|
-
registerEventListeners$1();
|
|
23450
|
-
registerTopicSubscribers$1(subChannelId);
|
|
23451
|
-
}
|
|
23452
|
-
try {
|
|
23453
|
-
return await startReadingAPI(subChannelId);
|
|
23454
|
-
}
|
|
23455
|
-
catch (e) {
|
|
23456
|
-
isReadingMap[subChannelId] = false;
|
|
23457
|
-
return false;
|
|
23458
|
-
}
|
|
23459
|
-
};
|
|
23460
|
-
/* end_public_function */
|
|
23461
|
-
/* begin_public_function
|
|
23462
|
-
id: subchannel.stop_reading
|
|
23463
|
-
*/
|
|
23464
|
-
/**
|
|
23465
|
-
* @deprecated Use {@link stopMessageReceiptSync} instead.
|
|
23466
|
-
* ```js
|
|
23467
|
-
* import { stopReading } from '@amityco/ts-sdk'
|
|
23468
|
-
* const success = await stopReading('foo')
|
|
23469
|
-
* ```
|
|
23470
|
-
*
|
|
23471
|
-
* Set local reading state of channel to `false` and then call mark all
|
|
23472
|
-
* messages as unread API.
|
|
23473
|
-
*
|
|
23474
|
-
* @param subChannelId - The sub channel ID to stop reading.
|
|
23475
|
-
* @return A success boolean if reading of the sub channel had begun.
|
|
23476
|
-
*
|
|
23477
|
-
* @category Channel API
|
|
23478
|
-
* @async
|
|
23479
|
-
*/
|
|
23480
|
-
const stopReading = (subChannelId) => {
|
|
23481
|
-
isReadingMap[subChannelId] = false;
|
|
23482
|
-
disposeAll();
|
|
23483
|
-
return stopReadingAPI(subChannelId);
|
|
23484
|
-
};
|
|
23485
|
-
/* end_public_function */
|
|
23486
23328
|
setIntervalTask(async () => {
|
|
23487
23329
|
if (!isSyncRunning$1)
|
|
23488
23330
|
return;
|
|
@@ -23637,7 +23479,7 @@ const initializeMessagePreviewSetting = async () => {
|
|
|
23637
23479
|
* 2. channel and subChannel which isDelete = true
|
|
23638
23480
|
*/
|
|
23639
23481
|
if (channelWithIsDeletedTrue.length !== 0)
|
|
23640
|
-
await getChannelByIds(channelWithIsDeletedTrue);
|
|
23482
|
+
await getChannelByIds$1(channelWithIsDeletedTrue);
|
|
23641
23483
|
if (subChannelWithIsDeletedTrue.length !== 0)
|
|
23642
23484
|
await getSubChannels$1(subChannelWithIsDeletedTrue);
|
|
23643
23485
|
}
|
|
@@ -24035,6 +23877,20 @@ var readReceiptSyncEngineOnLoginHandler = () => {
|
|
|
24035
23877
|
};
|
|
24036
23878
|
};
|
|
24037
23879
|
|
|
23880
|
+
const onOnline = (callback) => {
|
|
23881
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
23882
|
+
window.addEventListener('online', callback);
|
|
23883
|
+
return () => window.removeEventListener('online', callback);
|
|
23884
|
+
}
|
|
23885
|
+
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
23886
|
+
document.addEventListener('online', callback);
|
|
23887
|
+
return () => document.removeEventListener('online', callback);
|
|
23888
|
+
}
|
|
23889
|
+
// Handle unsupported environment
|
|
23890
|
+
console.error('Unsupported environment');
|
|
23891
|
+
return () => console.error('Unsupported environment');
|
|
23892
|
+
};
|
|
23893
|
+
|
|
24038
23894
|
const onOffline = (callback) => {
|
|
24039
23895
|
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
24040
23896
|
window.addEventListener('offline', callback);
|
|
@@ -24049,8 +23905,90 @@ const onOffline = (callback) => {
|
|
|
24049
23905
|
return () => console.error('Unsupported environment');
|
|
24050
23906
|
};
|
|
24051
23907
|
|
|
23908
|
+
/**
|
|
23909
|
+
* ```js
|
|
23910
|
+
* import { getChannelByIds } from '@amityco/ts-sdk'
|
|
23911
|
+
* const channels = await getChannelByIds(['foo', 'bar'])
|
|
23912
|
+
* ```
|
|
23913
|
+
*
|
|
23914
|
+
* Fetches a collection of {@link Amity.Channel} objects
|
|
23915
|
+
*
|
|
23916
|
+
* @param channelIds the IDs of the {@link Amity.Channel} to fetch
|
|
23917
|
+
* @returns the associated collection of {@link Amity.Channel} objects
|
|
23918
|
+
*
|
|
23919
|
+
* @category Channel API
|
|
23920
|
+
* @async
|
|
23921
|
+
*/
|
|
23922
|
+
const getChannelByIds = async (channelIds) => {
|
|
23923
|
+
const client = getActiveClient();
|
|
23924
|
+
client.log('channel/getChannelByIds', channelIds);
|
|
23925
|
+
const encodedChannelIds = channelIds.map(channelId => encodeURIComponent(channelId));
|
|
23926
|
+
let payload;
|
|
23927
|
+
try {
|
|
23928
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23929
|
+
const response = await client.http.get(`/api/v3/channels/list`, {
|
|
23930
|
+
params: { channelIds: encodedChannelIds },
|
|
23931
|
+
});
|
|
23932
|
+
payload = response.data;
|
|
23933
|
+
}
|
|
23934
|
+
catch (error) {
|
|
23935
|
+
channelIds.forEach(channelId => {
|
|
23936
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23937
|
+
// NOTE: use channelPublicId as tombstone cache key since we cannot get the channelPrivateId that come along with channel data from server
|
|
23938
|
+
pushToTombstone('channel', channelId);
|
|
23939
|
+
}
|
|
23940
|
+
});
|
|
23941
|
+
throw error;
|
|
23942
|
+
}
|
|
23943
|
+
const data = await prepareChannelPayload(payload);
|
|
23944
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
23945
|
+
await prepareUnreadCountInfo(payload);
|
|
23946
|
+
}
|
|
23947
|
+
const cachedAt = client.cache && Date.now();
|
|
23948
|
+
if (client.cache)
|
|
23949
|
+
ingestInCache(data, { cachedAt });
|
|
23950
|
+
fireEvent('local.channel.fetched', data.channels);
|
|
23951
|
+
return {
|
|
23952
|
+
data: data.channels,
|
|
23953
|
+
cachedAt,
|
|
23954
|
+
};
|
|
23955
|
+
};
|
|
23956
|
+
/**
|
|
23957
|
+
* ```js
|
|
23958
|
+
* import { getChannelByIds } from '@amityco/ts-sdk'
|
|
23959
|
+
* const channels = getChannelByIds.locally(['foo', 'bar']) ?? []
|
|
23960
|
+
* ```
|
|
23961
|
+
*
|
|
23962
|
+
* Fetches a collection of {@link Amity.Channel} objects from cache
|
|
23963
|
+
*
|
|
23964
|
+
* @param channelIds the IDs of the {@link Amity.Channel} to fetch
|
|
23965
|
+
* @returns the associated collection of {@link Amity.Channel} objects
|
|
23966
|
+
*
|
|
23967
|
+
* @category Channel API
|
|
23968
|
+
*/
|
|
23969
|
+
getChannelByIds.locally = (channelIds) => {
|
|
23970
|
+
var _a, _b;
|
|
23971
|
+
const client = getActiveClient();
|
|
23972
|
+
client.log('channel/getChannelByIds.locally', channelIds);
|
|
23973
|
+
if (!client.cache)
|
|
23974
|
+
return;
|
|
23975
|
+
const cached = (_a = queryCache(['channel', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
|
|
23976
|
+
return channelIds.includes(data.channelPublicId);
|
|
23977
|
+
});
|
|
23978
|
+
if (!cached || (cached === null || cached === void 0 ? void 0 : cached.length) < channelIds.length)
|
|
23979
|
+
return;
|
|
23980
|
+
const channels = cached.map(({ data }) => data);
|
|
23981
|
+
const oldest = (_b = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _b === void 0 ? void 0 : _b[0];
|
|
23982
|
+
return {
|
|
23983
|
+
data: channels,
|
|
23984
|
+
cachedAt: oldest.cachedAt,
|
|
23985
|
+
};
|
|
23986
|
+
};
|
|
23987
|
+
|
|
24052
23988
|
const resolveChannels = async (channelIds) => {
|
|
24053
|
-
|
|
23989
|
+
var _a, _b, _c;
|
|
23990
|
+
await getChannelByIds(channelIds);
|
|
23991
|
+
const channels = (_c = (_b = (_a = queryCache(['channel', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => data.channelPublicId && channelIds.includes(data.channelPublicId))) === null || _b === void 0 ? void 0 : _b.map(({ data }) => data)) !== null && _c !== void 0 ? _c : [];
|
|
24054
23992
|
fireEvent('local.channel.resolved', channels);
|
|
24055
23993
|
};
|
|
24056
23994
|
|
|
@@ -25178,13 +25116,6 @@ const stopUnreadSync = () => {
|
|
|
25178
25116
|
setMarkerSyncEvents([]);
|
|
25179
25117
|
unRegisterEventListeners();
|
|
25180
25118
|
};
|
|
25181
|
-
/**
|
|
25182
|
-
* @deprecated Please use `startUnreadSync` instead
|
|
25183
|
-
*/
|
|
25184
|
-
const stopUnreadSyncing = () => {
|
|
25185
|
-
console.warn('`stopUnreadSyncing` has been deprecated, please use `stopUnreadSync` instead');
|
|
25186
|
-
return stopUnreadSync();
|
|
25187
|
-
};
|
|
25188
25119
|
setIntervalTask(async () => {
|
|
25189
25120
|
if (!isSyncRunning)
|
|
25190
25121
|
return;
|
|
@@ -25882,100 +25813,6 @@ const removeFunctionProperties = (obj) => {
|
|
|
25882
25813
|
return Object.fromEntries(entries);
|
|
25883
25814
|
};
|
|
25884
25815
|
|
|
25885
|
-
/**
|
|
25886
|
-
* @deprecated This function is deprecated
|
|
25887
|
-
*/
|
|
25888
|
-
const liveObject = (id, callback, key, fetcher, eventHandlers, options) => {
|
|
25889
|
-
const { forceDispatch, callbackDataSelector, callbackFilter } = Object.assign({ forceDispatch: false, callbackDataSelector: (data) => data }, options);
|
|
25890
|
-
const { cache } = getActiveClient();
|
|
25891
|
-
if (!cache) {
|
|
25892
|
-
console.log(LIVE_OBJECT_ENABLE_CACHE_MESSAGE);
|
|
25893
|
-
}
|
|
25894
|
-
let model;
|
|
25895
|
-
let isUnsyncedModel = false; // for messages
|
|
25896
|
-
const disposers = [];
|
|
25897
|
-
const dispatcher = (data) => {
|
|
25898
|
-
const { data: newModel } = data, rest = __rest(data, ["data"]);
|
|
25899
|
-
if (!callbackFilter || callbackFilter(newModel, model)) {
|
|
25900
|
-
callback(Object.assign({ data: callbackDataSelector(newModel) }, rest));
|
|
25901
|
-
}
|
|
25902
|
-
// resolve all getter on data model to a static value to avoid comparison problems
|
|
25903
|
-
model = convertGetterPropsToStatic(newModel);
|
|
25904
|
-
};
|
|
25905
|
-
const realtimeRouter = (eventModel, forceDispatch = false) => {
|
|
25906
|
-
if (id !== eventModel[key]) {
|
|
25907
|
-
return;
|
|
25908
|
-
}
|
|
25909
|
-
if (model) {
|
|
25910
|
-
if (!forceDispatch && isEqual(model, eventModel)) {
|
|
25911
|
-
return;
|
|
25912
|
-
}
|
|
25913
|
-
}
|
|
25914
|
-
dispatcher({ loading: false, data: eventModel, origin: 'event' });
|
|
25915
|
-
};
|
|
25916
|
-
const onFetch = () => {
|
|
25917
|
-
// TODO: Ihis `@ts-ignore` is bring back to fix the build and it needs to be removed later
|
|
25918
|
-
// @ts-ignore
|
|
25919
|
-
const query = createQuery(fetcher, id, true);
|
|
25920
|
-
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
25921
|
-
if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
|
|
25922
|
-
dispatcher({
|
|
25923
|
-
// @ts-ignore
|
|
25924
|
-
data,
|
|
25925
|
-
origin,
|
|
25926
|
-
loading: false,
|
|
25927
|
-
error: new ASCApiError(UNSYNCED_OBJECT_CACHED_AT_MESSAGE, 800800 /* Amity.ClientError.DISALOOW_UNSYNCED_OBJECT */, "error" /* Amity.ErrorLevel.ERROR */),
|
|
25928
|
-
});
|
|
25929
|
-
isUnsyncedModel = true;
|
|
25930
|
-
disposers.forEach(fn => fn());
|
|
25931
|
-
}
|
|
25932
|
-
else if (!isUnsyncedModel) {
|
|
25933
|
-
// @ts-ignore
|
|
25934
|
-
dispatcher({ loading, data, origin, error });
|
|
25935
|
-
}
|
|
25936
|
-
if (error) {
|
|
25937
|
-
disposers.forEach(fn => fn());
|
|
25938
|
-
}
|
|
25939
|
-
});
|
|
25940
|
-
};
|
|
25941
|
-
disposers.push(...eventHandlers.map(fn => fn(eventModel => realtimeRouter(eventModel, forceDispatch))));
|
|
25942
|
-
onFetch();
|
|
25943
|
-
return () => {
|
|
25944
|
-
disposers.forEach(fn => fn());
|
|
25945
|
-
};
|
|
25946
|
-
};
|
|
25947
|
-
|
|
25948
|
-
/**
|
|
25949
|
-
* @deprecated Please use unreadCount from `getUserUnread` instead.
|
|
25950
|
-
*
|
|
25951
|
-
* ```js
|
|
25952
|
-
* import { getTotalUnreadCount } from '@amityco/ts-sdk';
|
|
25953
|
-
*
|
|
25954
|
-
* const unsubscribe = getTotalUnreadCount(response => {
|
|
25955
|
-
* totalUnreadCount = response.data;
|
|
25956
|
-
* });
|
|
25957
|
-
* ```
|
|
25958
|
-
*
|
|
25959
|
-
* Observe current user's unread count from {@link Amity.UserMarker}
|
|
25960
|
-
*
|
|
25961
|
-
* @param callback the function to call when new data are available
|
|
25962
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the events
|
|
25963
|
-
*
|
|
25964
|
-
* @category Message Live Object
|
|
25965
|
-
*/
|
|
25966
|
-
const getTotalUnreadCount = (callback) => {
|
|
25967
|
-
const { _id: userId } = getActiveUser();
|
|
25968
|
-
if (!userId)
|
|
25969
|
-
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
25970
|
-
const callbackDataSelector = (data) => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.unreadCount) !== null && _a !== void 0 ? _a : 0; };
|
|
25971
|
-
return liveObject(userId, callback, 'userId', async () => {
|
|
25972
|
-
const { data: userMarker, cachedAt } = await getUserMarker();
|
|
25973
|
-
return { data: userMarker, cachedAt };
|
|
25974
|
-
}, [onUserMarkerFetchedLegacy], {
|
|
25975
|
-
callbackDataSelector,
|
|
25976
|
-
});
|
|
25977
|
-
};
|
|
25978
|
-
|
|
25979
25816
|
/**
|
|
25980
25817
|
*
|
|
25981
25818
|
* ```js
|
|
@@ -26017,7 +25854,7 @@ const getUserUnread = (callback) => {
|
|
|
26017
25854
|
model = callbackModel ? convertGetterPropsToStatic(callbackModel) : callbackModel;
|
|
26018
25855
|
callback({
|
|
26019
25856
|
data: callbackModel
|
|
26020
|
-
? Object.assign(Object.assign({}, callbackModel), {
|
|
25857
|
+
? Object.assign(Object.assign({}, callbackModel), { isMentioned: callbackModel.isMentioned }) : callbackModel,
|
|
26021
25858
|
loading: data.loading,
|
|
26022
25859
|
error: data.error,
|
|
26023
25860
|
});
|
|
@@ -26105,7 +25942,6 @@ var index$l = /*#__PURE__*/Object.freeze({
|
|
|
26105
25942
|
onClientBanned: onClientBanned,
|
|
26106
25943
|
onSessionStateChange: onSessionStateChange,
|
|
26107
25944
|
onNetworkActivities: onNetworkActivities,
|
|
26108
|
-
getTotalUnreadCount: getTotalUnreadCount,
|
|
26109
25945
|
getUserUnread: getUserUnread,
|
|
26110
25946
|
getMarkerSyncEvents: getMarkerSyncEvents,
|
|
26111
25947
|
setMarkerSyncEvents: setMarkerSyncEvents,
|
|
@@ -26114,7 +25950,6 @@ var index$l = /*#__PURE__*/Object.freeze({
|
|
|
26114
25950
|
startMarkerSync: startMarkerSync,
|
|
26115
25951
|
startUnreadSync: startUnreadSync,
|
|
26116
25952
|
stopUnreadSync: stopUnreadSync,
|
|
26117
|
-
stopUnreadSyncing: stopUnreadSyncing,
|
|
26118
25953
|
getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
|
|
26119
25954
|
});
|
|
26120
25955
|
|
|
@@ -26199,311 +26034,134 @@ const unBlockUser = async (userId) => {
|
|
|
26199
26034
|
};
|
|
26200
26035
|
/* end_public_function */
|
|
26201
26036
|
|
|
26202
|
-
|
|
26203
|
-
|
|
26204
|
-
|
|
26205
|
-
this.queryParams = queryParams;
|
|
26206
|
-
this.http = http;
|
|
26207
|
-
}
|
|
26208
|
-
loadFirstPage() {
|
|
26209
|
-
return this.onFetch("first" /* Amity.LiveCollectionPageDirection.FIRST */);
|
|
26210
|
-
}
|
|
26211
|
-
loadNextPage() {
|
|
26212
|
-
return this.onFetch("next" /* Amity.LiveCollectionPageDirection.NEXT */);
|
|
26213
|
-
}
|
|
26214
|
-
loadPreviousPage() {
|
|
26215
|
-
return this.onFetch("prev" /* Amity.LiveCollectionPageDirection.PREV */);
|
|
26216
|
-
}
|
|
26217
|
-
async onFetch(direction = "first" /* Amity.LiveCollectionPageDirection.FIRST */) {
|
|
26218
|
-
var _a, _b, _c, _d;
|
|
26219
|
-
if (direction === 'prev' && !this.previousToken)
|
|
26220
|
-
return;
|
|
26221
|
-
if (direction === 'next' && !this.nextToken)
|
|
26222
|
-
return;
|
|
26223
|
-
let token;
|
|
26224
|
-
if (direction === 'prev')
|
|
26225
|
-
token = this.previousToken;
|
|
26226
|
-
if (direction === 'next')
|
|
26227
|
-
token = this.nextToken;
|
|
26228
|
-
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
26229
|
-
if (direction === 'first') {
|
|
26230
|
-
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
26231
|
-
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
26232
|
-
}
|
|
26233
|
-
if (direction === 'prev')
|
|
26234
|
-
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
26235
|
-
if (direction === 'next')
|
|
26236
|
-
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
26237
|
-
return queryResponse;
|
|
26238
|
-
}
|
|
26239
|
-
getNextToken() {
|
|
26240
|
-
return this.nextToken;
|
|
26241
|
-
}
|
|
26242
|
-
getPrevToken() {
|
|
26243
|
-
return this.previousToken;
|
|
26244
|
-
}
|
|
26245
|
-
}
|
|
26246
|
-
|
|
26247
|
-
class BlockedUserPaginationController extends PaginationController {
|
|
26248
|
-
async getRequest(queryParams, token) {
|
|
26249
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
26250
|
-
const options = token ? { token } : { limit };
|
|
26251
|
-
const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
|
|
26252
|
-
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
26253
|
-
});
|
|
26254
|
-
return queryResponse;
|
|
26255
|
-
}
|
|
26256
|
-
}
|
|
26257
|
-
|
|
26258
|
-
class QueryStreamController {
|
|
26259
|
-
constructor(query, cacheKey) {
|
|
26260
|
-
this.query = query;
|
|
26261
|
-
this.cacheKey = cacheKey;
|
|
26262
|
-
}
|
|
26263
|
-
}
|
|
26264
|
-
|
|
26265
|
-
var EnumFollowActions;
|
|
26266
|
-
(function (EnumFollowActions) {
|
|
26267
|
-
EnumFollowActions["OnRequested"] = "onRequested";
|
|
26268
|
-
EnumFollowActions["OnAccepted"] = "onAccepted";
|
|
26269
|
-
EnumFollowActions["OnDeclined"] = "onDeclined";
|
|
26270
|
-
EnumFollowActions["OnCanceled"] = "onCanceled";
|
|
26271
|
-
EnumFollowActions["OnFollowed"] = "onFollowed";
|
|
26272
|
-
EnumFollowActions["OnUnfollowed"] = "onUnfollowed";
|
|
26273
|
-
EnumFollowActions["OnDeleted"] = "onDeleted";
|
|
26274
|
-
EnumFollowActions["OnUserDeleted"] = "onUserDeleted";
|
|
26275
|
-
})(EnumFollowActions || (EnumFollowActions = {}));
|
|
26276
|
-
|
|
26277
|
-
class BlockedUserQueryStreamController extends QueryStreamController {
|
|
26278
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
26279
|
-
super(query, cacheKey);
|
|
26280
|
-
this.notifyChange = notifyChange;
|
|
26281
|
-
this.preparePayload = preparePayload;
|
|
26282
|
-
}
|
|
26283
|
-
async saveToMainDB(response) {
|
|
26284
|
-
const processedPayload = await this.preparePayload(response);
|
|
26285
|
-
const client = getActiveClient();
|
|
26286
|
-
const cachedAt = client.cache && Date.now();
|
|
26287
|
-
if (client.cache) {
|
|
26288
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
26289
|
-
}
|
|
26290
|
-
}
|
|
26291
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
26292
|
-
var _a, _b;
|
|
26293
|
-
if (refresh) {
|
|
26294
|
-
pushToCache(this.cacheKey, {
|
|
26295
|
-
data: response.users.map(getResolver('user')),
|
|
26296
|
-
});
|
|
26297
|
-
}
|
|
26298
|
-
else {
|
|
26299
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26300
|
-
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26301
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
|
|
26302
|
-
}
|
|
26303
|
-
}
|
|
26304
|
-
reactor(action) {
|
|
26305
|
-
return (targetUser) => {
|
|
26306
|
-
var _a;
|
|
26307
|
-
if (action === EnumFollowActions.OnFollowed) {
|
|
26308
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26309
|
-
const updatedCollection = collection === null || collection === void 0 ? void 0 : collection.data.filter(id => id !== targetUser.userId);
|
|
26310
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: updatedCollection }));
|
|
26311
|
-
}
|
|
26312
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
26313
|
-
};
|
|
26314
|
-
}
|
|
26315
|
-
subscribeRTE(createSubscriber) {
|
|
26316
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
26317
|
-
}
|
|
26318
|
-
}
|
|
26319
|
-
|
|
26320
|
-
class PaginationNoPageController {
|
|
26321
|
-
constructor(queryParams) {
|
|
26322
|
-
const { http } = getActiveClient();
|
|
26323
|
-
this.queryParams = queryParams;
|
|
26324
|
-
this.http = http;
|
|
26325
|
-
}
|
|
26326
|
-
async onFetch() {
|
|
26327
|
-
const queryResponse = await this.getRequest(this.queryParams);
|
|
26328
|
-
return queryResponse;
|
|
26329
|
-
}
|
|
26330
|
-
}
|
|
26331
|
-
|
|
26332
|
-
class LiveCollectionController {
|
|
26333
|
-
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
26334
|
-
this.paginationController = paginationController;
|
|
26335
|
-
this.queryStreamId = queryStreamId;
|
|
26336
|
-
this.cacheKey = cacheKey;
|
|
26337
|
-
this.callback = callback;
|
|
26338
|
-
}
|
|
26339
|
-
async refresh() {
|
|
26340
|
-
try {
|
|
26341
|
-
let result;
|
|
26342
|
-
if (this.paginationController instanceof PaginationNoPageController) {
|
|
26343
|
-
result = await this.paginationController.onFetch();
|
|
26344
|
-
}
|
|
26345
|
-
else {
|
|
26346
|
-
result = await this.paginationController.loadFirstPage();
|
|
26347
|
-
}
|
|
26348
|
-
if (!result)
|
|
26349
|
-
return;
|
|
26350
|
-
await this.persistModel(result);
|
|
26351
|
-
this.persistQueryStream({
|
|
26352
|
-
response: result,
|
|
26353
|
-
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
26354
|
-
refresh: true,
|
|
26355
|
-
});
|
|
26356
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
26357
|
-
}
|
|
26358
|
-
catch (e) {
|
|
26359
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
26360
|
-
}
|
|
26361
|
-
}
|
|
26362
|
-
loadPage({ initial = false, direction = "next" /* Amity.LiveCollectionPageDirection.NEXT */, }) {
|
|
26363
|
-
this.setup();
|
|
26364
|
-
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
26365
|
-
if (initial) {
|
|
26366
|
-
this.refresh();
|
|
26367
|
-
}
|
|
26368
|
-
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
26369
|
-
this.loadPrevPage();
|
|
26370
|
-
}
|
|
26371
|
-
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
26372
|
-
this.loadNextPage();
|
|
26373
|
-
}
|
|
26374
|
-
}
|
|
26375
|
-
async loadNextPage() {
|
|
26376
|
-
try {
|
|
26377
|
-
if (this.paginationController instanceof PaginationNoPageController)
|
|
26378
|
-
return;
|
|
26379
|
-
const result = await this.paginationController.loadNextPage();
|
|
26380
|
-
if (!result)
|
|
26381
|
-
return;
|
|
26382
|
-
await this.persistModel(result);
|
|
26383
|
-
this.persistQueryStream({
|
|
26384
|
-
response: result,
|
|
26385
|
-
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
26386
|
-
});
|
|
26387
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
26388
|
-
}
|
|
26389
|
-
catch (e) {
|
|
26390
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
26391
|
-
}
|
|
26392
|
-
}
|
|
26393
|
-
async loadPrevPage() {
|
|
26394
|
-
try {
|
|
26395
|
-
if (this.paginationController instanceof PaginationNoPageController)
|
|
26396
|
-
return;
|
|
26397
|
-
const result = await this.paginationController.loadPreviousPage();
|
|
26398
|
-
if (!result)
|
|
26399
|
-
return;
|
|
26400
|
-
await this.persistModel(result);
|
|
26401
|
-
this.persistQueryStream({
|
|
26402
|
-
response: result,
|
|
26403
|
-
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
26404
|
-
});
|
|
26405
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
26406
|
-
}
|
|
26407
|
-
catch (e) {
|
|
26408
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
26409
|
-
}
|
|
26410
|
-
}
|
|
26411
|
-
shouldNotify(data) {
|
|
26412
|
-
const newData = data.map(convertGetterPropsToStatic).map(removeFunctionProperties);
|
|
26413
|
-
if (isEqual(this.snapshot, newData))
|
|
26414
|
-
return false;
|
|
26415
|
-
this.snapshot = newData;
|
|
26416
|
-
return true;
|
|
26417
|
-
}
|
|
26418
|
-
getCacheKey() {
|
|
26419
|
-
return this.cacheKey;
|
|
26420
|
-
}
|
|
26421
|
-
}
|
|
26422
|
-
|
|
26423
|
-
function prepareBlockedUserPayload(response) {
|
|
26424
|
-
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
26425
|
-
return Object.assign(Object.assign({}, rest), { follows: follows.map(follow => {
|
|
26426
|
-
const followUser = users.find(user => user.userId === follow.from);
|
|
26427
|
-
return Object.assign(Object.assign({}, follow), { user: convertRawUserToInternalUser(followUser) });
|
|
26428
|
-
}), users: users.map(convertRawUserToInternalUser) });
|
|
26429
|
-
}
|
|
26430
|
-
|
|
26037
|
+
/* begin_public_function
|
|
26038
|
+
id: user.relationship.follow
|
|
26039
|
+
*/
|
|
26431
26040
|
/**
|
|
26432
26041
|
* ```js
|
|
26433
|
-
* import {
|
|
26434
|
-
* const
|
|
26435
|
-
* // ...
|
|
26436
|
-
* })
|
|
26042
|
+
* import { follow } from '@amityco/ts-sdk'
|
|
26043
|
+
* const status = await follow('foobar')
|
|
26437
26044
|
* ```
|
|
26438
26045
|
*
|
|
26439
|
-
*
|
|
26046
|
+
* Follow the user
|
|
26440
26047
|
*
|
|
26441
|
-
* @param
|
|
26442
|
-
* @returns
|
|
26048
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26049
|
+
* @returns the status {@link Amity.FollowStatus}
|
|
26443
26050
|
*
|
|
26444
|
-
* @category
|
|
26051
|
+
* @category Follow API
|
|
26052
|
+
* @async
|
|
26445
26053
|
*/
|
|
26446
|
-
const
|
|
26054
|
+
const follow = async (userId) => {
|
|
26055
|
+
const client = getActiveClient();
|
|
26056
|
+
client.log('follow/follow', userId);
|
|
26057
|
+
const { data } = await client.http.post(`/api/v4/me/following/${userId}`);
|
|
26058
|
+
const cachedAt = client.cache && Date.now();
|
|
26059
|
+
if (client.cache) {
|
|
26060
|
+
ingestInCache(data, { cachedAt });
|
|
26061
|
+
}
|
|
26062
|
+
const payload = prepareFollowStatusPayload(data);
|
|
26063
|
+
if (data.follows[0].status === 'accepted') {
|
|
26064
|
+
fireEvent('local.follow.created', payload);
|
|
26065
|
+
}
|
|
26066
|
+
else {
|
|
26067
|
+
fireEvent('local.follow.requested', payload);
|
|
26068
|
+
}
|
|
26069
|
+
return {
|
|
26070
|
+
data: data.follows[0],
|
|
26071
|
+
cachedAt,
|
|
26072
|
+
};
|
|
26073
|
+
};
|
|
26074
|
+
/* end_public_function */
|
|
26447
26075
|
|
|
26076
|
+
/* begin_public_function
|
|
26077
|
+
id: user.relationship.unfollow
|
|
26078
|
+
*/
|
|
26448
26079
|
/**
|
|
26449
26080
|
* ```js
|
|
26450
|
-
* import {
|
|
26451
|
-
*
|
|
26452
|
-
* // ...
|
|
26453
|
-
* })
|
|
26081
|
+
* import { unfollow } from '@amityco/ts-sdk'
|
|
26082
|
+
* await unfollow('foobar')
|
|
26454
26083
|
* ```
|
|
26455
26084
|
*
|
|
26456
|
-
*
|
|
26085
|
+
* Cancel the follow request or unfollow the user
|
|
26457
26086
|
*
|
|
26458
|
-
* @param
|
|
26459
|
-
* @returns
|
|
26087
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26088
|
+
* @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
|
|
26460
26089
|
*
|
|
26461
|
-
* @category
|
|
26090
|
+
* @category Follow API
|
|
26091
|
+
* @async
|
|
26462
26092
|
*/
|
|
26463
|
-
const
|
|
26093
|
+
const unfollow = async (userId) => {
|
|
26094
|
+
const client = getActiveClient();
|
|
26095
|
+
client.log('follow/unfollow', userId);
|
|
26096
|
+
const { data } = await client.http.delete(`/api/v4/me/following/${userId}`);
|
|
26097
|
+
if (client.cache) {
|
|
26098
|
+
ingestInCache(data);
|
|
26099
|
+
}
|
|
26100
|
+
const payload = prepareFollowStatusPayload(data);
|
|
26101
|
+
fireEvent('local.follow.unfollowed', payload);
|
|
26102
|
+
return true;
|
|
26103
|
+
};
|
|
26104
|
+
/* end_public_function */
|
|
26464
26105
|
|
|
26106
|
+
/* begin_public_function
|
|
26107
|
+
id: user.relationship.accept_follow
|
|
26108
|
+
*/
|
|
26465
26109
|
/**
|
|
26466
26110
|
* ```js
|
|
26467
|
-
* import {
|
|
26468
|
-
*
|
|
26469
|
-
* // ...
|
|
26470
|
-
* })
|
|
26111
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
26112
|
+
* await UserRepository.Relationship.acceptMyFollower('foobar')
|
|
26471
26113
|
* ```
|
|
26472
26114
|
*
|
|
26473
|
-
*
|
|
26115
|
+
* Accept the follow request
|
|
26474
26116
|
*
|
|
26475
|
-
* @param
|
|
26476
|
-
* @returns
|
|
26117
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
26118
|
+
* @returns A success boolean if the follow request was accepted
|
|
26477
26119
|
*
|
|
26478
|
-
* @category
|
|
26120
|
+
* @category Follow API
|
|
26121
|
+
* @async
|
|
26479
26122
|
*/
|
|
26480
|
-
const
|
|
26123
|
+
const acceptMyFollower = async (userId) => {
|
|
26124
|
+
const client = getActiveClient();
|
|
26125
|
+
client.log('follow/acceptMyFollower', userId);
|
|
26126
|
+
const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
|
|
26127
|
+
if (client.cache) {
|
|
26128
|
+
ingestInCache(data);
|
|
26129
|
+
}
|
|
26130
|
+
const payload = prepareFollowStatusPayload(data);
|
|
26131
|
+
fireEvent('local.follow.accepted', payload);
|
|
26132
|
+
return true;
|
|
26133
|
+
};
|
|
26134
|
+
/* end_public_function */
|
|
26481
26135
|
|
|
26136
|
+
/* begin_public_function
|
|
26137
|
+
id: user.relationship.decline_follow
|
|
26138
|
+
*/
|
|
26482
26139
|
/**
|
|
26483
26140
|
* ```js
|
|
26484
|
-
* import {
|
|
26485
|
-
*
|
|
26486
|
-
* // ...
|
|
26487
|
-
* })
|
|
26141
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
26142
|
+
* await UserRepository.Relationship.declineMyFollower('foobar')
|
|
26488
26143
|
* ```
|
|
26489
26144
|
*
|
|
26490
|
-
*
|
|
26145
|
+
* Decline the follow request or delete the follower
|
|
26491
26146
|
*
|
|
26492
|
-
* @param
|
|
26493
|
-
* @returns
|
|
26147
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
26148
|
+
* @returns A success boolean if the follow request was decline
|
|
26494
26149
|
*
|
|
26495
|
-
* @category
|
|
26150
|
+
* @category Follow API
|
|
26151
|
+
* @async
|
|
26496
26152
|
*/
|
|
26497
|
-
const
|
|
26498
|
-
|
|
26499
|
-
|
|
26500
|
-
|
|
26501
|
-
|
|
26502
|
-
|
|
26503
|
-
|
|
26504
|
-
|
|
26505
|
-
|
|
26506
|
-
|
|
26153
|
+
const declineMyFollower = async (userId) => {
|
|
26154
|
+
const client = getActiveClient();
|
|
26155
|
+
client.log('follow/declineMyFollower', userId);
|
|
26156
|
+
const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
|
|
26157
|
+
if (client.cache) {
|
|
26158
|
+
ingestInCache(data);
|
|
26159
|
+
}
|
|
26160
|
+
const payload = prepareFollowStatusPayload(data);
|
|
26161
|
+
fireEvent('local.follow.requestDeclined', payload);
|
|
26162
|
+
return true;
|
|
26163
|
+
};
|
|
26164
|
+
/* end_public_function */
|
|
26507
26165
|
|
|
26508
26166
|
const createFollowEventSubscriber = (event, callback) => {
|
|
26509
26167
|
const client = getActiveClient();
|
|
@@ -26767,446 +26425,50 @@ const onLocalFollowRequestAccepted = (callback) => createLocalFollowEventSubscri
|
|
|
26767
26425
|
|
|
26768
26426
|
const onLocalFollowRequestDeclined = (callback) => createLocalFollowEventSubscriber('local.follow.requestDeclined', callback);
|
|
26769
26427
|
|
|
26770
|
-
|
|
26771
|
-
|
|
26772
|
-
|
|
26773
|
-
|
|
26774
|
-
|
|
26775
|
-
const client = getActiveClient();
|
|
26776
|
-
const { objectSyncMap } = client;
|
|
26777
|
-
/*
|
|
26778
|
-
* NOTE: For objects created locally (optimistic creation), the SDK stores them with their local ID as the cache key, which is used throughout the entire SDK session (in-memory) for syncing updates.
|
|
26779
|
-
* If the payload or response only contains the remote ID of the same object, the SDK will look up the corresponding local ID to retrieve the object.
|
|
26780
|
-
*/
|
|
26781
|
-
const resolvedId = isLocalId(sourceModel[sourceModelProp])
|
|
26782
|
-
? sourceModel[sourceModelProp]
|
|
26783
|
-
: (_a = objectSyncMap.get(sourceModel[sourceModelProp])) !== null && _a !== void 0 ? _a : sourceModel[sourceModelProp];
|
|
26784
|
-
const model = (_b = pullFromCache([
|
|
26785
|
-
destinationDomain,
|
|
26786
|
-
'get',
|
|
26787
|
-
`${resolvedId}`,
|
|
26788
|
-
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
26789
|
-
if (!model)
|
|
26790
|
-
return;
|
|
26791
|
-
return callback(model);
|
|
26792
|
-
});
|
|
26793
|
-
|
|
26794
|
-
class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
26795
|
-
constructor(query, callback) {
|
|
26796
|
-
const queryStreamId = hash(query);
|
|
26797
|
-
const cacheKey = ['blockedUsers', 'collection', queryStreamId];
|
|
26798
|
-
const paginationController = new BlockedUserPaginationController(query);
|
|
26799
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
26800
|
-
this.query = query;
|
|
26801
|
-
this.queryStreamController = new BlockedUserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareBlockedUserPayload);
|
|
26802
|
-
this.callback = callback.bind(this);
|
|
26803
|
-
this.loadPage({ initial: true });
|
|
26804
|
-
}
|
|
26805
|
-
setup() {
|
|
26806
|
-
var _a;
|
|
26807
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26808
|
-
if (!collection) {
|
|
26809
|
-
pushToCache(this.cacheKey, {
|
|
26810
|
-
data: [],
|
|
26811
|
-
params: {},
|
|
26812
|
-
});
|
|
26813
|
-
}
|
|
26428
|
+
class PaginationController {
|
|
26429
|
+
constructor(queryParams) {
|
|
26430
|
+
const { http } = getActiveClient();
|
|
26431
|
+
this.queryParams = queryParams;
|
|
26432
|
+
this.http = http;
|
|
26814
26433
|
}
|
|
26815
|
-
|
|
26816
|
-
|
|
26434
|
+
loadFirstPage() {
|
|
26435
|
+
return this.onFetch("first" /* Amity.LiveCollectionPageDirection.FIRST */);
|
|
26817
26436
|
}
|
|
26818
|
-
|
|
26819
|
-
this.
|
|
26437
|
+
loadNextPage() {
|
|
26438
|
+
return this.onFetch("next" /* Amity.LiveCollectionPageDirection.NEXT */);
|
|
26820
26439
|
}
|
|
26821
|
-
|
|
26822
|
-
return this.
|
|
26823
|
-
{
|
|
26824
|
-
fn: onUserDeleted$2,
|
|
26825
|
-
action: EnumUserActions.OnUserDeleted,
|
|
26826
|
-
},
|
|
26827
|
-
// In the case of unblocking a user, we need to subscribe to the follow events
|
|
26828
|
-
{
|
|
26829
|
-
fn: convertEventPayload(onLocalUserFollowed, 'to', 'user'),
|
|
26830
|
-
action: EnumFollowActions.OnFollowed,
|
|
26831
|
-
},
|
|
26832
|
-
{
|
|
26833
|
-
fn: convertEventPayload(onUserFollowed, 'to', 'user'),
|
|
26834
|
-
action: EnumFollowActions.OnFollowed,
|
|
26835
|
-
},
|
|
26836
|
-
]);
|
|
26440
|
+
loadPreviousPage() {
|
|
26441
|
+
return this.onFetch("prev" /* Amity.LiveCollectionPageDirection.PREV */);
|
|
26837
26442
|
}
|
|
26838
|
-
|
|
26839
|
-
var _a, _b;
|
|
26840
|
-
|
|
26841
|
-
if (!collection)
|
|
26443
|
+
async onFetch(direction = "first" /* Amity.LiveCollectionPageDirection.FIRST */) {
|
|
26444
|
+
var _a, _b, _c, _d;
|
|
26445
|
+
if (direction === 'prev' && !this.previousToken)
|
|
26842
26446
|
return;
|
|
26843
|
-
|
|
26844
|
-
.map(id => pullFromCache(['user', 'get', id]))
|
|
26845
|
-
.filter(isNonNullable)
|
|
26846
|
-
.map(({ data }) => data)
|
|
26847
|
-
.map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
|
|
26848
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
26447
|
+
if (direction === 'next' && !this.nextToken)
|
|
26849
26448
|
return;
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
26855
|
-
|
|
26856
|
-
|
|
26857
|
-
|
|
26858
|
-
|
|
26859
|
-
|
|
26860
|
-
|
|
26861
|
-
|
|
26862
|
-
|
|
26863
|
-
|
|
26864
|
-
|
|
26865
|
-
|
|
26866
|
-
/* begin_public_function
|
|
26867
|
-
id: user.get_blocked_users
|
|
26868
|
-
*/
|
|
26869
|
-
/**
|
|
26870
|
-
* ```js
|
|
26871
|
-
* import { UserRepository } from '@amityco/ts-sdk'
|
|
26872
|
-
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
26873
|
-
* ```
|
|
26874
|
-
*
|
|
26875
|
-
* Blocks a {@link Amity.InternalUser}
|
|
26876
|
-
*
|
|
26877
|
-
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
26878
|
-
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
26879
|
-
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
26880
|
-
*
|
|
26881
|
-
* @category Post API
|
|
26882
|
-
* @async
|
|
26883
|
-
*/
|
|
26884
|
-
const getBlockedUsers$1 = (params, callback, config) => {
|
|
26885
|
-
const { log, cache } = getActiveClient();
|
|
26886
|
-
if (!cache) {
|
|
26887
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
26888
|
-
}
|
|
26889
|
-
const timestamp = Date.now();
|
|
26890
|
-
log(`getBlockedUsers(tmpid: ${timestamp}) > listen`);
|
|
26891
|
-
const blockedUserLiveCollection = new BlockedUserLiveCollectionController(params, callback);
|
|
26892
|
-
const disposers = blockedUserLiveCollection.startSubscription();
|
|
26893
|
-
const cacheKey = blockedUserLiveCollection.getCacheKey();
|
|
26894
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
26895
|
-
return () => {
|
|
26896
|
-
log(`getBlockedUsers(tmpid: ${timestamp}) > dispose`);
|
|
26897
|
-
disposers.forEach(fn => fn());
|
|
26898
|
-
dropFromCache(cacheKey);
|
|
26899
|
-
};
|
|
26900
|
-
};
|
|
26901
|
-
/* end_public_function */
|
|
26902
|
-
|
|
26903
|
-
/* eslint-disable no-use-before-define */
|
|
26904
|
-
const getBlockedUsers = (params, callback, config) => {
|
|
26905
|
-
console.log('Deprecation Notice: UserRepository.Relationship.getBlockedUsers will be deprecated on 9th June 2023, please use UserRepository.getBlockedUsers instead.');
|
|
26906
|
-
return getBlockedUsers$1(params, callback);
|
|
26907
|
-
};
|
|
26908
|
-
|
|
26909
|
-
/* begin_public_function
|
|
26910
|
-
id: user.relationship.follow
|
|
26911
|
-
*/
|
|
26912
|
-
/**
|
|
26913
|
-
* ```js
|
|
26914
|
-
* import { follow } from '@amityco/ts-sdk'
|
|
26915
|
-
* const status = await follow('foobar')
|
|
26916
|
-
* ```
|
|
26917
|
-
*
|
|
26918
|
-
* Follow the user
|
|
26919
|
-
*
|
|
26920
|
-
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26921
|
-
* @returns the status {@link Amity.FollowStatus}
|
|
26922
|
-
*
|
|
26923
|
-
* @category Follow API
|
|
26924
|
-
* @async
|
|
26925
|
-
*/
|
|
26926
|
-
const follow = async (userId) => {
|
|
26927
|
-
const client = getActiveClient();
|
|
26928
|
-
client.log('follow/follow', userId);
|
|
26929
|
-
const { data } = await client.http.post(`/api/v4/me/following/${userId}`);
|
|
26930
|
-
const cachedAt = client.cache && Date.now();
|
|
26931
|
-
if (client.cache) {
|
|
26932
|
-
ingestInCache(data, { cachedAt });
|
|
26933
|
-
}
|
|
26934
|
-
const payload = prepareFollowStatusPayload(data);
|
|
26935
|
-
if (data.follows[0].status === 'accepted') {
|
|
26936
|
-
fireEvent('local.follow.created', payload);
|
|
26937
|
-
}
|
|
26938
|
-
else {
|
|
26939
|
-
fireEvent('local.follow.requested', payload);
|
|
26940
|
-
}
|
|
26941
|
-
return {
|
|
26942
|
-
data: data.follows[0],
|
|
26943
|
-
cachedAt,
|
|
26944
|
-
};
|
|
26945
|
-
};
|
|
26946
|
-
/* end_public_function */
|
|
26947
|
-
|
|
26948
|
-
/* begin_public_function
|
|
26949
|
-
id: user.relationship.unfollow
|
|
26950
|
-
*/
|
|
26951
|
-
/**
|
|
26952
|
-
* ```js
|
|
26953
|
-
* import { unfollow } from '@amityco/ts-sdk'
|
|
26954
|
-
* await unfollow('foobar')
|
|
26955
|
-
* ```
|
|
26956
|
-
*
|
|
26957
|
-
* Cancel the follow request or unfollow the user
|
|
26958
|
-
*
|
|
26959
|
-
* @param userId the ID of the {@link Amity.InternalUser}
|
|
26960
|
-
* @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
|
|
26961
|
-
*
|
|
26962
|
-
* @category Follow API
|
|
26963
|
-
* @async
|
|
26964
|
-
*/
|
|
26965
|
-
const unfollow = async (userId) => {
|
|
26966
|
-
const client = getActiveClient();
|
|
26967
|
-
client.log('follow/unfollow', userId);
|
|
26968
|
-
const { data } = await client.http.delete(`/api/v4/me/following/${userId}`);
|
|
26969
|
-
if (client.cache) {
|
|
26970
|
-
ingestInCache(data);
|
|
26971
|
-
}
|
|
26972
|
-
const payload = prepareFollowStatusPayload(data);
|
|
26973
|
-
fireEvent('local.follow.unfollowed', payload);
|
|
26974
|
-
return true;
|
|
26975
|
-
};
|
|
26976
|
-
/* end_public_function */
|
|
26977
|
-
|
|
26978
|
-
/**
|
|
26979
|
-
* @deprecated This API renamed to `acceptMyFollower`.
|
|
26980
|
-
* Please use acceptMyFollower() instead.
|
|
26981
|
-
*
|
|
26982
|
-
* ```js
|
|
26983
|
-
* import { acceptFollower } from '@amityco/ts-sdk'
|
|
26984
|
-
* await acceptFollower('foobar')
|
|
26985
|
-
* ```
|
|
26986
|
-
*
|
|
26987
|
-
* Accept the follow request
|
|
26988
|
-
*
|
|
26989
|
-
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
26990
|
-
* @returns A success boolean if the follow request was accepted
|
|
26991
|
-
*
|
|
26992
|
-
* @category Follow API
|
|
26993
|
-
* @async
|
|
26994
|
-
*/
|
|
26995
|
-
const acceptFollower = async (userId) => {
|
|
26996
|
-
const client = getActiveClient();
|
|
26997
|
-
client.log('follow/acceptFollower', userId);
|
|
26998
|
-
const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
|
|
26999
|
-
if (client.cache) {
|
|
27000
|
-
ingestInCache(data);
|
|
27001
|
-
}
|
|
27002
|
-
const payload = prepareFollowStatusPayload(data);
|
|
27003
|
-
fireEvent('local.follow.accepted', payload);
|
|
27004
|
-
return true;
|
|
27005
|
-
};
|
|
27006
|
-
|
|
27007
|
-
/* begin_public_function
|
|
27008
|
-
id: user.relationship.accept_follow
|
|
27009
|
-
*/
|
|
27010
|
-
/**
|
|
27011
|
-
* ```js
|
|
27012
|
-
* import { UserRepository } from '@amityco/ts-sdk'
|
|
27013
|
-
* await UserRepository.Relationship.acceptMyFollower('foobar')
|
|
27014
|
-
* ```
|
|
27015
|
-
*
|
|
27016
|
-
* Accept the follow request
|
|
27017
|
-
*
|
|
27018
|
-
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
27019
|
-
* @returns A success boolean if the follow request was accepted
|
|
27020
|
-
*
|
|
27021
|
-
* @category Follow API
|
|
27022
|
-
* @async
|
|
27023
|
-
*/
|
|
27024
|
-
const acceptMyFollower = async (userId) => {
|
|
27025
|
-
const client = getActiveClient();
|
|
27026
|
-
client.log('follow/acceptMyFollower', userId);
|
|
27027
|
-
const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
|
|
27028
|
-
if (client.cache) {
|
|
27029
|
-
ingestInCache(data);
|
|
26449
|
+
let token;
|
|
26450
|
+
if (direction === 'prev')
|
|
26451
|
+
token = this.previousToken;
|
|
26452
|
+
if (direction === 'next')
|
|
26453
|
+
token = this.nextToken;
|
|
26454
|
+
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
26455
|
+
if (direction === 'first') {
|
|
26456
|
+
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
26457
|
+
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
26458
|
+
}
|
|
26459
|
+
if (direction === 'prev')
|
|
26460
|
+
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
26461
|
+
if (direction === 'next')
|
|
26462
|
+
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
26463
|
+
return queryResponse;
|
|
27030
26464
|
}
|
|
27031
|
-
|
|
27032
|
-
|
|
27033
|
-
return true;
|
|
27034
|
-
};
|
|
27035
|
-
/* end_public_function */
|
|
27036
|
-
|
|
27037
|
-
/**
|
|
27038
|
-
* @deprecated This API renamed to `declineMyFollower`.
|
|
27039
|
-
* Please use declineMyFollower() instead.
|
|
27040
|
-
*
|
|
27041
|
-
* ```js
|
|
27042
|
-
* import { declineFollower } from '@amityco/ts-sdk'
|
|
27043
|
-
* await declineFollower('foobar')
|
|
27044
|
-
* ```
|
|
27045
|
-
*
|
|
27046
|
-
* Decline the follow request or delete the follower
|
|
27047
|
-
*
|
|
27048
|
-
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
27049
|
-
* @returns A success boolean if the follow request was decline
|
|
27050
|
-
*
|
|
27051
|
-
* @category Follow API
|
|
27052
|
-
* @async
|
|
27053
|
-
*/
|
|
27054
|
-
const declineFollower = async (userId) => {
|
|
27055
|
-
const client = getActiveClient();
|
|
27056
|
-
client.log('follow/declineFollower', userId);
|
|
27057
|
-
const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
|
|
27058
|
-
if (client.cache) {
|
|
27059
|
-
ingestInCache(data);
|
|
26465
|
+
getNextToken() {
|
|
26466
|
+
return this.nextToken;
|
|
27060
26467
|
}
|
|
27061
|
-
|
|
27062
|
-
|
|
27063
|
-
return true;
|
|
27064
|
-
};
|
|
27065
|
-
|
|
27066
|
-
/* begin_public_function
|
|
27067
|
-
id: user.relationship.decline_follow
|
|
27068
|
-
*/
|
|
27069
|
-
/**
|
|
27070
|
-
* ```js
|
|
27071
|
-
* import { UserRepository } from '@amityco/ts-sdk'
|
|
27072
|
-
* await UserRepository.Relationship.declineMyFollower('foobar')
|
|
27073
|
-
* ```
|
|
27074
|
-
*
|
|
27075
|
-
* Decline the follow request or delete the follower
|
|
27076
|
-
*
|
|
27077
|
-
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
27078
|
-
* @returns A success boolean if the follow request was decline
|
|
27079
|
-
*
|
|
27080
|
-
* @category Follow API
|
|
27081
|
-
* @async
|
|
27082
|
-
*/
|
|
27083
|
-
const declineMyFollower = async (userId) => {
|
|
27084
|
-
const client = getActiveClient();
|
|
27085
|
-
client.log('follow/declineMyFollower', userId);
|
|
27086
|
-
const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
|
|
27087
|
-
if (client.cache) {
|
|
27088
|
-
ingestInCache(data);
|
|
26468
|
+
getPrevToken() {
|
|
26469
|
+
return this.previousToken;
|
|
27089
26470
|
}
|
|
27090
|
-
|
|
27091
|
-
fireEvent('local.follow.requestDeclined', payload);
|
|
27092
|
-
return true;
|
|
27093
|
-
};
|
|
27094
|
-
/* end_public_function */
|
|
27095
|
-
|
|
27096
|
-
/**
|
|
27097
|
-
* ```js
|
|
27098
|
-
* import { observeFollowInfo } from '@amityco/ts-sdk'
|
|
27099
|
-
*
|
|
27100
|
-
* let followInfo = {}
|
|
27101
|
-
* const dispose = observeFollowInfo(userId, updated => followInfo = updated)
|
|
27102
|
-
* ```
|
|
27103
|
-
*
|
|
27104
|
-
* Observe all mutation on a given {@link Amity.FollowInfo}
|
|
27105
|
-
*
|
|
27106
|
-
* @param userId the ID of the user to observe
|
|
27107
|
-
* @param callback the function to call when new data are available
|
|
27108
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the post
|
|
27109
|
-
*
|
|
27110
|
-
* @category Follow Observer
|
|
27111
|
-
*/
|
|
27112
|
-
const observeFollowInfo = (userId, callback, policy = 'cache_then_server') => {
|
|
27113
|
-
const { log } = getActiveClient();
|
|
27114
|
-
const timestamp = Date.now();
|
|
27115
|
-
log(`observeFollowInfo(tmpid: ${timestamp}) > listen`);
|
|
27116
|
-
const router = (result, action) => {
|
|
27117
|
-
var _a, _b;
|
|
27118
|
-
if (callback instanceof Function)
|
|
27119
|
-
return callback(result);
|
|
27120
|
-
if (action !== 'onFetch')
|
|
27121
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, result);
|
|
27122
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, result);
|
|
27123
|
-
};
|
|
27124
|
-
const realtimeRouter = (result, action) => {
|
|
27125
|
-
var _a;
|
|
27126
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.userId) !== userId)
|
|
27127
|
-
return;
|
|
27128
|
-
router(result, action);
|
|
27129
|
-
};
|
|
27130
|
-
const disposers = [];
|
|
27131
|
-
disposers.push(onFollowInfoUpdated(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUpdate')));
|
|
27132
|
-
runQuery(createQuery(getFollowInfo$1, userId), result => (result.data || result.error) && router(result, 'onFetch'), queryOptions(policy));
|
|
27133
|
-
return () => {
|
|
27134
|
-
log(`observeFollowInfo(tmpid: ${timestamp}) > dispose`);
|
|
27135
|
-
disposers.forEach(fn => fn());
|
|
27136
|
-
};
|
|
27137
|
-
};
|
|
27138
|
-
|
|
27139
|
-
/**
|
|
27140
|
-
* ```js
|
|
27141
|
-
* import { observeFollowers } from '@amityco/ts-sdk'
|
|
27142
|
-
*
|
|
27143
|
-
* let followers = []
|
|
27144
|
-
* const unsub = observeFollowers('userId', follower => merge(followers, follower))
|
|
27145
|
-
* ```
|
|
27146
|
-
*
|
|
27147
|
-
* Observe all mutations on a list of followers {@link Amity.FollowStatus} for a given user
|
|
27148
|
-
*
|
|
27149
|
-
* @param userId the ID of the {@link Amity.InternalUser}
|
|
27150
|
-
* @param callback the function to call when new data are available
|
|
27151
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
27152
|
-
*
|
|
27153
|
-
* @category Follow Observer
|
|
27154
|
-
*/
|
|
27155
|
-
const observeFollowers = (userId, callback) => {
|
|
27156
|
-
const { log } = getActiveClient();
|
|
27157
|
-
const timestamp = Date.now();
|
|
27158
|
-
log(`observeFollowers(tmpid: ${timestamp}) > listen`);
|
|
27159
|
-
const disposers = [];
|
|
27160
|
-
const router = (status, action) => {
|
|
27161
|
-
var _a, _b;
|
|
27162
|
-
if (callback instanceof Function) {
|
|
27163
|
-
return callback(status);
|
|
27164
|
-
}
|
|
27165
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, status);
|
|
27166
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, status);
|
|
27167
|
-
};
|
|
27168
|
-
disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')), onLocalFollowerRequested(x => router(x, 'onRequested')), onLocalFollowRequestAccepted(x => router(x, 'onAccepted')), onLocalFollowRequestDeclined(x => router(x, 'onDeclined')), onLocalUserFollowed(x => router(x, 'onFollowed')), onLocalUserUnfollowed(x => router(x, 'onUnfollowed')));
|
|
27169
|
-
return () => {
|
|
27170
|
-
log(`observeFollowers(tmpid: ${timestamp}) > dispose`);
|
|
27171
|
-
disposers.forEach(fn => fn());
|
|
27172
|
-
};
|
|
27173
|
-
};
|
|
27174
|
-
|
|
27175
|
-
/**
|
|
27176
|
-
* ```js
|
|
27177
|
-
* import { observeFollowings } from '@amityco/ts-sdk'
|
|
27178
|
-
*
|
|
27179
|
-
* let followings = []
|
|
27180
|
-
* const unsub = observeFollowers('userId', follower => merge(followings, following))
|
|
27181
|
-
* ```
|
|
27182
|
-
*
|
|
27183
|
-
* Observe all mutations on a list of followings {@link Amity.FollowStatus} for a given user
|
|
27184
|
-
*
|
|
27185
|
-
* @param userId the ID of the {@link Amity.InternalUser}
|
|
27186
|
-
* @param callback the function to call when new data are available
|
|
27187
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
27188
|
-
*
|
|
27189
|
-
* @category Follow Observer
|
|
27190
|
-
*/
|
|
27191
|
-
const observeFollowings = (userId, callback) => {
|
|
27192
|
-
const { log } = getActiveClient();
|
|
27193
|
-
const timestamp = Date.now();
|
|
27194
|
-
log(`observeFollowings(tmpid: ${timestamp}) > listen`);
|
|
27195
|
-
const disposers = [];
|
|
27196
|
-
const router = (status, action) => {
|
|
27197
|
-
var _a, _b;
|
|
27198
|
-
if (callback instanceof Function) {
|
|
27199
|
-
return callback(status);
|
|
27200
|
-
}
|
|
27201
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, status);
|
|
27202
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, status);
|
|
27203
|
-
};
|
|
27204
|
-
disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')), onLocalFollowerRequested(x => router(x, 'onRequested')), onLocalFollowRequestAccepted(x => router(x, 'onAccepted')), onLocalFollowRequestDeclined(x => router(x, 'onDeclined')), onLocalUserFollowed(x => router(x, 'onFollowed')), onLocalUserUnfollowed(x => router(x, 'onUnfollowed')));
|
|
27205
|
-
return () => {
|
|
27206
|
-
log(`observeFollowings(tmpid: ${timestamp}) > dispose`);
|
|
27207
|
-
disposers.forEach(fn => fn());
|
|
27208
|
-
};
|
|
27209
|
-
};
|
|
26471
|
+
}
|
|
27210
26472
|
|
|
27211
26473
|
class FollowerPaginationController extends PaginationController {
|
|
27212
26474
|
async getRequest(queryParams, token) {
|
|
@@ -27221,6 +26483,25 @@ class FollowerPaginationController extends PaginationController {
|
|
|
27221
26483
|
}
|
|
27222
26484
|
}
|
|
27223
26485
|
|
|
26486
|
+
class QueryStreamController {
|
|
26487
|
+
constructor(query, cacheKey) {
|
|
26488
|
+
this.query = query;
|
|
26489
|
+
this.cacheKey = cacheKey;
|
|
26490
|
+
}
|
|
26491
|
+
}
|
|
26492
|
+
|
|
26493
|
+
var EnumFollowActions;
|
|
26494
|
+
(function (EnumFollowActions) {
|
|
26495
|
+
EnumFollowActions["OnRequested"] = "onRequested";
|
|
26496
|
+
EnumFollowActions["OnAccepted"] = "onAccepted";
|
|
26497
|
+
EnumFollowActions["OnDeclined"] = "onDeclined";
|
|
26498
|
+
EnumFollowActions["OnCanceled"] = "onCanceled";
|
|
26499
|
+
EnumFollowActions["OnFollowed"] = "onFollowed";
|
|
26500
|
+
EnumFollowActions["OnUnfollowed"] = "onUnfollowed";
|
|
26501
|
+
EnumFollowActions["OnDeleted"] = "onDeleted";
|
|
26502
|
+
EnumFollowActions["OnUserDeleted"] = "onUserDeleted";
|
|
26503
|
+
})(EnumFollowActions || (EnumFollowActions = {}));
|
|
26504
|
+
|
|
27224
26505
|
class FollowerQueryStreamController extends QueryStreamController {
|
|
27225
26506
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
27226
26507
|
super(query, cacheKey);
|
|
@@ -27276,6 +26557,109 @@ class FollowerQueryStreamController extends QueryStreamController {
|
|
|
27276
26557
|
}
|
|
27277
26558
|
}
|
|
27278
26559
|
|
|
26560
|
+
class PaginationNoPageController {
|
|
26561
|
+
constructor(queryParams) {
|
|
26562
|
+
const { http } = getActiveClient();
|
|
26563
|
+
this.queryParams = queryParams;
|
|
26564
|
+
this.http = http;
|
|
26565
|
+
}
|
|
26566
|
+
async onFetch() {
|
|
26567
|
+
const queryResponse = await this.getRequest(this.queryParams);
|
|
26568
|
+
return queryResponse;
|
|
26569
|
+
}
|
|
26570
|
+
}
|
|
26571
|
+
|
|
26572
|
+
class LiveCollectionController {
|
|
26573
|
+
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
26574
|
+
this.paginationController = paginationController;
|
|
26575
|
+
this.queryStreamId = queryStreamId;
|
|
26576
|
+
this.cacheKey = cacheKey;
|
|
26577
|
+
this.callback = callback;
|
|
26578
|
+
}
|
|
26579
|
+
async refresh() {
|
|
26580
|
+
try {
|
|
26581
|
+
let result;
|
|
26582
|
+
if (this.paginationController instanceof PaginationNoPageController) {
|
|
26583
|
+
result = await this.paginationController.onFetch();
|
|
26584
|
+
}
|
|
26585
|
+
else {
|
|
26586
|
+
result = await this.paginationController.loadFirstPage();
|
|
26587
|
+
}
|
|
26588
|
+
if (!result)
|
|
26589
|
+
return;
|
|
26590
|
+
await this.persistModel(result);
|
|
26591
|
+
this.persistQueryStream({
|
|
26592
|
+
response: result,
|
|
26593
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
26594
|
+
refresh: true,
|
|
26595
|
+
});
|
|
26596
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
26597
|
+
}
|
|
26598
|
+
catch (e) {
|
|
26599
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
26600
|
+
}
|
|
26601
|
+
}
|
|
26602
|
+
loadPage({ initial = false, direction = "next" /* Amity.LiveCollectionPageDirection.NEXT */, }) {
|
|
26603
|
+
this.setup();
|
|
26604
|
+
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
26605
|
+
if (initial) {
|
|
26606
|
+
this.refresh();
|
|
26607
|
+
}
|
|
26608
|
+
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
26609
|
+
this.loadPrevPage();
|
|
26610
|
+
}
|
|
26611
|
+
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
26612
|
+
this.loadNextPage();
|
|
26613
|
+
}
|
|
26614
|
+
}
|
|
26615
|
+
async loadNextPage() {
|
|
26616
|
+
try {
|
|
26617
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
26618
|
+
return;
|
|
26619
|
+
const result = await this.paginationController.loadNextPage();
|
|
26620
|
+
if (!result)
|
|
26621
|
+
return;
|
|
26622
|
+
await this.persistModel(result);
|
|
26623
|
+
this.persistQueryStream({
|
|
26624
|
+
response: result,
|
|
26625
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
26626
|
+
});
|
|
26627
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
26628
|
+
}
|
|
26629
|
+
catch (e) {
|
|
26630
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
26631
|
+
}
|
|
26632
|
+
}
|
|
26633
|
+
async loadPrevPage() {
|
|
26634
|
+
try {
|
|
26635
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
26636
|
+
return;
|
|
26637
|
+
const result = await this.paginationController.loadPreviousPage();
|
|
26638
|
+
if (!result)
|
|
26639
|
+
return;
|
|
26640
|
+
await this.persistModel(result);
|
|
26641
|
+
this.persistQueryStream({
|
|
26642
|
+
response: result,
|
|
26643
|
+
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
26644
|
+
});
|
|
26645
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
26646
|
+
}
|
|
26647
|
+
catch (e) {
|
|
26648
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
26649
|
+
}
|
|
26650
|
+
}
|
|
26651
|
+
shouldNotify(data) {
|
|
26652
|
+
const newData = data.map(convertGetterPropsToStatic).map(removeFunctionProperties);
|
|
26653
|
+
if (isEqual(this.snapshot, newData))
|
|
26654
|
+
return false;
|
|
26655
|
+
this.snapshot = newData;
|
|
26656
|
+
return true;
|
|
26657
|
+
}
|
|
26658
|
+
getCacheKey() {
|
|
26659
|
+
return this.cacheKey;
|
|
26660
|
+
}
|
|
26661
|
+
}
|
|
26662
|
+
|
|
27279
26663
|
const onFollowerUserDeleted = ({ userId }) => (callback) => {
|
|
27280
26664
|
const client = getActiveClient();
|
|
27281
26665
|
const filter = (data) => {
|
|
@@ -27620,6 +27004,69 @@ const getFollowings = (params, callback, config) => {
|
|
|
27620
27004
|
};
|
|
27621
27005
|
/* end_public_function */
|
|
27622
27006
|
|
|
27007
|
+
/**
|
|
27008
|
+
* @deprecated This function will to be deprecated soon.
|
|
27009
|
+
*/
|
|
27010
|
+
const liveObject = (id, callback, key, fetcher, eventHandlers, options) => {
|
|
27011
|
+
const { forceDispatch, callbackDataSelector, callbackFilter } = Object.assign({ forceDispatch: false, callbackDataSelector: (data) => data }, options);
|
|
27012
|
+
const { cache } = getActiveClient();
|
|
27013
|
+
if (!cache) {
|
|
27014
|
+
console.log(LIVE_OBJECT_ENABLE_CACHE_MESSAGE);
|
|
27015
|
+
}
|
|
27016
|
+
let model;
|
|
27017
|
+
let isUnsyncedModel = false; // for messages
|
|
27018
|
+
const disposers = [];
|
|
27019
|
+
const dispatcher = (data) => {
|
|
27020
|
+
const { data: newModel } = data, rest = __rest(data, ["data"]);
|
|
27021
|
+
if (!callbackFilter || callbackFilter(newModel, model)) {
|
|
27022
|
+
callback(Object.assign({ data: callbackDataSelector(newModel) }, rest));
|
|
27023
|
+
}
|
|
27024
|
+
// resolve all getter on data model to a static value to avoid comparison problems
|
|
27025
|
+
model = convertGetterPropsToStatic(newModel);
|
|
27026
|
+
};
|
|
27027
|
+
const realtimeRouter = (eventModel, forceDispatch = false) => {
|
|
27028
|
+
if (id !== eventModel[key]) {
|
|
27029
|
+
return;
|
|
27030
|
+
}
|
|
27031
|
+
if (model) {
|
|
27032
|
+
if (!forceDispatch && isEqual(model, eventModel)) {
|
|
27033
|
+
return;
|
|
27034
|
+
}
|
|
27035
|
+
}
|
|
27036
|
+
dispatcher({ loading: false, data: eventModel, origin: 'event' });
|
|
27037
|
+
};
|
|
27038
|
+
const onFetch = () => {
|
|
27039
|
+
// TODO: Ihis `@ts-ignore` is bring back to fix the build and it needs to be removed later
|
|
27040
|
+
// @ts-ignore
|
|
27041
|
+
const query = createQuery(fetcher, id, true);
|
|
27042
|
+
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
27043
|
+
if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
|
|
27044
|
+
dispatcher({
|
|
27045
|
+
// @ts-ignore
|
|
27046
|
+
data,
|
|
27047
|
+
origin,
|
|
27048
|
+
loading: false,
|
|
27049
|
+
error: new ASCApiError(UNSYNCED_OBJECT_CACHED_AT_MESSAGE, 800800 /* Amity.ClientError.DISALOOW_UNSYNCED_OBJECT */, "error" /* Amity.ErrorLevel.ERROR */),
|
|
27050
|
+
});
|
|
27051
|
+
isUnsyncedModel = true;
|
|
27052
|
+
disposers.forEach(fn => fn());
|
|
27053
|
+
}
|
|
27054
|
+
else if (!isUnsyncedModel) {
|
|
27055
|
+
// @ts-ignore
|
|
27056
|
+
dispatcher({ loading, data, origin, error });
|
|
27057
|
+
}
|
|
27058
|
+
if (error) {
|
|
27059
|
+
disposers.forEach(fn => fn());
|
|
27060
|
+
}
|
|
27061
|
+
});
|
|
27062
|
+
};
|
|
27063
|
+
disposers.push(...eventHandlers.map(fn => fn(eventModel => realtimeRouter(eventModel, forceDispatch))));
|
|
27064
|
+
onFetch();
|
|
27065
|
+
return () => {
|
|
27066
|
+
disposers.forEach(fn => fn());
|
|
27067
|
+
};
|
|
27068
|
+
};
|
|
27069
|
+
|
|
27623
27070
|
/* begin_public_function
|
|
27624
27071
|
id: user.relationship.get_follow_info
|
|
27625
27072
|
*/
|
|
@@ -27685,12 +27132,9 @@ var index$k = /*#__PURE__*/Object.freeze({
|
|
|
27685
27132
|
__proto__: null,
|
|
27686
27133
|
blockUser: blockUser,
|
|
27687
27134
|
unBlockUser: unBlockUser,
|
|
27688
|
-
getBlockedUsers: getBlockedUsers,
|
|
27689
27135
|
follow: follow,
|
|
27690
27136
|
unfollow: unfollow,
|
|
27691
|
-
acceptFollower: acceptFollower,
|
|
27692
27137
|
acceptMyFollower: acceptMyFollower,
|
|
27693
|
-
declineFollower: declineFollower,
|
|
27694
27138
|
declineMyFollower: declineMyFollower,
|
|
27695
27139
|
onUserFollowed: onUserFollowed,
|
|
27696
27140
|
onUserUnfollowed: onUserUnfollowed,
|
|
@@ -27705,9 +27149,6 @@ var index$k = /*#__PURE__*/Object.freeze({
|
|
|
27705
27149
|
onLocalFollowerRequested: onLocalFollowerRequested,
|
|
27706
27150
|
onLocalFollowRequestAccepted: onLocalFollowRequestAccepted,
|
|
27707
27151
|
onLocalFollowRequestDeclined: onLocalFollowRequestDeclined,
|
|
27708
|
-
observeFollowInfo: observeFollowInfo,
|
|
27709
|
-
observeFollowers: observeFollowers,
|
|
27710
|
-
observeFollowings: observeFollowings,
|
|
27711
27152
|
getFollowers: getFollowers,
|
|
27712
27153
|
getFollowings: getFollowings,
|
|
27713
27154
|
getFollowInfo: getFollowInfo,
|
|
@@ -27895,6 +27336,74 @@ const isUserFlaggedByMe = async (userId) => {
|
|
|
27895
27336
|
};
|
|
27896
27337
|
/* end_public_function */
|
|
27897
27338
|
|
|
27339
|
+
/**
|
|
27340
|
+
* ```js
|
|
27341
|
+
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
27342
|
+
* const dispose = onUserUpdated(user => {
|
|
27343
|
+
* // ...
|
|
27344
|
+
* })
|
|
27345
|
+
* ```
|
|
27346
|
+
*
|
|
27347
|
+
* Fired when a {@link Amity.InternalUser} has been updated
|
|
27348
|
+
*
|
|
27349
|
+
* @param callback The function to call when the event was fired
|
|
27350
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27351
|
+
*
|
|
27352
|
+
* @category User Events
|
|
27353
|
+
*/
|
|
27354
|
+
const onUserUpdated = (callback) => createUserEventSubscriber('user.updated', callback);
|
|
27355
|
+
|
|
27356
|
+
/**
|
|
27357
|
+
* ```js
|
|
27358
|
+
* import { onUserFlagged } from '@amityco/ts-sdk'
|
|
27359
|
+
* const dispose = onUserFlagged(user => {
|
|
27360
|
+
* // ...
|
|
27361
|
+
* })
|
|
27362
|
+
* ```
|
|
27363
|
+
*
|
|
27364
|
+
* Fired when a {@link Amity.InternalUser} has been flagged
|
|
27365
|
+
*
|
|
27366
|
+
* @param callback The function to call when the event was fired
|
|
27367
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27368
|
+
*
|
|
27369
|
+
* @category User Events
|
|
27370
|
+
*/
|
|
27371
|
+
const onUserFlagged = (callback) => createUserEventSubscriber('user.flagged', callback);
|
|
27372
|
+
|
|
27373
|
+
/**
|
|
27374
|
+
* ```js
|
|
27375
|
+
* import { onUserUnflagged } from '@amityco/ts-sdk'
|
|
27376
|
+
* const dispose = onUserUnflagged(user => {
|
|
27377
|
+
* // ...
|
|
27378
|
+
* })
|
|
27379
|
+
* ```
|
|
27380
|
+
*
|
|
27381
|
+
* Fired when a flag has been removed from a {@link Amity.InternalUser}
|
|
27382
|
+
*
|
|
27383
|
+
* @param callback The function to call when the event was fired
|
|
27384
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27385
|
+
*
|
|
27386
|
+
* @category User Events
|
|
27387
|
+
*/
|
|
27388
|
+
const onUserUnflagged = (callback) => createUserEventSubscriber('user.unflagged', callback);
|
|
27389
|
+
|
|
27390
|
+
/**
|
|
27391
|
+
* ```js
|
|
27392
|
+
* import { onUserFlagCleared } from '@amityco/ts-sdk'
|
|
27393
|
+
* const dispose = onUserFlagCleared(user => {
|
|
27394
|
+
* // ...
|
|
27395
|
+
* })
|
|
27396
|
+
* ```
|
|
27397
|
+
*
|
|
27398
|
+
* Fired when flags have been cleared for a {@link Amity.InternalUser}
|
|
27399
|
+
*
|
|
27400
|
+
* @param callback The function to call when the event was fired
|
|
27401
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27402
|
+
*
|
|
27403
|
+
* @category User Events
|
|
27404
|
+
*/
|
|
27405
|
+
const onUserFlagCleared = (callback) => createUserEventSubscriber('user.flagCleared', callback);
|
|
27406
|
+
|
|
27898
27407
|
/**
|
|
27899
27408
|
* ```js
|
|
27900
27409
|
* import { onUserFetched } from '@amityco/ts-sdk'
|
|
@@ -27926,7 +27435,7 @@ const onUserFetched = (callback) => createUserEventSubscriber('user.fetched', ca
|
|
|
27926
27435
|
* @category Private
|
|
27927
27436
|
* @async
|
|
27928
27437
|
*/
|
|
27929
|
-
const getUser$
|
|
27438
|
+
const getUser$1 = async (userId) => {
|
|
27930
27439
|
const client = getActiveClient();
|
|
27931
27440
|
client.log('user/getUser', userId);
|
|
27932
27441
|
isInTombstone('user', userId);
|
|
@@ -27962,7 +27471,7 @@ const getUser$2 = async (userId) => {
|
|
|
27962
27471
|
*
|
|
27963
27472
|
* @category User API
|
|
27964
27473
|
*/
|
|
27965
|
-
getUser$
|
|
27474
|
+
getUser$1.locally = (userId) => {
|
|
27966
27475
|
const client = getActiveClient();
|
|
27967
27476
|
client.log('user/getUser.locally', userId);
|
|
27968
27477
|
if (!client.cache)
|
|
@@ -27998,11 +27507,11 @@ getUser$2.locally = (userId) => {
|
|
|
27998
27507
|
*
|
|
27999
27508
|
* @category Message Live Object
|
|
28000
27509
|
*/
|
|
28001
|
-
const getUser
|
|
27510
|
+
const getUser = (userId, callback) => {
|
|
28002
27511
|
const reactor = (response) => {
|
|
28003
27512
|
return callback(Object.assign(Object.assign({}, response), { data: response.data ? LinkedObject.user(response.data) : response.data }));
|
|
28004
27513
|
};
|
|
28005
|
-
return liveObject(userId, reactor, 'userId', getUser$
|
|
27514
|
+
return liveObject(userId, reactor, 'userId', getUser$1, [
|
|
28006
27515
|
onUserFetched,
|
|
28007
27516
|
onUserUpdated,
|
|
28008
27517
|
onUserDeleted$2,
|
|
@@ -28015,10 +27524,10 @@ const getUser$1 = (userId, callback) => {
|
|
|
28015
27524
|
|
|
28016
27525
|
class UserPaginationController extends PaginationController {
|
|
28017
27526
|
async getRequest(queryParams, token) {
|
|
28018
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT
|
|
27527
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
28019
27528
|
const options = token ? { token } : { limit };
|
|
28020
27529
|
const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
|
|
28021
|
-
params: Object.assign(Object.assign({}, params), {
|
|
27530
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
28022
27531
|
});
|
|
28023
27532
|
return queryResponse;
|
|
28024
27533
|
}
|
|
@@ -28070,6 +27579,15 @@ class UserQueryStreamController extends QueryStreamController {
|
|
|
28070
27579
|
}
|
|
28071
27580
|
}
|
|
28072
27581
|
|
|
27582
|
+
var EnumUserActions;
|
|
27583
|
+
(function (EnumUserActions) {
|
|
27584
|
+
EnumUserActions["OnUserDeleted"] = "onUserDeleted";
|
|
27585
|
+
EnumUserActions["OnUserUpdated"] = "onUserUpdated";
|
|
27586
|
+
EnumUserActions["OnUserFlagged"] = "onUserFlagged";
|
|
27587
|
+
EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
|
|
27588
|
+
EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
|
|
27589
|
+
})(EnumUserActions || (EnumUserActions = {}));
|
|
27590
|
+
|
|
28073
27591
|
class UserLiveCollectionController extends LiveCollectionController {
|
|
28074
27592
|
constructor(query, callback) {
|
|
28075
27593
|
const queryStreamId = hash(query);
|
|
@@ -28128,21 +27646,17 @@ class UserLiveCollectionController extends LiveCollectionController {
|
|
|
28128
27646
|
}
|
|
28129
27647
|
applyFilter(data) {
|
|
28130
27648
|
let users = data;
|
|
28131
|
-
|
|
28132
|
-
|
|
28133
|
-
|
|
28134
|
-
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28138
|
-
|
|
28139
|
-
|
|
28140
|
-
|
|
28141
|
-
|
|
28142
|
-
}
|
|
28143
|
-
})();
|
|
28144
|
-
users = users.sort(sortFn);
|
|
28145
|
-
}
|
|
27649
|
+
const sortFn = (() => {
|
|
27650
|
+
switch (this.query.sortBy) {
|
|
27651
|
+
case 'firstCreated':
|
|
27652
|
+
return sortByFirstCreated;
|
|
27653
|
+
case 'lastCreated':
|
|
27654
|
+
return sortByLastCreated;
|
|
27655
|
+
default:
|
|
27656
|
+
return sortByLastCreated;
|
|
27657
|
+
}
|
|
27658
|
+
})();
|
|
27659
|
+
users = users.sort(sortFn);
|
|
28146
27660
|
if (this.query.filter === 'flagged') {
|
|
28147
27661
|
users = users.filter(user => !!user.hashFlag);
|
|
28148
27662
|
}
|
|
@@ -28189,90 +27703,200 @@ const getUsers = (params, callback, config) => {
|
|
|
28189
27703
|
};
|
|
28190
27704
|
/* end_public_function */
|
|
28191
27705
|
|
|
28192
|
-
|
|
28193
|
-
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
|
|
28197
|
-
|
|
28198
|
-
|
|
28199
|
-
|
|
28200
|
-
|
|
28201
|
-
|
|
28202
|
-
|
|
28203
|
-
|
|
28204
|
-
|
|
28205
|
-
|
|
28206
|
-
|
|
28207
|
-
|
|
28208
|
-
|
|
28209
|
-
|
|
28210
|
-
|
|
28211
|
-
|
|
28212
|
-
|
|
28213
|
-
|
|
28214
|
-
|
|
28215
|
-
|
|
28216
|
-
|
|
28217
|
-
|
|
28218
|
-
|
|
28219
|
-
|
|
28220
|
-
|
|
28221
|
-
|
|
28222
|
-
|
|
28223
|
-
|
|
28224
|
-
|
|
28225
|
-
|
|
28226
|
-
|
|
28227
|
-
|
|
28228
|
-
|
|
27706
|
+
class BlockedUserPaginationController extends PaginationController {
|
|
27707
|
+
async getRequest(queryParams, token) {
|
|
27708
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
27709
|
+
const options = token ? { token } : { limit };
|
|
27710
|
+
const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
|
|
27711
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
27712
|
+
});
|
|
27713
|
+
return queryResponse;
|
|
27714
|
+
}
|
|
27715
|
+
}
|
|
27716
|
+
|
|
27717
|
+
class BlockedUserQueryStreamController extends QueryStreamController {
|
|
27718
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
27719
|
+
super(query, cacheKey);
|
|
27720
|
+
this.notifyChange = notifyChange;
|
|
27721
|
+
this.preparePayload = preparePayload;
|
|
27722
|
+
}
|
|
27723
|
+
async saveToMainDB(response) {
|
|
27724
|
+
const processedPayload = await this.preparePayload(response);
|
|
27725
|
+
const client = getActiveClient();
|
|
27726
|
+
const cachedAt = client.cache && Date.now();
|
|
27727
|
+
if (client.cache) {
|
|
27728
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
27729
|
+
}
|
|
27730
|
+
}
|
|
27731
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
27732
|
+
var _a, _b;
|
|
27733
|
+
if (refresh) {
|
|
27734
|
+
pushToCache(this.cacheKey, {
|
|
27735
|
+
data: response.users.map(getResolver('user')),
|
|
27736
|
+
});
|
|
27737
|
+
}
|
|
27738
|
+
else {
|
|
27739
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27740
|
+
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27741
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
|
|
27742
|
+
}
|
|
27743
|
+
}
|
|
27744
|
+
reactor(action) {
|
|
27745
|
+
return (targetUser) => {
|
|
27746
|
+
var _a;
|
|
27747
|
+
if (action === EnumFollowActions.OnFollowed) {
|
|
27748
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27749
|
+
const updatedCollection = collection === null || collection === void 0 ? void 0 : collection.data.filter(id => id !== targetUser.userId);
|
|
27750
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: updatedCollection }));
|
|
27751
|
+
}
|
|
27752
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
27753
|
+
};
|
|
27754
|
+
}
|
|
27755
|
+
subscribeRTE(createSubscriber) {
|
|
27756
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
27757
|
+
}
|
|
27758
|
+
}
|
|
27759
|
+
|
|
27760
|
+
function prepareBlockedUserPayload(response) {
|
|
27761
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
27762
|
+
return Object.assign(Object.assign({}, rest), { follows: follows.map(follow => {
|
|
27763
|
+
const followUser = users.find(user => user.userId === follow.from);
|
|
27764
|
+
return Object.assign(Object.assign({}, follow), { user: convertRawUserToInternalUser(followUser) });
|
|
27765
|
+
}), users: users.map(convertRawUserToInternalUser) });
|
|
27766
|
+
}
|
|
27767
|
+
|
|
27768
|
+
const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
|
|
27769
|
+
var _a, _b;
|
|
27770
|
+
if (!sourceModel) {
|
|
27771
|
+
return sourceModel;
|
|
27772
|
+
}
|
|
27773
|
+
const client = getActiveClient();
|
|
27774
|
+
const { objectSyncMap } = client;
|
|
27775
|
+
/*
|
|
27776
|
+
* NOTE: For objects created locally (optimistic creation), the SDK stores them with their local ID as the cache key, which is used throughout the entire SDK session (in-memory) for syncing updates.
|
|
27777
|
+
* If the payload or response only contains the remote ID of the same object, the SDK will look up the corresponding local ID to retrieve the object.
|
|
27778
|
+
*/
|
|
27779
|
+
const resolvedId = isLocalId(sourceModel[sourceModelProp])
|
|
27780
|
+
? sourceModel[sourceModelProp]
|
|
27781
|
+
: (_a = objectSyncMap.get(sourceModel[sourceModelProp])) !== null && _a !== void 0 ? _a : sourceModel[sourceModelProp];
|
|
27782
|
+
const model = (_b = pullFromCache([
|
|
27783
|
+
destinationDomain,
|
|
27784
|
+
'get',
|
|
27785
|
+
`${resolvedId}`,
|
|
27786
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
27787
|
+
if (!model)
|
|
28229
27788
|
return;
|
|
28230
|
-
return
|
|
28231
|
-
|
|
28232
|
-
cachedAt: cached.cachedAt,
|
|
28233
|
-
};
|
|
28234
|
-
};
|
|
27789
|
+
return callback(model);
|
|
27790
|
+
});
|
|
28235
27791
|
|
|
27792
|
+
class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
27793
|
+
constructor(query, callback) {
|
|
27794
|
+
const queryStreamId = hash(query);
|
|
27795
|
+
const cacheKey = ['blockedUsers', 'collection', queryStreamId];
|
|
27796
|
+
const paginationController = new BlockedUserPaginationController(query);
|
|
27797
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
27798
|
+
this.query = query;
|
|
27799
|
+
this.queryStreamController = new BlockedUserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareBlockedUserPayload);
|
|
27800
|
+
this.callback = callback.bind(this);
|
|
27801
|
+
this.loadPage({ initial: true });
|
|
27802
|
+
}
|
|
27803
|
+
setup() {
|
|
27804
|
+
var _a;
|
|
27805
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27806
|
+
if (!collection) {
|
|
27807
|
+
pushToCache(this.cacheKey, {
|
|
27808
|
+
data: [],
|
|
27809
|
+
params: {},
|
|
27810
|
+
});
|
|
27811
|
+
}
|
|
27812
|
+
}
|
|
27813
|
+
async persistModel(queryPayload) {
|
|
27814
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
27815
|
+
}
|
|
27816
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
27817
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
27818
|
+
}
|
|
27819
|
+
startSubscription() {
|
|
27820
|
+
return this.queryStreamController.subscribeRTE([
|
|
27821
|
+
{
|
|
27822
|
+
fn: onUserDeleted$2,
|
|
27823
|
+
action: EnumUserActions.OnUserDeleted,
|
|
27824
|
+
},
|
|
27825
|
+
// In the case of unblocking a user, we need to subscribe to the follow events
|
|
27826
|
+
{
|
|
27827
|
+
fn: convertEventPayload(onLocalUserFollowed, 'to', 'user'),
|
|
27828
|
+
action: EnumFollowActions.OnFollowed,
|
|
27829
|
+
},
|
|
27830
|
+
{
|
|
27831
|
+
fn: convertEventPayload(onUserFollowed, 'to', 'user'),
|
|
27832
|
+
action: EnumFollowActions.OnFollowed,
|
|
27833
|
+
},
|
|
27834
|
+
]);
|
|
27835
|
+
}
|
|
27836
|
+
notifyChange({ origin, loading, error }) {
|
|
27837
|
+
var _a, _b;
|
|
27838
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27839
|
+
if (!collection)
|
|
27840
|
+
return;
|
|
27841
|
+
const data = this.applyFilter((_b = collection.data
|
|
27842
|
+
.map(id => pullFromCache(['user', 'get', id]))
|
|
27843
|
+
.filter(isNonNullable)
|
|
27844
|
+
.map(({ data }) => data)
|
|
27845
|
+
.map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
|
|
27846
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
27847
|
+
return;
|
|
27848
|
+
this.callback({
|
|
27849
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
27850
|
+
data,
|
|
27851
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
27852
|
+
loading,
|
|
27853
|
+
error,
|
|
27854
|
+
});
|
|
27855
|
+
}
|
|
27856
|
+
// eslint-disable-next-line class-methods-use-this
|
|
27857
|
+
applyFilter(data) {
|
|
27858
|
+
let users = data;
|
|
27859
|
+
users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
|
|
27860
|
+
return users;
|
|
27861
|
+
}
|
|
27862
|
+
}
|
|
27863
|
+
|
|
27864
|
+
/* begin_public_function
|
|
27865
|
+
id: user.get_blocked_users
|
|
27866
|
+
*/
|
|
28236
27867
|
/**
|
|
28237
27868
|
* ```js
|
|
28238
|
-
* import {
|
|
28239
|
-
*
|
|
28240
|
-
* let user = {}
|
|
28241
|
-
* const dispose = observeUser(userId, updated => user = updated)
|
|
27869
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
27870
|
+
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
28242
27871
|
* ```
|
|
28243
27872
|
*
|
|
28244
|
-
*
|
|
28245
|
-
*
|
|
28246
|
-
* @
|
|
27873
|
+
* Blocks a {@link Amity.InternalUser}
|
|
27874
|
+
*
|
|
27875
|
+
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
27876
|
+
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
27877
|
+
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
28247
27878
|
*
|
|
28248
|
-
*
|
|
28249
|
-
* @
|
|
27879
|
+
* @category Post API
|
|
27880
|
+
* @async
|
|
28250
27881
|
*/
|
|
28251
|
-
const
|
|
28252
|
-
const { log } = getActiveClient();
|
|
27882
|
+
const getBlockedUsers = (params, callback, config) => {
|
|
27883
|
+
const { log, cache } = getActiveClient();
|
|
27884
|
+
if (!cache) {
|
|
27885
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
27886
|
+
}
|
|
28253
27887
|
const timestamp = Date.now();
|
|
28254
|
-
log(`
|
|
28255
|
-
|
|
28256
|
-
const
|
|
28257
|
-
|
|
28258
|
-
|
|
28259
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.userId) !== userId)
|
|
28260
|
-
return;
|
|
28261
|
-
const newResult = Object.assign(Object.assign({}, result), { data: LinkedObject.user(result.data) });
|
|
28262
|
-
if (callback instanceof Function)
|
|
28263
|
-
return callback(newResult);
|
|
28264
|
-
if (action !== 'onFetch')
|
|
28265
|
-
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, newResult);
|
|
28266
|
-
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, newResult);
|
|
28267
|
-
};
|
|
28268
|
-
const disposers = [];
|
|
28269
|
-
disposers.push(onUserUpdated(data => router({ data, loading: false, origin: 'event' }, 'onUpdate')), onUserDeleted$2(data => router({ data, loading: false, origin: 'event' }, 'onDelete')), onUserFlagged(data => router({ data, loading: false, origin: 'event' }, 'onFlagged')), onUserUnflagged(data => router({ data, loading: false, origin: 'event' }, 'onUnflagged')), onUserFlagCleared(data => router({ data, loading: false, origin: 'event' }, 'onFlagCleared')));
|
|
28270
|
-
runQuery(createQuery(getUser, userId), result => result.data && router(result, 'onFetch'));
|
|
27888
|
+
log(`getBlockedUsers(tmpid: ${timestamp}) > listen`);
|
|
27889
|
+
const blockedUserLiveCollection = new BlockedUserLiveCollectionController(params, callback);
|
|
27890
|
+
const disposers = blockedUserLiveCollection.startSubscription();
|
|
27891
|
+
const cacheKey = blockedUserLiveCollection.getCacheKey();
|
|
27892
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28271
27893
|
return () => {
|
|
28272
|
-
log(`
|
|
27894
|
+
log(`getBlockedUsers(tmpid: ${timestamp}) > dispose`);
|
|
28273
27895
|
disposers.forEach(fn => fn());
|
|
27896
|
+
dropFromCache(cacheKey);
|
|
28274
27897
|
};
|
|
28275
|
-
};
|
|
27898
|
+
};
|
|
27899
|
+
/* end_public_function */
|
|
28276
27900
|
|
|
28277
27901
|
class SearchUserPaginationController extends PaginationController {
|
|
28278
27902
|
async getRequest(queryParams, token) {
|
|
@@ -28457,74 +28081,6 @@ const queryReachUser = async ({ viewId, viewedType, limit, token, }) => {
|
|
|
28457
28081
|
return response.data;
|
|
28458
28082
|
};
|
|
28459
28083
|
|
|
28460
|
-
/**
|
|
28461
|
-
* @deprecated: Please use {@link UserRepository.getReachUsers} instead
|
|
28462
|
-
* @param params
|
|
28463
|
-
* @param callback
|
|
28464
|
-
*/
|
|
28465
|
-
const getViewedUsers = (params, callback) => {
|
|
28466
|
-
const { log, cache } = getActiveClient();
|
|
28467
|
-
const cacheKey = ['postViewedUsers', 'collection', { postId: params.postId }];
|
|
28468
|
-
if (!cache) {
|
|
28469
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
28470
|
-
}
|
|
28471
|
-
const timestamp = Date.now();
|
|
28472
|
-
log(`getViewedUsers(tmpid: ${timestamp}) > listen`);
|
|
28473
|
-
const { limit: queryLimit, postId } = params;
|
|
28474
|
-
const responder = (snapshot) => {
|
|
28475
|
-
var _a, _b;
|
|
28476
|
-
let users = [];
|
|
28477
|
-
if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.data) {
|
|
28478
|
-
users =
|
|
28479
|
-
snapshot.data
|
|
28480
|
-
.map((userId) => pullFromCache(['user', 'get', userId]))
|
|
28481
|
-
.filter(Boolean)
|
|
28482
|
-
.map(data => data === null || data === void 0 ? void 0 : data.data) || [];
|
|
28483
|
-
}
|
|
28484
|
-
callback({
|
|
28485
|
-
// eslint-disable-next-line no-use-before-define
|
|
28486
|
-
onNextPage: onFetch,
|
|
28487
|
-
data: users,
|
|
28488
|
-
hasNextPage: !!((_b = (_a = snapshot.params) === null || _a === void 0 ? void 0 : _a.page) === null || _b === void 0 ? void 0 : _b.next),
|
|
28489
|
-
loading: snapshot.loading || false,
|
|
28490
|
-
});
|
|
28491
|
-
};
|
|
28492
|
-
const onFetch = (initial = false) => {
|
|
28493
|
-
var _a, _b, _c;
|
|
28494
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28495
|
-
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28496
|
-
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
28497
|
-
return;
|
|
28498
|
-
const query = createQuery(queryReachUser, {
|
|
28499
|
-
viewId: postId,
|
|
28500
|
-
viewedType: "post" /* Amity.AnalyticEventContentType.Post */,
|
|
28501
|
-
limit: queryLimit || 10,
|
|
28502
|
-
token: !initial ? (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) === null || _c === void 0 ? void 0 : _c.next : undefined,
|
|
28503
|
-
});
|
|
28504
|
-
runQuery(query, result => {
|
|
28505
|
-
var _a, _b, _c, _d, _e;
|
|
28506
|
-
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 : [];
|
|
28507
|
-
if ((_d = result.data) === null || _d === void 0 ? void 0 : _d.users) {
|
|
28508
|
-
userIds = [
|
|
28509
|
-
...new Set([...userIds, ...result.data.users.map(({ userId }) => userId)]),
|
|
28510
|
-
];
|
|
28511
|
-
}
|
|
28512
|
-
const saveToCache = {
|
|
28513
|
-
loading: result.loading,
|
|
28514
|
-
params: { page: (_e = result.data) === null || _e === void 0 ? void 0 : _e.paging },
|
|
28515
|
-
data: userIds || [],
|
|
28516
|
-
};
|
|
28517
|
-
pushToCache(cacheKey, saveToCache);
|
|
28518
|
-
responder(saveToCache);
|
|
28519
|
-
}, queryOptions(COLLECTION_DEFAULT_CACHING_POLICY, CACHE_SHORTEN_LIFESPAN));
|
|
28520
|
-
};
|
|
28521
|
-
onFetch(true);
|
|
28522
|
-
return () => {
|
|
28523
|
-
log(`getViewedUsers(tmpid: ${timestamp}) > dispose`);
|
|
28524
|
-
dropFromCache(cacheKey);
|
|
28525
|
-
};
|
|
28526
|
-
};
|
|
28527
|
-
|
|
28528
28084
|
const getReachedUsers = (params, callback) => {
|
|
28529
28085
|
// Pre-defined function to avoid undefined function call
|
|
28530
28086
|
let onFetch = (initial = false) => undefined;
|
|
@@ -28612,12 +28168,10 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
28612
28168
|
onUserFlagged: onUserFlagged,
|
|
28613
28169
|
onUserUnflagged: onUserUnflagged,
|
|
28614
28170
|
onUserFlagCleared: onUserFlagCleared,
|
|
28615
|
-
getUser: getUser
|
|
28171
|
+
getUser: getUser,
|
|
28616
28172
|
getUsers: getUsers,
|
|
28617
|
-
|
|
28618
|
-
getBlockedUsers: getBlockedUsers$1,
|
|
28173
|
+
getBlockedUsers: getBlockedUsers,
|
|
28619
28174
|
searchUserByDisplayName: searchUserByDisplayName,
|
|
28620
|
-
getViewedUsers: getViewedUsers,
|
|
28621
28175
|
getReachedUsers: getReachedUsers,
|
|
28622
28176
|
get AmityUserSearchMatchType () { return AmityUserSearchMatchType; }
|
|
28623
28177
|
});
|
|
@@ -28867,181 +28421,6 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
28867
28421
|
};
|
|
28868
28422
|
/* end_public_function */
|
|
28869
28423
|
|
|
28870
|
-
/**
|
|
28871
|
-
* ```js
|
|
28872
|
-
* import { createImage } from '@amityco/ts-sdk'
|
|
28873
|
-
* const created = await createImage(formData)
|
|
28874
|
-
* ```
|
|
28875
|
-
*
|
|
28876
|
-
* Creates an {@link Amity.File<'image'>}
|
|
28877
|
-
*
|
|
28878
|
-
* @param formData The data necessary to create a new {@link Amity.File<'image'>}
|
|
28879
|
-
* @param onProgress The callback to track the upload progress
|
|
28880
|
-
* @returns The newly created {@link Amity.File<'image'>}
|
|
28881
|
-
*
|
|
28882
|
-
* @category File API
|
|
28883
|
-
* @async
|
|
28884
|
-
*/
|
|
28885
|
-
const createImage = async (formData, onProgress) => {
|
|
28886
|
-
const client = getActiveClient();
|
|
28887
|
-
client.log('file/createImage', formData);
|
|
28888
|
-
const files = formData.getAll('files');
|
|
28889
|
-
if (!files.length)
|
|
28890
|
-
throw new Error('The formData object must have a `files` key.');
|
|
28891
|
-
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
28892
|
-
formData.append('accessType', accessType);
|
|
28893
|
-
formData.append('preferredFilename', files[0].name);
|
|
28894
|
-
const headers = 'getHeaders' in formData
|
|
28895
|
-
? formData.getHeaders()
|
|
28896
|
-
: { 'content-type': 'multipart/form-data' };
|
|
28897
|
-
const { data } = await client.http.post('/api/v4/images', formData, {
|
|
28898
|
-
headers,
|
|
28899
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
28900
|
-
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
28901
|
-
},
|
|
28902
|
-
});
|
|
28903
|
-
// API-FIX: payload should be serialized properly
|
|
28904
|
-
// const { files } = data
|
|
28905
|
-
const cachedAt = client.cache && Date.now();
|
|
28906
|
-
if (client.cache)
|
|
28907
|
-
ingestInCache({ files: data }, { cachedAt });
|
|
28908
|
-
return {
|
|
28909
|
-
data,
|
|
28910
|
-
cachedAt,
|
|
28911
|
-
};
|
|
28912
|
-
};
|
|
28913
|
-
/* end_public_function */
|
|
28914
|
-
|
|
28915
|
-
/**
|
|
28916
|
-
* ```js
|
|
28917
|
-
* import { FileRepository } from '@amityco/ts-sdk'
|
|
28918
|
-
* const created = await FileRepository.createFile(formData)
|
|
28919
|
-
* ```
|
|
28920
|
-
*
|
|
28921
|
-
* Creates an {@link Amity.File}
|
|
28922
|
-
*
|
|
28923
|
-
* @param formData The data necessary to create a new {@link Amity.File}
|
|
28924
|
-
* @param onProgress The callback to track the upload progress
|
|
28925
|
-
* @returns The newly created {@link Amity.File}
|
|
28926
|
-
*
|
|
28927
|
-
* @category File API
|
|
28928
|
-
* @async
|
|
28929
|
-
*/
|
|
28930
|
-
const createFile = async (formData, onProgress) => {
|
|
28931
|
-
const client = getActiveClient();
|
|
28932
|
-
client.log('file/createFile', formData);
|
|
28933
|
-
const files = formData.getAll('files');
|
|
28934
|
-
if (!files.length)
|
|
28935
|
-
throw new Error('The formData object must have a `files` key.');
|
|
28936
|
-
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
28937
|
-
formData.append('accessType', accessType);
|
|
28938
|
-
formData.append('preferredFilename', files[0].name);
|
|
28939
|
-
const headers = 'getHeaders' in formData
|
|
28940
|
-
? formData.getHeaders()
|
|
28941
|
-
: { 'content-type': 'multipart/form-data' };
|
|
28942
|
-
const { data } = await client.http.post('/api/v4/files', formData, {
|
|
28943
|
-
headers,
|
|
28944
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
28945
|
-
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
28946
|
-
},
|
|
28947
|
-
});
|
|
28948
|
-
// API-FIX: payload should be serialized properly
|
|
28949
|
-
// const { files } = data
|
|
28950
|
-
const cachedAt = client.cache && Date.now();
|
|
28951
|
-
if (client.cache)
|
|
28952
|
-
ingestInCache({ files: data }, { cachedAt });
|
|
28953
|
-
return {
|
|
28954
|
-
data,
|
|
28955
|
-
cachedAt,
|
|
28956
|
-
};
|
|
28957
|
-
};
|
|
28958
|
-
|
|
28959
|
-
/**
|
|
28960
|
-
* ```js
|
|
28961
|
-
* import { FileRepository } from '@amityco/ts-sdk'
|
|
28962
|
-
* const created = await FileRepository.createVideo(formData)
|
|
28963
|
-
* ```
|
|
28964
|
-
*
|
|
28965
|
-
* Creates an {@link Amity.File<'video'>}
|
|
28966
|
-
*
|
|
28967
|
-
* @param formData The data necessary to create a new {@link Amity.File<'video'>}
|
|
28968
|
-
* @param feedType The {@link Amity.File<'video'>} feed type
|
|
28969
|
-
* @param onProgress The callback to track the upload progress
|
|
28970
|
-
* @returns The newly uploaded {@link Amity.File<'video'>}
|
|
28971
|
-
*
|
|
28972
|
-
* @category File API
|
|
28973
|
-
* @async
|
|
28974
|
-
*/
|
|
28975
|
-
const createVideo = async (formData, feedType, onProgress) => {
|
|
28976
|
-
const client = getActiveClient();
|
|
28977
|
-
client.log('file/createVideo', formData);
|
|
28978
|
-
const files = formData.getAll('files');
|
|
28979
|
-
if (!files.length)
|
|
28980
|
-
throw new Error('The formData object must have a `files` key.');
|
|
28981
|
-
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
28982
|
-
formData.append('accessType', accessType);
|
|
28983
|
-
formData.append('preferredFilename', files[0].name);
|
|
28984
|
-
if (feedType) {
|
|
28985
|
-
formData.append('feedType', feedType);
|
|
28986
|
-
}
|
|
28987
|
-
const headers = 'getHeaders' in formData
|
|
28988
|
-
? formData.getHeaders()
|
|
28989
|
-
: { 'content-type': 'multipart/form-data' };
|
|
28990
|
-
const { data } = await client.http.post('/api/v4/videos', formData, {
|
|
28991
|
-
headers,
|
|
28992
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
28993
|
-
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
28994
|
-
},
|
|
28995
|
-
});
|
|
28996
|
-
// API-FIX: payload should be serialized properly
|
|
28997
|
-
// const { files } = data
|
|
28998
|
-
const cachedAt = client.cache && Date.now();
|
|
28999
|
-
if (client.cache)
|
|
29000
|
-
ingestInCache({ files: data }, { cachedAt });
|
|
29001
|
-
return {
|
|
29002
|
-
data,
|
|
29003
|
-
cachedAt,
|
|
29004
|
-
};
|
|
29005
|
-
};
|
|
29006
|
-
|
|
29007
|
-
/**
|
|
29008
|
-
* ```js
|
|
29009
|
-
* import { observeFile } from '@amityco/ts-sdk'
|
|
29010
|
-
*
|
|
29011
|
-
* let file = {}
|
|
29012
|
-
* const dispose = observeFile(fileId, updated => file = updated)
|
|
29013
|
-
* ```
|
|
29014
|
-
*
|
|
29015
|
-
* Observe all mutation on a given {@link Amity.File}
|
|
29016
|
-
*
|
|
29017
|
-
* @param fileId the ID of the file to observe
|
|
29018
|
-
* @param callback the function to call when new data are available
|
|
29019
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the file
|
|
29020
|
-
*
|
|
29021
|
-
* @category File Observer
|
|
29022
|
-
*/
|
|
29023
|
-
const observeFile = (fileId, callback) => {
|
|
29024
|
-
const { log } = getActiveClient();
|
|
29025
|
-
const timestamp = Date.now();
|
|
29026
|
-
log(`observeFile(tmpid: ${timestamp}) > listen`);
|
|
29027
|
-
// wrapper function to make sure
|
|
29028
|
-
const router = (result, action) => {
|
|
29029
|
-
var _a, _b, _c;
|
|
29030
|
-
// filter function
|
|
29031
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.fileId) !== fileId)
|
|
29032
|
-
return;
|
|
29033
|
-
if (callback instanceof Function)
|
|
29034
|
-
return callback(result);
|
|
29035
|
-
if (action !== 'onFetch')
|
|
29036
|
-
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, result);
|
|
29037
|
-
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, result);
|
|
29038
|
-
};
|
|
29039
|
-
runQuery(createQuery(getFile, fileId), result => result.data && router(result, 'onFetch'));
|
|
29040
|
-
return () => {
|
|
29041
|
-
log(`observeFile(tmpid: ${timestamp}) > dispose`);
|
|
29042
|
-
};
|
|
29043
|
-
};
|
|
29044
|
-
|
|
29045
28424
|
var index$i = /*#__PURE__*/Object.freeze({
|
|
29046
28425
|
__proto__: null,
|
|
29047
28426
|
getFile: getFile,
|
|
@@ -29049,11 +28428,7 @@ var index$i = /*#__PURE__*/Object.freeze({
|
|
|
29049
28428
|
deleteFile: deleteFile,
|
|
29050
28429
|
fileUrlWithSize: fileUrlWithSize,
|
|
29051
28430
|
uploadVideo: uploadVideo,
|
|
29052
|
-
uploadImage: uploadImage
|
|
29053
|
-
createImage: createImage,
|
|
29054
|
-
createFile: createFile,
|
|
29055
|
-
createVideo: createVideo,
|
|
29056
|
-
observeFile: observeFile
|
|
28431
|
+
uploadImage: uploadImage
|
|
29057
28432
|
});
|
|
29058
28433
|
|
|
29059
28434
|
/**
|
|
@@ -29074,16 +28449,12 @@ var index$i = /*#__PURE__*/Object.freeze({
|
|
|
29074
28449
|
const queryRoles = async (query) => {
|
|
29075
28450
|
const client = getActiveClient();
|
|
29076
28451
|
client.log('role/queryRoles', query);
|
|
29077
|
-
const _a = query !== null && query !== void 0 ? query : {}, {
|
|
28452
|
+
const _a = query !== null && query !== void 0 ? query : {}, { limit = 10, queryToken, displayName, sortBy } = _a, params = __rest(_a, ["limit", "queryToken", "displayName", "sortBy"]);
|
|
29078
28453
|
const options = (() => {
|
|
29079
28454
|
if (queryToken)
|
|
29080
28455
|
return { token: queryToken };
|
|
29081
28456
|
if (limit)
|
|
29082
28457
|
return { limit };
|
|
29083
|
-
if (page)
|
|
29084
|
-
return {
|
|
29085
|
-
token: toToken(page, 'skiplimit'),
|
|
29086
|
-
};
|
|
29087
28458
|
return undefined;
|
|
29088
28459
|
})();
|
|
29089
28460
|
// API-FIX: parameters should be querystring.
|
|
@@ -29211,12 +28582,9 @@ const dispatchReactable = (referenceType, model) => {
|
|
|
29211
28582
|
* @category Message API
|
|
29212
28583
|
* @async
|
|
29213
28584
|
*/
|
|
29214
|
-
const getMessage$
|
|
28585
|
+
const getMessage$1 = async (messageId, isLive = false) => {
|
|
29215
28586
|
const client = getActiveClient();
|
|
29216
28587
|
client.log('message/getMessage', messageId);
|
|
29217
|
-
if (!isLive) {
|
|
29218
|
-
console.log('getMessage will be deprecated on 15th November 2022, please use liveMessage instead.');
|
|
29219
|
-
}
|
|
29220
28588
|
isInTombstone('message', messageId);
|
|
29221
28589
|
let data;
|
|
29222
28590
|
try {
|
|
@@ -29253,7 +28621,7 @@ const getMessage$2 = async (messageId, isLive = false) => {
|
|
|
29253
28621
|
*
|
|
29254
28622
|
* @category Message API
|
|
29255
28623
|
*/
|
|
29256
|
-
getMessage$
|
|
28624
|
+
getMessage$1.locally = (messageId) => {
|
|
29257
28625
|
const client = getActiveClient();
|
|
29258
28626
|
client.log('message/getMessage.locally', messageId);
|
|
29259
28627
|
if (!client.cache)
|
|
@@ -31182,7 +30550,7 @@ const getChannel$1 = async (channelId) => {
|
|
|
31182
30550
|
ingestInCache(data, { cachedAt });
|
|
31183
30551
|
const { channels } = data;
|
|
31184
30552
|
return {
|
|
31185
|
-
data:
|
|
30553
|
+
data: channels.find(channel => channel.channelId === channelId),
|
|
31186
30554
|
cachedAt,
|
|
31187
30555
|
};
|
|
31188
30556
|
};
|
|
@@ -31212,7 +30580,7 @@ getChannel$1.locally = (channelId) => {
|
|
|
31212
30580
|
if (!cached || (cached === null || cached === void 0 ? void 0 : cached.length) === 0)
|
|
31213
30581
|
return;
|
|
31214
30582
|
return {
|
|
31215
|
-
data:
|
|
30583
|
+
data: cached[0].data,
|
|
31216
30584
|
cachedAt: cached[0].cachedAt,
|
|
31217
30585
|
};
|
|
31218
30586
|
};
|
|
@@ -31237,7 +30605,7 @@ const deleteChannel = async (channelId) => {
|
|
|
31237
30605
|
await client.http.delete(`/api/v3/channels/${encodeURIComponent(channelId)}`);
|
|
31238
30606
|
const deleted = await getChannel$1(channelId);
|
|
31239
30607
|
// no need for event, fired by server
|
|
31240
|
-
return deleted.data;
|
|
30608
|
+
return constructChannelDynamicValue(deleted.data);
|
|
31241
30609
|
};
|
|
31242
30610
|
|
|
31243
30611
|
/* begin_public_function
|
|
@@ -31359,81 +30727,6 @@ const unmuteChannel = async (channelId) => {
|
|
|
31359
30727
|
};
|
|
31360
30728
|
/* end_public_function */
|
|
31361
30729
|
|
|
31362
|
-
/**
|
|
31363
|
-
* ```js
|
|
31364
|
-
* import { observeChannel } from '@amityco/ts-sdk'
|
|
31365
|
-
*
|
|
31366
|
-
* let channel = {}
|
|
31367
|
-
* const dispose = observeChannel(channelId, ({ data }) => channel = data)
|
|
31368
|
-
* ```
|
|
31369
|
-
*
|
|
31370
|
-
* Observe all mutation on a given {@link Amity.Channel}
|
|
31371
|
-
*
|
|
31372
|
-
* @param channelId the ID of the channel to observe
|
|
31373
|
-
* @param callback the function to call when new data are available
|
|
31374
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channel
|
|
31375
|
-
*
|
|
31376
|
-
* @category Channel Observer
|
|
31377
|
-
*/
|
|
31378
|
-
const observeChannel = (channelId, callback) => {
|
|
31379
|
-
const { log } = getActiveClient();
|
|
31380
|
-
const timestamp = Date.now();
|
|
31381
|
-
log(`observeChannel(tmpid: ${timestamp}) > listen`);
|
|
31382
|
-
// wrapper function to make sure
|
|
31383
|
-
const router = (result, action) => {
|
|
31384
|
-
var _a, _b, _c;
|
|
31385
|
-
// filter function
|
|
31386
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.channelId) !== channelId)
|
|
31387
|
-
return;
|
|
31388
|
-
if (callback instanceof Function)
|
|
31389
|
-
return callback(Object.assign(Object.assign({}, result), { data: LinkedObject.channel(constructChannelDynamicValue(result.data)) }));
|
|
31390
|
-
if (action !== 'onFetch')
|
|
31391
|
-
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, Object.assign(Object.assign({}, result), { data: LinkedObject.channel(constructChannelDynamicValue(result.data)) }));
|
|
31392
|
-
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, Object.assign(Object.assign({}, result), { data: LinkedObject.channel(constructChannelDynamicValue(result.data)) }));
|
|
31393
|
-
};
|
|
31394
|
-
const disposers = [];
|
|
31395
|
-
disposers.push(onChannelUpdated(data => router({ data, loading: false, origin: 'event' }, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)), onChannelDeleted(data => router({ data, loading: false, origin: 'event' }, "onDelete" /* Amity.ChannelActionType.OnDelete */)), onChannelJoined(data => router({ data, loading: false, origin: 'event' }, "onJoin" /* Amity.ChannelActionType.OnJoin */)), onChannelLeft(data => router({ data, loading: false, origin: 'event' }, "onLeft" /* Amity.ChannelActionType.OnLeft */)), onChannelMuted(data => router({ data, loading: false, origin: 'event' }, "onMute" /* Amity.ChannelActionType.OnMute */)), onChannelMemberAdded(data => router({ data, loading: false, origin: 'event' }, "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */)), onChannelMemberRemoved(data => router({ data, loading: false, origin: 'event' }, "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */)), convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(data => router({ data, loading: false, origin: 'event' }, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)));
|
|
31396
|
-
runQuery(createQuery(getChannel$1, channelId), result => result.data && router(result, "onFetch" /* Amity.ChannelActionType.OnFetch */));
|
|
31397
|
-
return () => {
|
|
31398
|
-
log(`observeChannel(tmpid: ${timestamp}) > dispose`);
|
|
31399
|
-
disposers.forEach(fn => fn());
|
|
31400
|
-
};
|
|
31401
|
-
};
|
|
31402
|
-
|
|
31403
|
-
/**
|
|
31404
|
-
* ```js
|
|
31405
|
-
* import { observeChannels } from '@amityco/ts-sdk'
|
|
31406
|
-
*
|
|
31407
|
-
* let channels = []
|
|
31408
|
-
* const unsub = observeChannels(channel => merge(channels, channel))
|
|
31409
|
-
* ```
|
|
31410
|
-
*
|
|
31411
|
-
* Observe all mutations on a list of {@link Amity.Channel} for a current user
|
|
31412
|
-
*
|
|
31413
|
-
* @param callback the function to call when new data are available
|
|
31414
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channels
|
|
31415
|
-
*
|
|
31416
|
-
* @category Channel Observer
|
|
31417
|
-
*/
|
|
31418
|
-
const observeChannels = (callback) => {
|
|
31419
|
-
const { log } = getActiveClient();
|
|
31420
|
-
const timestamp = Date.now();
|
|
31421
|
-
log(`observeChannels(tmpid: ${timestamp}) > listen`);
|
|
31422
|
-
const disposers = [];
|
|
31423
|
-
const router = (channel, action) => {
|
|
31424
|
-
var _a, _b;
|
|
31425
|
-
if (callback instanceof Function)
|
|
31426
|
-
return callback(LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
31427
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
31428
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
31429
|
-
};
|
|
31430
|
-
disposers.push(onChannelCreated(data => router(data, "onCreate" /* Amity.ChannelActionType.OnCreate */)), onChannelUpdated(data => router(data, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)), onChannelDeleted(data => router(data, "onDelete" /* Amity.ChannelActionType.OnDelete */)), onChannelJoined(data => router(data, "onJoin" /* Amity.ChannelActionType.OnJoin */)), onChannelLeft(data => router(data, "onLeft" /* Amity.ChannelActionType.OnLeft */)), onChannelMuted(data => router(data, "onMute" /* Amity.ChannelActionType.OnMute */)), onChannelMemberAdded(data => router(data, "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */)), onChannelMemberRemoved(data => router(data, "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */)), convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(data => router(data, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)));
|
|
31431
|
-
return () => {
|
|
31432
|
-
log(`observeChannels(tmpid: ${timestamp}) > dispose`);
|
|
31433
|
-
disposers.forEach(fn => fn());
|
|
31434
|
-
};
|
|
31435
|
-
};
|
|
31436
|
-
|
|
31437
30730
|
/**
|
|
31438
30731
|
* ```js
|
|
31439
30732
|
* import { onMessageUpdated } from '@amityco/ts-sdk'
|
|
@@ -31712,69 +31005,6 @@ const onSubChannelFetched = (callback) => {
|
|
|
31712
31005
|
return createEventSubscriber(getActiveClient(), 'onSubChannelFetched', 'local.message-feed.fetched', payload => callback(payload.messageFeeds[0]));
|
|
31713
31006
|
};
|
|
31714
31007
|
|
|
31715
|
-
/**
|
|
31716
|
-
* ```js
|
|
31717
|
-
* import { getMessages } from '@amityco/ts-sdk'
|
|
31718
|
-
* const messages = await getMessages(['foo', 'bar'])
|
|
31719
|
-
* ```
|
|
31720
|
-
*
|
|
31721
|
-
* Fetches a collection of {@link Amity.Message} objects
|
|
31722
|
-
*
|
|
31723
|
-
* @param messageIds the IDs of the {@link Amity.Message} to fetch
|
|
31724
|
-
* @returns the associated collection of {@link Amity.Message} objects
|
|
31725
|
-
*
|
|
31726
|
-
* @category Message API
|
|
31727
|
-
* @async
|
|
31728
|
-
*/
|
|
31729
|
-
const getMessages$1 = async (messageIds) => {
|
|
31730
|
-
const client = getActiveClient();
|
|
31731
|
-
client.log('message/getMessages', messageIds);
|
|
31732
|
-
const { data: payload } = await client.http.get(`/api/v5/messages/list`, {
|
|
31733
|
-
params: { messageIds: messageIds.map(encodeURIComponent) },
|
|
31734
|
-
});
|
|
31735
|
-
const data = await prepareMessagePayload(payload);
|
|
31736
|
-
const cachedAt = client.cache && Date.now();
|
|
31737
|
-
if (client.cache)
|
|
31738
|
-
ingestInCache(data, { cachedAt });
|
|
31739
|
-
const { messages } = data;
|
|
31740
|
-
fireEvent('local.message.fetched', { messages });
|
|
31741
|
-
return {
|
|
31742
|
-
data: messages.map(message => LinkedObject.message(message)),
|
|
31743
|
-
cachedAt,
|
|
31744
|
-
};
|
|
31745
|
-
};
|
|
31746
|
-
/**
|
|
31747
|
-
* ```js
|
|
31748
|
-
* import { getMessages } from '@amityco/ts-sdk'
|
|
31749
|
-
* const messages = getMessages.locally(['foo', 'bar']) ?? []
|
|
31750
|
-
* ```
|
|
31751
|
-
*
|
|
31752
|
-
* Fetches a collection of {@link Amity.Message} objects from cache
|
|
31753
|
-
*
|
|
31754
|
-
* @param messageIds the IDs of the {@link Amity.Message} to fetch
|
|
31755
|
-
* @returns the associated collection of {@link Amity.Message} objects
|
|
31756
|
-
*
|
|
31757
|
-
* @category Message API
|
|
31758
|
-
*/
|
|
31759
|
-
getMessages$1.locally = (messageIds) => {
|
|
31760
|
-
var _a;
|
|
31761
|
-
const client = getActiveClient();
|
|
31762
|
-
client.log('message/getMessages.locally', messageIds);
|
|
31763
|
-
if (!client.cache)
|
|
31764
|
-
return;
|
|
31765
|
-
const cached = messageIds
|
|
31766
|
-
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
31767
|
-
.filter(Boolean);
|
|
31768
|
-
const messages = cached.map(({ data }) => data);
|
|
31769
|
-
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
31770
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) < messageIds.length)
|
|
31771
|
-
return;
|
|
31772
|
-
return {
|
|
31773
|
-
data: messages,
|
|
31774
|
-
cachedAt: oldest.cachedAt,
|
|
31775
|
-
};
|
|
31776
|
-
};
|
|
31777
|
-
|
|
31778
31008
|
const getLocalId = () => `LOCAL_${uuid()}`;
|
|
31779
31009
|
// FIXME: temp solution
|
|
31780
31010
|
let uniqueId;
|
|
@@ -31799,7 +31029,11 @@ const createMessageOptimistic = (bundle) => {
|
|
|
31799
31029
|
if (subChannel) {
|
|
31800
31030
|
upsertInCache(['subChannel', 'get', bundle.subChannelId], Object.assign(Object.assign({}, subChannel.data), { messageCount: subChannel.data.messageCount + 1 }));
|
|
31801
31031
|
if (subChannel.data.channelId === subChannel.data.subChannelId) {
|
|
31802
|
-
const channel = pullFromCache([
|
|
31032
|
+
const channel = pullFromCache([
|
|
31033
|
+
'channel',
|
|
31034
|
+
'get',
|
|
31035
|
+
subChannel.data.channelId,
|
|
31036
|
+
]);
|
|
31803
31037
|
if (channel === null || channel === void 0 ? void 0 : channel.data) {
|
|
31804
31038
|
upsertInCache(['channel', 'get', subChannel.data.channelId], Object.assign(Object.assign({}, channel.data), { messageCount: ((_a = channel.data.messageCount) !== null && _a !== void 0 ? _a : 0) + 1 }));
|
|
31805
31039
|
}
|
|
@@ -32087,7 +31321,7 @@ const softDeleteMessage = async (messageId) => {
|
|
|
32087
31321
|
client.log('message/softDeleteMessage', messageId);
|
|
32088
31322
|
// API-FIX: This endpoint has not been implemented yet.
|
|
32089
31323
|
await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}`);
|
|
32090
|
-
const deleted = await getMessage$
|
|
31324
|
+
const deleted = await getMessage$1(messageId);
|
|
32091
31325
|
fireEvent('local.message.deleted', { messages: [deleted.data] });
|
|
32092
31326
|
return LinkedObject.message(deleted.data);
|
|
32093
31327
|
};
|
|
@@ -32561,12 +31795,12 @@ const onMessageFetched = (callback) => {
|
|
|
32561
31795
|
*
|
|
32562
31796
|
* @category Message Live Object
|
|
32563
31797
|
*/
|
|
32564
|
-
const getMessage
|
|
31798
|
+
const getMessage = (messageId, callback) => {
|
|
32565
31799
|
const responder = (snapshot) => {
|
|
32566
31800
|
const { data } = snapshot;
|
|
32567
31801
|
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.message(snapshot.data) : data }));
|
|
32568
31802
|
};
|
|
32569
|
-
return liveObject(messageId, responder, 'messageId', getMessage$
|
|
31803
|
+
return liveObject(messageId, responder, 'messageId', getMessage$1, [
|
|
32570
31804
|
onMessageFetched,
|
|
32571
31805
|
onMessageUpdated,
|
|
32572
31806
|
onMessageDeleted,
|
|
@@ -32615,7 +31849,7 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
32615
31849
|
}
|
|
32616
31850
|
reactor(action) {
|
|
32617
31851
|
return (payload) => {
|
|
32618
|
-
var _a, _b, _c
|
|
31852
|
+
var _a, _b, _c;
|
|
32619
31853
|
if (action === 'onCreate') {
|
|
32620
31854
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32621
31855
|
const { referenceId } = payload;
|
|
@@ -32625,14 +31859,9 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
32625
31859
|
return;
|
|
32626
31860
|
if (this.query.type && this.query.type !== payload.dataType)
|
|
32627
31861
|
return;
|
|
32628
|
-
if (this.query.dataType && this.query.dataType !== payload.dataType)
|
|
32629
|
-
return;
|
|
32630
31862
|
if (this.query.excludingTags &&
|
|
32631
31863
|
((_b = this.query.excludingTags) === null || _b === void 0 ? void 0 : _b.some(value => { var _a; return (_a = payload.tags) === null || _a === void 0 ? void 0 : _a.includes(value); })))
|
|
32632
31864
|
return;
|
|
32633
|
-
if (this.query.excludeTags &&
|
|
32634
|
-
((_c = this.query.excludeTags) === null || _c === void 0 ? void 0 : _c.some(value => { var _a; return (_a = payload.tags) === null || _a === void 0 ? void 0 : _a.includes(value); })))
|
|
32635
|
-
return;
|
|
32636
31865
|
if (!!this.query.hasFlags !== !!payload.flagCount)
|
|
32637
31866
|
return;
|
|
32638
31867
|
if (this.query.parentId && this.query.parentId !== payload.parentId)
|
|
@@ -32642,9 +31871,7 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
32642
31871
|
payload.isDeleted)
|
|
32643
31872
|
return;
|
|
32644
31873
|
if (this.query.includingTags &&
|
|
32645
|
-
!((
|
|
32646
|
-
return;
|
|
32647
|
-
if (this.query.tags && !((_e = this.query.tags) === null || _e === void 0 ? void 0 : _e.some(value => { var _a; return (_a = payload.tags) === null || _a === void 0 ? void 0 : _a.includes(value); })))
|
|
31874
|
+
!((_c = this.query.includingTags) === null || _c === void 0 ? void 0 : _c.some(value => { var _a; return (_a = payload.tags) === null || _a === void 0 ? void 0 : _a.includes(value); })))
|
|
32648
31875
|
return;
|
|
32649
31876
|
if ((!this.query.sortBy || this.query.sortBy === 'segmentDesc') &&
|
|
32650
31877
|
!this.paginationController.getPrevToken()) {
|
|
@@ -32744,26 +31971,6 @@ class MessageLiveCollectionController extends LiveCollectionController {
|
|
|
32744
31971
|
}
|
|
32745
31972
|
applyFilter(data) {
|
|
32746
31973
|
let messages = data;
|
|
32747
|
-
messages = messages.filter(m => {
|
|
32748
|
-
if (this.query.tags) {
|
|
32749
|
-
return this.query.tags.find(value => {
|
|
32750
|
-
if (!m.tags)
|
|
32751
|
-
return false;
|
|
32752
|
-
return m.tags.includes(value);
|
|
32753
|
-
});
|
|
32754
|
-
}
|
|
32755
|
-
return true;
|
|
32756
|
-
});
|
|
32757
|
-
messages = messages.filter(m => {
|
|
32758
|
-
if (this.query.excludeTags) {
|
|
32759
|
-
return (this.query.excludeTags || []).find(value => {
|
|
32760
|
-
if (!m.tags)
|
|
32761
|
-
return true;
|
|
32762
|
-
return !m.tags.includes(value);
|
|
32763
|
-
});
|
|
32764
|
-
}
|
|
32765
|
-
return true;
|
|
32766
|
-
});
|
|
32767
31974
|
/*
|
|
32768
31975
|
* for cases when message is deleted via RTE, this flag is used to get
|
|
32769
31976
|
* items from cache that are !deleted
|
|
@@ -32800,7 +32007,6 @@ class MessageLiveCollectionController extends LiveCollectionController {
|
|
|
32800
32007
|
}
|
|
32801
32008
|
}
|
|
32802
32009
|
|
|
32803
|
-
/* eslint-disable no-use-before-define */
|
|
32804
32010
|
/* begin_public_function
|
|
32805
32011
|
id: message.query
|
|
32806
32012
|
*/
|
|
@@ -32843,164 +32049,8 @@ const getMessages = (params, callback, config) => {
|
|
|
32843
32049
|
};
|
|
32844
32050
|
/* end_public_function */
|
|
32845
32051
|
|
|
32846
|
-
/**
|
|
32847
|
-
* ```js
|
|
32848
|
-
* import { getMessage } from '@amityco/ts-sdk'
|
|
32849
|
-
* const message = await getMessage('foobar')
|
|
32850
|
-
* ```
|
|
32851
|
-
*
|
|
32852
|
-
* Fetches a {@link Amity.Message} object
|
|
32853
|
-
*
|
|
32854
|
-
* @param messageId the ID of the {@link Amity.Message} to fetch
|
|
32855
|
-
* @returns the associated {@link Amity.Message} object
|
|
32856
|
-
*
|
|
32857
|
-
* @category Message API
|
|
32858
|
-
* @async
|
|
32859
|
-
*/
|
|
32860
|
-
const getMessage = async (messageId, isLive = false) => {
|
|
32861
|
-
const client = getActiveClient();
|
|
32862
|
-
client.log('message/getMessage', messageId);
|
|
32863
|
-
if (!isLive) {
|
|
32864
|
-
console.log('getMessage will be deprecated on 15th November 2022, please use liveMessage instead.');
|
|
32865
|
-
}
|
|
32866
|
-
isInTombstone('message', messageId);
|
|
32867
|
-
let data;
|
|
32868
|
-
try {
|
|
32869
|
-
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
32870
|
-
const { data: payload } = await client.http.get(`/api/v5/messages/${encodeURIComponent(messageId)}`);
|
|
32871
|
-
data = await prepareMessagePayload(payload);
|
|
32872
|
-
}
|
|
32873
|
-
catch (error) {
|
|
32874
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
32875
|
-
pushToTombstone('message', messageId);
|
|
32876
|
-
}
|
|
32877
|
-
throw error;
|
|
32878
|
-
}
|
|
32879
|
-
const cachedAt = client.cache && Date.now();
|
|
32880
|
-
if (client.cache)
|
|
32881
|
-
ingestInCache(data, { cachedAt });
|
|
32882
|
-
const { messages } = data;
|
|
32883
|
-
fireEvent('local.message.fetched', { messages });
|
|
32884
|
-
return {
|
|
32885
|
-
data: LinkedObject.message(messages.find(message => message.messageId === messageId)),
|
|
32886
|
-
cachedAt,
|
|
32887
|
-
};
|
|
32888
|
-
};
|
|
32889
|
-
/**
|
|
32890
|
-
* ```js
|
|
32891
|
-
* import { getMessage } from '@amityco/ts-sdk'
|
|
32892
|
-
* const message = getMessage.locally('foobar')
|
|
32893
|
-
* ```
|
|
32894
|
-
*
|
|
32895
|
-
* Fetches a {@link Amity.Message} object
|
|
32896
|
-
*
|
|
32897
|
-
* @param messageId the ID of the {@link Amity.Message} to fetch
|
|
32898
|
-
* @returns the associated {@link Amity.Message} object
|
|
32899
|
-
*
|
|
32900
|
-
* @category Message API
|
|
32901
|
-
*/
|
|
32902
|
-
getMessage.locally = (messageId) => {
|
|
32903
|
-
const client = getActiveClient();
|
|
32904
|
-
client.log('message/getMessage.locally', messageId);
|
|
32905
|
-
if (!client.cache)
|
|
32906
|
-
return;
|
|
32907
|
-
const cached = pullFromCache(['message', 'get', messageId]);
|
|
32908
|
-
if (!cached)
|
|
32909
|
-
return;
|
|
32910
|
-
return {
|
|
32911
|
-
data: cached.data,
|
|
32912
|
-
cachedAt: cached.cachedAt,
|
|
32913
|
-
};
|
|
32914
|
-
};
|
|
32915
|
-
|
|
32916
|
-
/**
|
|
32917
|
-
* ```js
|
|
32918
|
-
* import { observeMessage } from '@amityco/ts-sdk'
|
|
32919
|
-
*
|
|
32920
|
-
* let message = {}
|
|
32921
|
-
*
|
|
32922
|
-
* const unsub = observeMessage(messageId, updated => message = updated)
|
|
32923
|
-
* ```
|
|
32924
|
-
*
|
|
32925
|
-
* Observe all mutations on a {@link Amity.Message} given a single messageId
|
|
32926
|
-
*
|
|
32927
|
-
* @param client the client to observe the message with
|
|
32928
|
-
* @param messageId the ID of the message to observe
|
|
32929
|
-
* @param callback the function to call when new data are available
|
|
32930
|
-
* @param policy a query policy option for this observer
|
|
32931
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
|
|
32932
|
-
*
|
|
32933
|
-
* @category Message Observer
|
|
32934
|
-
*/
|
|
32935
|
-
const observeMessage = (messageId, callback, policy = 'cache_then_server') => {
|
|
32936
|
-
const { log } = getActiveClient();
|
|
32937
|
-
const timestamp = Date.now();
|
|
32938
|
-
log(`observeMessage(tmpid: ${timestamp}) > listen`);
|
|
32939
|
-
console.log('observeMessage will be deprecated on 15th November 2022, please use liveMessage instead.');
|
|
32940
|
-
// wrapper function to make sure
|
|
32941
|
-
const router = (result, action) => {
|
|
32942
|
-
var _a, _b, _c;
|
|
32943
|
-
// filter function
|
|
32944
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.messageId) !== messageId)
|
|
32945
|
-
return;
|
|
32946
|
-
if (callback instanceof Function)
|
|
32947
|
-
return callback(result);
|
|
32948
|
-
if (action !== 'onFetch')
|
|
32949
|
-
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, result);
|
|
32950
|
-
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, result);
|
|
32951
|
-
};
|
|
32952
|
-
const disposers = [];
|
|
32953
|
-
disposers.push(onMessageUpdated(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onUpdate')), onMessageDeleted(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onDelete')), convertEventPayload(onMessageMarkerFetched, 'contentId', 'message')(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onUpdate')), convertEventPayload(onMessageMarked, 'contentId', 'message')(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onUpdate')));
|
|
32954
|
-
if (policy !== 'no_fetch') {
|
|
32955
|
-
runQuery(createQuery(getMessage, messageId), result => result.data && router(result, 'onFetch'), queryOptions(policy));
|
|
32956
|
-
}
|
|
32957
|
-
return () => {
|
|
32958
|
-
log(`observeMessages(tmpid: ${timestamp}) > dispose`);
|
|
32959
|
-
disposers.forEach(fn => fn());
|
|
32960
|
-
};
|
|
32961
|
-
};
|
|
32962
|
-
|
|
32963
|
-
/**
|
|
32964
|
-
* ```js
|
|
32965
|
-
* import { observeMessages } from '@amityco/ts-sdk'
|
|
32966
|
-
*
|
|
32967
|
-
* let messages = []
|
|
32968
|
-
*
|
|
32969
|
-
* const unsubscribe = observeMessages(channelId, message => merge(messages, message))
|
|
32970
|
-
* ```
|
|
32971
|
-
*
|
|
32972
|
-
* Observe all mutations on a list of {@link Amity.Message} for a given {@link Amity.SubChannel} object
|
|
32973
|
-
*
|
|
32974
|
-
* @param subChannelId the ID of the channel where to observe the messages
|
|
32975
|
-
* @param callback the function to call when new data are available
|
|
32976
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
32977
|
-
*
|
|
32978
|
-
* @category Message Observer
|
|
32979
|
-
*/
|
|
32980
|
-
const observeMessages = (subChannelId, callback) => {
|
|
32981
|
-
const { log } = getActiveClient();
|
|
32982
|
-
const timestamp = Date.now();
|
|
32983
|
-
log(`observeMessages(tmpid: ${timestamp}) > listen`);
|
|
32984
|
-
const disposers = [];
|
|
32985
|
-
const router = (message, action) => {
|
|
32986
|
-
var _a, _b, _c;
|
|
32987
|
-
if (((_a = message.data) === null || _a === void 0 ? void 0 : _a.subChannelId) !== subChannelId)
|
|
32988
|
-
return;
|
|
32989
|
-
if (callback instanceof Function)
|
|
32990
|
-
return callback(message);
|
|
32991
|
-
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, message);
|
|
32992
|
-
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, message);
|
|
32993
|
-
};
|
|
32994
|
-
disposers.push(onMessageCreatedMqtt(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onCreate')), onMessageCreatedLocal(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onCreate')), onMessageUpdated(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onUpdate')), onMessageDeleted(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onDelete')), convertEventPayload(onMessageMarkerFetched, 'contentId', 'message')(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onCreate')), convertEventPayload(onMessageMarked, 'contentId', 'message')(data => router({ data: LinkedObject.message(data), loading: false, origin: 'event' }, 'onCreate')));
|
|
32995
|
-
return () => {
|
|
32996
|
-
log(`observeMessages(tmpid: ${timestamp}) > dispose`);
|
|
32997
|
-
disposers.forEach(fn => fn());
|
|
32998
|
-
};
|
|
32999
|
-
};
|
|
33000
|
-
|
|
33001
32052
|
var index$g = /*#__PURE__*/Object.freeze({
|
|
33002
32053
|
__proto__: null,
|
|
33003
|
-
getMessageByIds: getMessages$1,
|
|
33004
32054
|
createMessage: createMessage,
|
|
33005
32055
|
updateMessage: updateMessage,
|
|
33006
32056
|
editMessage: editMessage,
|
|
@@ -33022,10 +32072,8 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
33022
32072
|
onMessageReactionAdded: onMessageReactionAdded,
|
|
33023
32073
|
onMessageReactionRemoved: onMessageReactionRemoved,
|
|
33024
32074
|
onMessageFetched: onMessageFetched,
|
|
33025
|
-
getMessage: getMessage
|
|
32075
|
+
getMessage: getMessage,
|
|
33026
32076
|
getMessages: getMessages,
|
|
33027
|
-
observeMessage: observeMessage,
|
|
33028
|
-
observeMessages: observeMessages,
|
|
33029
32077
|
convertFromRaw: convertFromRaw$1,
|
|
33030
32078
|
prepareMessagePayload: prepareMessagePayload,
|
|
33031
32079
|
convertParams: convertParams,
|
|
@@ -33542,8 +32590,6 @@ var index$f = /*#__PURE__*/Object.freeze({
|
|
|
33542
32590
|
getSubChannel: getSubChannel,
|
|
33543
32591
|
getSubChannels: getSubChannels,
|
|
33544
32592
|
markReadEngineOnLoginHandler: markReadEngineOnLoginHandler,
|
|
33545
|
-
startReading: startReading,
|
|
33546
|
-
stopReading: stopReading,
|
|
33547
32593
|
startMessageReceiptSync: startMessageReceiptSync,
|
|
33548
32594
|
stopMessageReceiptSync: stopMessageReceiptSync
|
|
33549
32595
|
});
|
|
@@ -33594,7 +32640,7 @@ const getChannel = (channelId, callback) => {
|
|
|
33594
32640
|
const reactor = async (response) => {
|
|
33595
32641
|
if (!response.data)
|
|
33596
32642
|
return callback(response);
|
|
33597
|
-
const data = Object.assign(Object.assign({}, response), { data:
|
|
32643
|
+
const data = Object.assign(Object.assign({}, response), { data: constructChannelObject(response.data) });
|
|
33598
32644
|
const newSnapshot = __rest(data, ["origin"]);
|
|
33599
32645
|
/**
|
|
33600
32646
|
* check equality of previous data and current data to avoid redundancy
|
|
@@ -33628,7 +32674,11 @@ const getChannel = (channelId, callback) => {
|
|
|
33628
32674
|
if (message.channelId !== channelId)
|
|
33629
32675
|
return;
|
|
33630
32676
|
// channelId from message is channelInternalId
|
|
33631
|
-
const channel = (_a = pullFromCache([
|
|
32677
|
+
const channel = (_a = pullFromCache([
|
|
32678
|
+
'channel',
|
|
32679
|
+
'get',
|
|
32680
|
+
channelId,
|
|
32681
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33632
32682
|
if (!channel)
|
|
33633
32683
|
return;
|
|
33634
32684
|
updateChannelCache(channel, {
|
|
@@ -33651,7 +32701,11 @@ const getChannel = (channelId, callback) => {
|
|
|
33651
32701
|
if (message.channelId !== channelId)
|
|
33652
32702
|
return;
|
|
33653
32703
|
// channelId from message is channelInternalId
|
|
33654
|
-
const channel = (_a = pullFromCache([
|
|
32704
|
+
const channel = (_a = pullFromCache([
|
|
32705
|
+
'channel',
|
|
32706
|
+
'get',
|
|
32707
|
+
channelId,
|
|
32708
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33655
32709
|
if (!channel)
|
|
33656
32710
|
return;
|
|
33657
32711
|
updateChannelCache(channel, {
|
|
@@ -33664,7 +32718,11 @@ const getChannel = (channelId, callback) => {
|
|
|
33664
32718
|
convertEventPayload((callback) => {
|
|
33665
32719
|
const updateMessagePreview = async (message) => {
|
|
33666
32720
|
var _a;
|
|
33667
|
-
const channel = (_a = pullFromCache([
|
|
32721
|
+
const channel = (_a = pullFromCache([
|
|
32722
|
+
'channel',
|
|
32723
|
+
'get',
|
|
32724
|
+
channelId,
|
|
32725
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33668
32726
|
if (!channel || channel.messagePreviewId !== message.messageId)
|
|
33669
32727
|
return;
|
|
33670
32728
|
const messagePreviewSetting = await client.getMessagePreviewSetting(false);
|
|
@@ -33678,7 +32736,11 @@ const getChannel = (channelId, callback) => {
|
|
|
33678
32736
|
convertEventPayload((callback) => {
|
|
33679
32737
|
const updateMessagePreview = async (message) => {
|
|
33680
32738
|
var _a;
|
|
33681
|
-
const channel = (_a = pullFromCache([
|
|
32739
|
+
const channel = (_a = pullFromCache([
|
|
32740
|
+
'channel',
|
|
32741
|
+
'get',
|
|
32742
|
+
channelId,
|
|
32743
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33682
32744
|
if (!channel || channel.messagePreviewId !== message.messageId)
|
|
33683
32745
|
return;
|
|
33684
32746
|
const messagePreviewSetting = await client.getMessagePreviewSetting(false);
|
|
@@ -33711,7 +32773,11 @@ const getChannel = (channelId, callback) => {
|
|
|
33711
32773
|
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
33712
32774
|
return;
|
|
33713
32775
|
await getChannel$1(channelId);
|
|
33714
|
-
const channel = (_b = pullFromCache([
|
|
32776
|
+
const channel = (_b = pullFromCache([
|
|
32777
|
+
'channel',
|
|
32778
|
+
'get',
|
|
32779
|
+
channelId,
|
|
32780
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
33715
32781
|
if (!channel)
|
|
33716
32782
|
return;
|
|
33717
32783
|
callback(subChannel);
|
|
@@ -33733,7 +32799,11 @@ const getChannel = (channelId, callback) => {
|
|
|
33733
32799
|
if (!messagePreviewCache ||
|
|
33734
32800
|
messagePreviewCache.subChannelId !== subChannel.subChannelId)
|
|
33735
32801
|
return;
|
|
33736
|
-
const channel = (_b = pullFromCache([
|
|
32802
|
+
const channel = (_b = pullFromCache([
|
|
32803
|
+
'channel',
|
|
32804
|
+
'get',
|
|
32805
|
+
channelId,
|
|
32806
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
33737
32807
|
if (!channel)
|
|
33738
32808
|
return;
|
|
33739
32809
|
callback(subChannel);
|
|
@@ -33929,9 +32999,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
33929
32999
|
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
33930
33000
|
.filter(Boolean)
|
|
33931
33001
|
.map(({ data }) => data)
|
|
33932
|
-
.map(
|
|
33933
|
-
.map(constructChannelDynamicValue)
|
|
33934
|
-
.map(LinkedObject.channel)) !== null && _b !== void 0 ? _b : [];
|
|
33002
|
+
.map(constructChannelObject)) !== null && _b !== void 0 ? _b : [];
|
|
33935
33003
|
if (this.paginationController instanceof ChannelPaginationController) {
|
|
33936
33004
|
data = this.applyFilter(data);
|
|
33937
33005
|
}
|
|
@@ -34578,11 +33646,6 @@ class ChannelMemberLiveCollectionController extends LiveCollectionController {
|
|
|
34578
33646
|
return false;
|
|
34579
33647
|
});
|
|
34580
33648
|
}
|
|
34581
|
-
if (this.query.search) {
|
|
34582
|
-
// eslint-disable-next-line no-console
|
|
34583
|
-
console.warn('`search` param will be deprecated in the next major release. If you want to search channel members by displayName, Please use `searchMembers()` instead.');
|
|
34584
|
-
channelMembers = filterBySearchTerm(channelMembers, this.query.search);
|
|
34585
|
-
}
|
|
34586
33649
|
if (this.query.includeDeleted === false) {
|
|
34587
33650
|
channelMembers = channelMembers.filter(member => { var _a; return ((_a = member.user) === null || _a === void 0 ? void 0 : _a.isDeleted) !== true; });
|
|
34588
33651
|
}
|
|
@@ -34616,11 +33679,6 @@ const applyFilter$1 = (data, params) => {
|
|
|
34616
33679
|
return params.memberships.includes(member.membership);
|
|
34617
33680
|
});
|
|
34618
33681
|
}
|
|
34619
|
-
if (params.search) {
|
|
34620
|
-
// eslint-disable-next-line no-console
|
|
34621
|
-
console.warn('`search` param will be deprecated in the next major release. If you want to search channel members by displayName, Please use `searchMembers()` instead.');
|
|
34622
|
-
channelMembers = filterBySearchTerm(channelMembers, params.search);
|
|
34623
|
-
}
|
|
34624
33682
|
// sort, 'lastCreated' is the default sort order
|
|
34625
33683
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
34626
33684
|
channelMembers = channelMembers.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
@@ -34912,7 +33970,7 @@ var index$c = /*#__PURE__*/Object.freeze({
|
|
|
34912
33970
|
__proto__: null,
|
|
34913
33971
|
Membership: index$e,
|
|
34914
33972
|
Moderation: index$d,
|
|
34915
|
-
getChannelByIds: getChannelByIds,
|
|
33973
|
+
getChannelByIds: getChannelByIds$1,
|
|
34916
33974
|
createChannel: createChannel,
|
|
34917
33975
|
updateChannel: updateChannel,
|
|
34918
33976
|
deleteChannel: deleteChannel,
|
|
@@ -34920,7 +33978,6 @@ var index$c = /*#__PURE__*/Object.freeze({
|
|
|
34920
33978
|
leaveChannel: leaveChannel,
|
|
34921
33979
|
muteChannel: muteChannel,
|
|
34922
33980
|
unmuteChannel: unmuteChannel,
|
|
34923
|
-
markAsRead: markAsRead,
|
|
34924
33981
|
onChannelCreated: onChannelCreated,
|
|
34925
33982
|
onChannelUpdated: onChannelUpdated,
|
|
34926
33983
|
onChannelDeleted: onChannelDeleted,
|
|
@@ -34933,8 +33990,6 @@ var index$c = /*#__PURE__*/Object.freeze({
|
|
|
34933
33990
|
onChannelMemberUnbanned: onChannelMemberUnbanned,
|
|
34934
33991
|
onChannelMemberRoleAdded: onChannelMemberRoleAdded,
|
|
34935
33992
|
onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
|
|
34936
|
-
observeChannel: observeChannel,
|
|
34937
|
-
observeChannels: observeChannels,
|
|
34938
33993
|
getChannel: getChannel,
|
|
34939
33994
|
getChannels: getChannels,
|
|
34940
33995
|
MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
|
|
@@ -35245,77 +34300,6 @@ const leaveCommunity = async (communityId) => {
|
|
|
35245
34300
|
};
|
|
35246
34301
|
/* end_public_function */
|
|
35247
34302
|
|
|
35248
|
-
/* begin_public_function
|
|
35249
|
-
id: community.query.trending_communities
|
|
35250
|
-
*/
|
|
35251
|
-
/**
|
|
35252
|
-
* @deprecated This API renamed to `getTrendingCommunities()`.
|
|
35253
|
-
* Please use getTrendingCommunities() instead.
|
|
35254
|
-
*
|
|
35255
|
-
* ```js
|
|
35256
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
35257
|
-
* const trendingCommunities = await CommunityRepository.getTrendingCommunities()
|
|
35258
|
-
* ```
|
|
35259
|
-
*
|
|
35260
|
-
* Gets a list of top trending {@link Amity.Community} objects
|
|
35261
|
-
*
|
|
35262
|
-
* @param query The query parameters
|
|
35263
|
-
* @returns A list of {@link Amity.Community} objects
|
|
35264
|
-
*
|
|
35265
|
-
* @category Community API
|
|
35266
|
-
* @async
|
|
35267
|
-
*/
|
|
35268
|
-
const getTopTrendingCommunities = async (query) => {
|
|
35269
|
-
const client = getActiveClient();
|
|
35270
|
-
client.log('channel/getTopTrendingCommunities', query);
|
|
35271
|
-
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
35272
|
-
// API-FIX: backend doesnt answer Amity.Response
|
|
35273
|
-
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
35274
|
-
const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
35275
|
-
const data = prepareCommunityPayload(payload);
|
|
35276
|
-
const { communities } = data;
|
|
35277
|
-
const cachedAt = client.cache && Date.now();
|
|
35278
|
-
if (client.cache) {
|
|
35279
|
-
ingestInCache(data, { cachedAt });
|
|
35280
|
-
const cacheKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
35281
|
-
pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
|
|
35282
|
-
}
|
|
35283
|
-
return { data: communities, cachedAt };
|
|
35284
|
-
};
|
|
35285
|
-
/* end_public_function */
|
|
35286
|
-
/**
|
|
35287
|
-
* ```js
|
|
35288
|
-
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
35289
|
-
* const communities = getTopTrendingCommunities.locally()
|
|
35290
|
-
* ```
|
|
35291
|
-
*
|
|
35292
|
-
* Gets a list of top trending {@link Amity.Community} objects from cache
|
|
35293
|
-
*
|
|
35294
|
-
* @param query The query parameters
|
|
35295
|
-
* @returns communities
|
|
35296
|
-
*
|
|
35297
|
-
* @category Community API
|
|
35298
|
-
*/
|
|
35299
|
-
getTopTrendingCommunities.locally = (query) => {
|
|
35300
|
-
var _a, _b;
|
|
35301
|
-
const client = getActiveClient();
|
|
35302
|
-
client.log('community/getTopTrendingCommunities.locally', query);
|
|
35303
|
-
if (!client.cache)
|
|
35304
|
-
return;
|
|
35305
|
-
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
35306
|
-
const queryKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
35307
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
35308
|
-
if (!(data === null || data === void 0 ? void 0 : data.communities.length))
|
|
35309
|
-
return;
|
|
35310
|
-
const communities = data.communities
|
|
35311
|
-
.map(communityId => pullFromCache(['community', 'get', communityId]))
|
|
35312
|
-
.filter(Boolean)
|
|
35313
|
-
.map(({ data }) => data);
|
|
35314
|
-
return communities.length === ((_b = data === null || data === void 0 ? void 0 : data.communities) === null || _b === void 0 ? void 0 : _b.length)
|
|
35315
|
-
? { data: communities, cachedAt }
|
|
35316
|
-
: undefined;
|
|
35317
|
-
};
|
|
35318
|
-
|
|
35319
34303
|
const createCommunityEventSubscriber = (event, callback) => {
|
|
35320
34304
|
const client = getActiveClient();
|
|
35321
34305
|
const filter = (payload) => {
|
|
@@ -35386,7 +34370,224 @@ const onCommunityUpdated = (callback) => createCommunityEventSubscriber('communi
|
|
|
35386
34370
|
*
|
|
35387
34371
|
* @category Community Events
|
|
35388
34372
|
*/
|
|
35389
|
-
const onCommunityDeleted = (callback) => createCommunityEventSubscriber('community.deleted', callback);
|
|
34373
|
+
const onCommunityDeleted = (callback) => createCommunityEventSubscriber('community.deleted', callback);
|
|
34374
|
+
|
|
34375
|
+
/**
|
|
34376
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
34377
|
+
* TODO: check if querybyIds is supported
|
|
34378
|
+
*/
|
|
34379
|
+
class CommunitiesPaginationController$1 extends PaginationController {
|
|
34380
|
+
async getRequest(queryParams, token) {
|
|
34381
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
34382
|
+
const options = token ? { token } : { limit };
|
|
34383
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/communities`, {
|
|
34384
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(params.includeDeleted), keyword: params.displayName, filter: params.membership, options }),
|
|
34385
|
+
});
|
|
34386
|
+
return queryResponse;
|
|
34387
|
+
}
|
|
34388
|
+
}
|
|
34389
|
+
|
|
34390
|
+
class CommunitiesQueryStreamController$1 extends QueryStreamController {
|
|
34391
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
34392
|
+
super(query, cacheKey);
|
|
34393
|
+
this.notifyChange = notifyChange;
|
|
34394
|
+
this.preparePayload = preparePayload;
|
|
34395
|
+
}
|
|
34396
|
+
async saveToMainDB(response) {
|
|
34397
|
+
const processedPayload = await this.preparePayload(response);
|
|
34398
|
+
const client = getActiveClient();
|
|
34399
|
+
const cachedAt = client.cache && Date.now();
|
|
34400
|
+
if (client.cache) {
|
|
34401
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
34402
|
+
}
|
|
34403
|
+
}
|
|
34404
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
34405
|
+
var _a, _b;
|
|
34406
|
+
if (refresh) {
|
|
34407
|
+
pushToCache(this.cacheKey, {
|
|
34408
|
+
data: response.communities.map(getResolver('community')),
|
|
34409
|
+
});
|
|
34410
|
+
}
|
|
34411
|
+
else {
|
|
34412
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
34413
|
+
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
34414
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...communities, ...response.communities.map(getResolver('community'))])] }));
|
|
34415
|
+
}
|
|
34416
|
+
}
|
|
34417
|
+
reactor(action) {
|
|
34418
|
+
return (community) => {
|
|
34419
|
+
var _a;
|
|
34420
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
34421
|
+
if (!collection)
|
|
34422
|
+
return;
|
|
34423
|
+
pushToCache(this.cacheKey, collection);
|
|
34424
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
34425
|
+
};
|
|
34426
|
+
}
|
|
34427
|
+
subscribeRTE(createSubscriber) {
|
|
34428
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
34429
|
+
}
|
|
34430
|
+
}
|
|
34431
|
+
|
|
34432
|
+
var EnumCommunityActions$4;
|
|
34433
|
+
(function (EnumCommunityActions) {
|
|
34434
|
+
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
34435
|
+
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
34436
|
+
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
34437
|
+
})(EnumCommunityActions$4 || (EnumCommunityActions$4 = {}));
|
|
34438
|
+
|
|
34439
|
+
var EnumCommunityMemberActions$1;
|
|
34440
|
+
(function (EnumCommunityMemberActions) {
|
|
34441
|
+
EnumCommunityMemberActions["OnCommunityJoined"] = "onCommunityJoined";
|
|
34442
|
+
EnumCommunityMemberActions["OnCommunityLeft"] = "onCommunityLeft";
|
|
34443
|
+
EnumCommunityMemberActions["OnCommunityUserBanned"] = "onCommunityUserBanned";
|
|
34444
|
+
EnumCommunityMemberActions["OnCommunityUserChanged"] = "onCommunityUserChanged";
|
|
34445
|
+
EnumCommunityMemberActions["OnCommunityUserRoleAdded"] = "onCommunityUserRoleAdded";
|
|
34446
|
+
EnumCommunityMemberActions["OnCommunityUserRoleRemoved"] = "onCommunityUserRoleRemoved";
|
|
34447
|
+
EnumCommunityMemberActions["OnCommunityUserUnbanned"] = "onCommunityUserUnbanned";
|
|
34448
|
+
EnumCommunityMemberActions["OnMemberCountChanged"] = "OnMemberCountChanged";
|
|
34449
|
+
EnumCommunityMemberActions["OnCommunityUserAdded"] = "OnCommunityUserAdded";
|
|
34450
|
+
EnumCommunityMemberActions["onCommunityUserRemoved"] = "onCommunityUserRemoved";
|
|
34451
|
+
EnumCommunityMemberActions["OnUserDeleted"] = "OnUserDeleted";
|
|
34452
|
+
})(EnumCommunityMemberActions$1 || (EnumCommunityMemberActions$1 = {}));
|
|
34453
|
+
|
|
34454
|
+
/* begin_public_function
|
|
34455
|
+
id: community.membership.add_members
|
|
34456
|
+
*/
|
|
34457
|
+
/**
|
|
34458
|
+
* ```js
|
|
34459
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
34460
|
+
* const updated = await CommunityRepository.moderation.addMembers(communityId, ['foo', 'bar'])
|
|
34461
|
+
* ```
|
|
34462
|
+
*
|
|
34463
|
+
* Adds a list of {@link Amity.InternalUser} to a {@link Amity.Community} to add users to
|
|
34464
|
+
*
|
|
34465
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
34466
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to add
|
|
34467
|
+
* @returns A success boolean if the {@link Amity.InternalUser} were added to the {@link Amity.Community}
|
|
34468
|
+
*
|
|
34469
|
+
* @category Community API
|
|
34470
|
+
* @async
|
|
34471
|
+
*/
|
|
34472
|
+
const addMembers = async (communityId, userIds) => {
|
|
34473
|
+
const client = getActiveClient();
|
|
34474
|
+
client.log('community/moderation/addMembers', communityId, userIds);
|
|
34475
|
+
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
34476
|
+
fireEvent('local.community.userAdded', payload);
|
|
34477
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
34478
|
+
if (client.cache)
|
|
34479
|
+
ingestInCache(data);
|
|
34480
|
+
const { communityUsers } = data;
|
|
34481
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
34482
|
+
};
|
|
34483
|
+
/* end_public_function */
|
|
34484
|
+
|
|
34485
|
+
/* begin_public_function
|
|
34486
|
+
id: community.membership.remove_member
|
|
34487
|
+
*/
|
|
34488
|
+
/**
|
|
34489
|
+
* ```js
|
|
34490
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
34491
|
+
* const updated = await CommunityRepository.moderation.removeMembers(communityId, ['foo', 'bar'])
|
|
34492
|
+
* ```
|
|
34493
|
+
*
|
|
34494
|
+
* Removes a list of {@link Amity.InternalUser} from a {@link Amity.Community}
|
|
34495
|
+
*
|
|
34496
|
+
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
34497
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to remove
|
|
34498
|
+
* @returns A success boolean if the list of {@link Amity.InternalUser} were removed from the {@link Amity.Community}
|
|
34499
|
+
*
|
|
34500
|
+
* @category Community API
|
|
34501
|
+
* @async
|
|
34502
|
+
*/
|
|
34503
|
+
const removeMembers = async (communityId, userIds) => {
|
|
34504
|
+
const client = getActiveClient();
|
|
34505
|
+
client.log('community/moderation/removeMembers', communityId, userIds);
|
|
34506
|
+
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
34507
|
+
fireEvent('local.community.userRemoved', payload);
|
|
34508
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
34509
|
+
if (client.cache)
|
|
34510
|
+
ingestInCache(data);
|
|
34511
|
+
const { communityUsers } = data;
|
|
34512
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
34513
|
+
};
|
|
34514
|
+
/* end_public_function */
|
|
34515
|
+
|
|
34516
|
+
/**
|
|
34517
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
34518
|
+
* TODO: check if querybyIds is supported
|
|
34519
|
+
*/
|
|
34520
|
+
class CommunityMembersPaginationController extends PaginationController {
|
|
34521
|
+
async getRequest(queryParams, token) {
|
|
34522
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
34523
|
+
const options = token ? { token } : { limit };
|
|
34524
|
+
const isDeleted = includeDeleted === false ? false : undefined;
|
|
34525
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/communities/${params.communityId}/users`, {
|
|
34526
|
+
params: Object.assign(Object.assign({}, params), { options,
|
|
34527
|
+
isDeleted }),
|
|
34528
|
+
});
|
|
34529
|
+
return queryResponse;
|
|
34530
|
+
}
|
|
34531
|
+
}
|
|
34532
|
+
|
|
34533
|
+
class CommunityMembersQueryStreamController extends QueryStreamController {
|
|
34534
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
34535
|
+
super(query, cacheKey);
|
|
34536
|
+
this.notifyChange = notifyChange;
|
|
34537
|
+
this.preparePayload = preparePayload;
|
|
34538
|
+
}
|
|
34539
|
+
async saveToMainDB(response) {
|
|
34540
|
+
const processedPayload = await this.preparePayload(response);
|
|
34541
|
+
const client = getActiveClient();
|
|
34542
|
+
const cachedAt = client.cache && Date.now();
|
|
34543
|
+
if (client.cache) {
|
|
34544
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
34545
|
+
}
|
|
34546
|
+
}
|
|
34547
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
34548
|
+
var _a, _b;
|
|
34549
|
+
if (refresh) {
|
|
34550
|
+
pushToCache(this.cacheKey, {
|
|
34551
|
+
data: response.communityUsers.map(({ communityId, userId }) => getResolver('communityUsers')({ communityId, userId })),
|
|
34552
|
+
});
|
|
34553
|
+
}
|
|
34554
|
+
else {
|
|
34555
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
34556
|
+
const communityUsers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
34557
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
34558
|
+
...new Set([
|
|
34559
|
+
...communityUsers,
|
|
34560
|
+
...response.communityUsers.map(({ communityId, userId }) => getResolver('communityUsers')({ communityId, userId })),
|
|
34561
|
+
]),
|
|
34562
|
+
] }));
|
|
34563
|
+
}
|
|
34564
|
+
}
|
|
34565
|
+
reactor(action) {
|
|
34566
|
+
return (community, communityMembers) => {
|
|
34567
|
+
var _a;
|
|
34568
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
34569
|
+
if (!collection)
|
|
34570
|
+
return;
|
|
34571
|
+
communityMembers.forEach(communityMember => {
|
|
34572
|
+
const communityMemberCacheId = getResolver('communityUsers')({
|
|
34573
|
+
communityId: this.query.communityId,
|
|
34574
|
+
userId: communityMember.userId,
|
|
34575
|
+
});
|
|
34576
|
+
if (communityMember.communityMembership === 'none') {
|
|
34577
|
+
collection.data = collection.data.filter(m => m !== communityMemberCacheId);
|
|
34578
|
+
}
|
|
34579
|
+
else if (!collection.data.includes(communityMemberCacheId)) {
|
|
34580
|
+
collection.data = [communityMemberCacheId, ...collection.data];
|
|
34581
|
+
}
|
|
34582
|
+
});
|
|
34583
|
+
pushToCache(this.cacheKey, collection);
|
|
34584
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
34585
|
+
};
|
|
34586
|
+
}
|
|
34587
|
+
subscribeRTE(createSubscriber) {
|
|
34588
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
34589
|
+
}
|
|
34590
|
+
}
|
|
35390
34591
|
|
|
35391
34592
|
function hasPermission(member, payload, permission) {
|
|
35392
34593
|
if (member.permissions.some(x => x === permission)) {
|
|
@@ -35680,271 +34881,6 @@ const onLocalCommunityJoined = (callback) => createLocalCommunityMemberEventSubs
|
|
|
35680
34881
|
|
|
35681
34882
|
const onLocalCommunityLeft = (callback) => createLocalCommunityMemberEventSubscriber('local.community.left', callback);
|
|
35682
34883
|
|
|
35683
|
-
/**
|
|
35684
|
-
* ```js
|
|
35685
|
-
* import { observeCommunity } from '@amityco/ts-sdk'
|
|
35686
|
-
*
|
|
35687
|
-
* let community = {}
|
|
35688
|
-
* const dispose = observeCommunity(communityId, updated => community = updated)
|
|
35689
|
-
* ```
|
|
35690
|
-
*
|
|
35691
|
-
* Observe all mutation on a given {@link Amity.Community}
|
|
35692
|
-
*
|
|
35693
|
-
* @param communityId the ID of the community to observe
|
|
35694
|
-
* @param callback the function to call when new data are available
|
|
35695
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the community
|
|
35696
|
-
*
|
|
35697
|
-
* @category Community Observer
|
|
35698
|
-
*/
|
|
35699
|
-
const observeCommunity = (communityId, callback) => {
|
|
35700
|
-
const { log } = getActiveClient();
|
|
35701
|
-
const timestamp = Date.now();
|
|
35702
|
-
log(`observeCommunity(tmpid: ${timestamp}) > listen`);
|
|
35703
|
-
// wrapper function to make sure
|
|
35704
|
-
const router = (result, action) => {
|
|
35705
|
-
var _a, _b;
|
|
35706
|
-
if (callback instanceof Function)
|
|
35707
|
-
return callback(result);
|
|
35708
|
-
if (action !== 'onFetch')
|
|
35709
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, result);
|
|
35710
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, result);
|
|
35711
|
-
};
|
|
35712
|
-
const realtimeRouter = (result, action) => {
|
|
35713
|
-
var _a;
|
|
35714
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.communityId) !== communityId)
|
|
35715
|
-
return;
|
|
35716
|
-
router(result, action);
|
|
35717
|
-
};
|
|
35718
|
-
const disposers = [];
|
|
35719
|
-
disposers.push(onCommunityUpdated(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUpdate')), onCommunityDeleted(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onDelete')), onCommunityJoined(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onJoin')), onCommunityLeft(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onLeft')), onCommunityUserAdded(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUserAdded')), onCommunityUserRemoved(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUserRemoved')), onCommunityUserBanned(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUserBanned')), onCommunityUserUnbanned(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUserUnbanned')));
|
|
35720
|
-
runQuery(createQuery(getCommunity$1, communityId), result => (result.data || result.error) && router(result, 'onFetch'));
|
|
35721
|
-
return () => {
|
|
35722
|
-
log(`observeCommunity(tmpid: ${timestamp}) > dispose`);
|
|
35723
|
-
disposers.forEach(fn => fn());
|
|
35724
|
-
};
|
|
35725
|
-
};
|
|
35726
|
-
|
|
35727
|
-
/**
|
|
35728
|
-
* TODO: handle cache receive cache option, and cache policy
|
|
35729
|
-
* TODO: check if querybyIds is supported
|
|
35730
|
-
*/
|
|
35731
|
-
class CommunitiesPaginationController$1 extends PaginationController {
|
|
35732
|
-
async getRequest(queryParams, token) {
|
|
35733
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
35734
|
-
const options = token ? { token } : { limit };
|
|
35735
|
-
const { data: queryResponse } = await this.http.get(`/api/v3/communities`, {
|
|
35736
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(params.includeDeleted), keyword: params.displayName, filter: params.membership, options }),
|
|
35737
|
-
});
|
|
35738
|
-
return queryResponse;
|
|
35739
|
-
}
|
|
35740
|
-
}
|
|
35741
|
-
|
|
35742
|
-
class CommunitiesQueryStreamController$1 extends QueryStreamController {
|
|
35743
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
35744
|
-
super(query, cacheKey);
|
|
35745
|
-
this.notifyChange = notifyChange;
|
|
35746
|
-
this.preparePayload = preparePayload;
|
|
35747
|
-
}
|
|
35748
|
-
async saveToMainDB(response) {
|
|
35749
|
-
const processedPayload = await this.preparePayload(response);
|
|
35750
|
-
const client = getActiveClient();
|
|
35751
|
-
const cachedAt = client.cache && Date.now();
|
|
35752
|
-
if (client.cache) {
|
|
35753
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
35754
|
-
}
|
|
35755
|
-
}
|
|
35756
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
35757
|
-
var _a, _b;
|
|
35758
|
-
if (refresh) {
|
|
35759
|
-
pushToCache(this.cacheKey, {
|
|
35760
|
-
data: response.communities.map(getResolver('community')),
|
|
35761
|
-
});
|
|
35762
|
-
}
|
|
35763
|
-
else {
|
|
35764
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35765
|
-
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
35766
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...communities, ...response.communities.map(getResolver('community'))])] }));
|
|
35767
|
-
}
|
|
35768
|
-
}
|
|
35769
|
-
reactor(action) {
|
|
35770
|
-
return (community) => {
|
|
35771
|
-
var _a;
|
|
35772
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35773
|
-
if (!collection)
|
|
35774
|
-
return;
|
|
35775
|
-
pushToCache(this.cacheKey, collection);
|
|
35776
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
35777
|
-
};
|
|
35778
|
-
}
|
|
35779
|
-
subscribeRTE(createSubscriber) {
|
|
35780
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
35781
|
-
}
|
|
35782
|
-
}
|
|
35783
|
-
|
|
35784
|
-
var EnumCommunityActions$4;
|
|
35785
|
-
(function (EnumCommunityActions) {
|
|
35786
|
-
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
35787
|
-
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
35788
|
-
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
35789
|
-
})(EnumCommunityActions$4 || (EnumCommunityActions$4 = {}));
|
|
35790
|
-
|
|
35791
|
-
var EnumCommunityMemberActions$1;
|
|
35792
|
-
(function (EnumCommunityMemberActions) {
|
|
35793
|
-
EnumCommunityMemberActions["OnCommunityJoined"] = "onCommunityJoined";
|
|
35794
|
-
EnumCommunityMemberActions["OnCommunityLeft"] = "onCommunityLeft";
|
|
35795
|
-
EnumCommunityMemberActions["OnCommunityUserBanned"] = "onCommunityUserBanned";
|
|
35796
|
-
EnumCommunityMemberActions["OnCommunityUserChanged"] = "onCommunityUserChanged";
|
|
35797
|
-
EnumCommunityMemberActions["OnCommunityUserRoleAdded"] = "onCommunityUserRoleAdded";
|
|
35798
|
-
EnumCommunityMemberActions["OnCommunityUserRoleRemoved"] = "onCommunityUserRoleRemoved";
|
|
35799
|
-
EnumCommunityMemberActions["OnCommunityUserUnbanned"] = "onCommunityUserUnbanned";
|
|
35800
|
-
EnumCommunityMemberActions["OnMemberCountChanged"] = "OnMemberCountChanged";
|
|
35801
|
-
EnumCommunityMemberActions["OnCommunityUserAdded"] = "OnCommunityUserAdded";
|
|
35802
|
-
EnumCommunityMemberActions["onCommunityUserRemoved"] = "onCommunityUserRemoved";
|
|
35803
|
-
EnumCommunityMemberActions["OnUserDeleted"] = "OnUserDeleted";
|
|
35804
|
-
})(EnumCommunityMemberActions$1 || (EnumCommunityMemberActions$1 = {}));
|
|
35805
|
-
|
|
35806
|
-
/* begin_public_function
|
|
35807
|
-
id: community.membership.add_members
|
|
35808
|
-
*/
|
|
35809
|
-
/**
|
|
35810
|
-
* ```js
|
|
35811
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
35812
|
-
* const updated = await CommunityRepository.moderation.addMembers(communityId, ['foo', 'bar'])
|
|
35813
|
-
* ```
|
|
35814
|
-
*
|
|
35815
|
-
* Adds a list of {@link Amity.InternalUser} to a {@link Amity.Community} to add users to
|
|
35816
|
-
*
|
|
35817
|
-
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
35818
|
-
* @param userIds The list of IDs {@link Amity.InternalUser} to add
|
|
35819
|
-
* @returns A success boolean if the {@link Amity.InternalUser} were added to the {@link Amity.Community}
|
|
35820
|
-
*
|
|
35821
|
-
* @category Community API
|
|
35822
|
-
* @async
|
|
35823
|
-
*/
|
|
35824
|
-
const addMembers = async (communityId, userIds) => {
|
|
35825
|
-
const client = getActiveClient();
|
|
35826
|
-
client.log('community/moderation/addMembers', communityId, userIds);
|
|
35827
|
-
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
35828
|
-
fireEvent('local.community.userAdded', payload);
|
|
35829
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
35830
|
-
if (client.cache)
|
|
35831
|
-
ingestInCache(data);
|
|
35832
|
-
const { communityUsers } = data;
|
|
35833
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
35834
|
-
};
|
|
35835
|
-
/* end_public_function */
|
|
35836
|
-
|
|
35837
|
-
/* begin_public_function
|
|
35838
|
-
id: community.membership.remove_member
|
|
35839
|
-
*/
|
|
35840
|
-
/**
|
|
35841
|
-
* ```js
|
|
35842
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
35843
|
-
* const updated = await CommunityRepository.moderation.removeMembers(communityId, ['foo', 'bar'])
|
|
35844
|
-
* ```
|
|
35845
|
-
*
|
|
35846
|
-
* Removes a list of {@link Amity.InternalUser} from a {@link Amity.Community}
|
|
35847
|
-
*
|
|
35848
|
-
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
35849
|
-
* @param userIds The list of IDs {@link Amity.InternalUser} to remove
|
|
35850
|
-
* @returns A success boolean if the list of {@link Amity.InternalUser} were removed from the {@link Amity.Community}
|
|
35851
|
-
*
|
|
35852
|
-
* @category Community API
|
|
35853
|
-
* @async
|
|
35854
|
-
*/
|
|
35855
|
-
const removeMembers = async (communityId, userIds) => {
|
|
35856
|
-
const client = getActiveClient();
|
|
35857
|
-
client.log('community/moderation/removeMembers', communityId, userIds);
|
|
35858
|
-
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
35859
|
-
fireEvent('local.community.userRemoved', payload);
|
|
35860
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
35861
|
-
if (client.cache)
|
|
35862
|
-
ingestInCache(data);
|
|
35863
|
-
const { communityUsers } = data;
|
|
35864
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
35865
|
-
};
|
|
35866
|
-
/* end_public_function */
|
|
35867
|
-
|
|
35868
|
-
/**
|
|
35869
|
-
* TODO: handle cache receive cache option, and cache policy
|
|
35870
|
-
* TODO: check if querybyIds is supported
|
|
35871
|
-
*/
|
|
35872
|
-
class CommunityMembersPaginationController extends PaginationController {
|
|
35873
|
-
async getRequest(queryParams, token) {
|
|
35874
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
35875
|
-
const options = token ? { token } : { limit };
|
|
35876
|
-
const isDeleted = includeDeleted === false ? false : undefined;
|
|
35877
|
-
const { data: queryResponse } = await this.http.get(`/api/v3/communities/${params.communityId}/users`, {
|
|
35878
|
-
params: Object.assign(Object.assign({}, params), { options,
|
|
35879
|
-
isDeleted }),
|
|
35880
|
-
});
|
|
35881
|
-
return queryResponse;
|
|
35882
|
-
}
|
|
35883
|
-
}
|
|
35884
|
-
|
|
35885
|
-
class CommunityMembersQueryStreamController extends QueryStreamController {
|
|
35886
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
35887
|
-
super(query, cacheKey);
|
|
35888
|
-
this.notifyChange = notifyChange;
|
|
35889
|
-
this.preparePayload = preparePayload;
|
|
35890
|
-
}
|
|
35891
|
-
async saveToMainDB(response) {
|
|
35892
|
-
const processedPayload = await this.preparePayload(response);
|
|
35893
|
-
const client = getActiveClient();
|
|
35894
|
-
const cachedAt = client.cache && Date.now();
|
|
35895
|
-
if (client.cache) {
|
|
35896
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
35897
|
-
}
|
|
35898
|
-
}
|
|
35899
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
35900
|
-
var _a, _b;
|
|
35901
|
-
if (refresh) {
|
|
35902
|
-
pushToCache(this.cacheKey, {
|
|
35903
|
-
data: response.communityUsers.map(({ communityId, userId }) => getResolver('communityUsers')({ communityId, userId })),
|
|
35904
|
-
});
|
|
35905
|
-
}
|
|
35906
|
-
else {
|
|
35907
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35908
|
-
const communityUsers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
35909
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
35910
|
-
...new Set([
|
|
35911
|
-
...communityUsers,
|
|
35912
|
-
...response.communityUsers.map(({ communityId, userId }) => getResolver('communityUsers')({ communityId, userId })),
|
|
35913
|
-
]),
|
|
35914
|
-
] }));
|
|
35915
|
-
}
|
|
35916
|
-
}
|
|
35917
|
-
reactor(action) {
|
|
35918
|
-
return (community, communityMembers) => {
|
|
35919
|
-
var _a;
|
|
35920
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35921
|
-
if (!collection)
|
|
35922
|
-
return;
|
|
35923
|
-
if (action === EnumCommunityMemberActions$1.OnCommunityUserRoleAdded &&
|
|
35924
|
-
this.query.sortBy === 'displayName') {
|
|
35925
|
-
return;
|
|
35926
|
-
}
|
|
35927
|
-
communityMembers.forEach(communityMember => {
|
|
35928
|
-
const communityMemberCacheId = getResolver('communityUsers')({
|
|
35929
|
-
communityId: this.query.communityId,
|
|
35930
|
-
userId: communityMember.userId,
|
|
35931
|
-
});
|
|
35932
|
-
if (communityMember.communityMembership === 'none') {
|
|
35933
|
-
collection.data = collection.data.filter(m => m !== communityMemberCacheId);
|
|
35934
|
-
}
|
|
35935
|
-
else if (!collection.data.includes(communityMemberCacheId)) {
|
|
35936
|
-
collection.data = [communityMemberCacheId, ...collection.data];
|
|
35937
|
-
}
|
|
35938
|
-
});
|
|
35939
|
-
pushToCache(this.cacheKey, collection);
|
|
35940
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
35941
|
-
};
|
|
35942
|
-
}
|
|
35943
|
-
subscribeRTE(createSubscriber) {
|
|
35944
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
35945
|
-
}
|
|
35946
|
-
}
|
|
35947
|
-
|
|
35948
34884
|
/**
|
|
35949
34885
|
* ```js
|
|
35950
34886
|
* import { onLocalCommunityRoleRemoved } from '@amityco/ts-sdk'
|
|
@@ -36122,9 +35058,6 @@ class CommunityMembersLiveCollectionController extends LiveCollectionController
|
|
|
36122
35058
|
return memberships.includes(communityMembership);
|
|
36123
35059
|
});
|
|
36124
35060
|
}
|
|
36125
|
-
if (this.query.search) {
|
|
36126
|
-
communityMembers = filterBySearchTerm(communityMembers, this.query.search);
|
|
36127
|
-
}
|
|
36128
35061
|
if (this.query.includeDeleted === false) {
|
|
36129
35062
|
communityMembers = communityMembers.filter(({ user }) => (user === null || user === void 0 ? void 0 : user.isDeleted) !== true);
|
|
36130
35063
|
}
|
|
@@ -36132,15 +35065,6 @@ class CommunityMembersLiveCollectionController extends LiveCollectionController
|
|
|
36132
35065
|
case 'firstCreated':
|
|
36133
35066
|
communityMembers = communityMembers.sort(sortByFirstCreated);
|
|
36134
35067
|
break;
|
|
36135
|
-
case 'displayName':
|
|
36136
|
-
communityMembers = communityMembers.sort((a, b) => {
|
|
36137
|
-
var _a, _b, _c, _d;
|
|
36138
|
-
if (((_a = a === null || a === void 0 ? void 0 : a.user) === null || _a === void 0 ? void 0 : _a.displayName) && ((_b = b === null || b === void 0 ? void 0 : b.user) === null || _b === void 0 ? void 0 : _b.displayName)) {
|
|
36139
|
-
return (_c = a === null || a === void 0 ? void 0 : a.user) === null || _c === void 0 ? void 0 : _c.displayName.localeCompare((_d = b === null || b === void 0 ? void 0 : b.user) === null || _d === void 0 ? void 0 : _d.displayName);
|
|
36140
|
-
}
|
|
36141
|
-
return 0;
|
|
36142
|
-
});
|
|
36143
|
-
break;
|
|
36144
35068
|
case 'lastCreated':
|
|
36145
35069
|
default:
|
|
36146
35070
|
communityMembers = communityMembers.sort(sortByLastCreated);
|
|
@@ -36162,9 +35086,6 @@ const applyFilter = (data, params) => {
|
|
|
36162
35086
|
return membership.includes(communityMembership);
|
|
36163
35087
|
});
|
|
36164
35088
|
}
|
|
36165
|
-
if (params.search) {
|
|
36166
|
-
communityMembers = filterBySearchTerm(communityMembers, params.search);
|
|
36167
|
-
}
|
|
36168
35089
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
36169
35090
|
communityMembers = communityMembers.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
36170
35091
|
return communityMembers;
|
|
@@ -36521,209 +35442,202 @@ class SearchCommunityLiveCollectionController extends LiveCollectionController {
|
|
|
36521
35442
|
if (this.query.membership && userId) {
|
|
36522
35443
|
communities = filterByCommunityMembership(communities, this.query.membership, userId);
|
|
36523
35444
|
}
|
|
36524
|
-
return communities;
|
|
36525
|
-
}
|
|
36526
|
-
}
|
|
36527
|
-
|
|
36528
|
-
/* begin_public_function
|
|
36529
|
-
id: community.query
|
|
36530
|
-
*/
|
|
36531
|
-
/**
|
|
36532
|
-
* ```js
|
|
36533
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
36534
|
-
*
|
|
36535
|
-
* let communities = []
|
|
36536
|
-
* const unsub = CommunityRepository.searchCommunities({
|
|
36537
|
-
* displayName: Amity.Community['displayName'],
|
|
36538
|
-
* }, response => merge(communities, response.data))
|
|
36539
|
-
* ```
|
|
36540
|
-
*
|
|
36541
|
-
* Observe all mutations on a list of {@link Amity.Community}s
|
|
36542
|
-
*
|
|
36543
|
-
* @param params for querying communities
|
|
36544
|
-
* @param callback the function to call when new data are available
|
|
36545
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the communities
|
|
36546
|
-
*
|
|
36547
|
-
* @category Community Live Collection
|
|
36548
|
-
*/
|
|
36549
|
-
const searchCommunities = (params, callback, config) => {
|
|
36550
|
-
const { log, cache } = getActiveClient();
|
|
36551
|
-
if (!cache) {
|
|
36552
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
36553
|
-
}
|
|
36554
|
-
const timestamp = Date.now();
|
|
36555
|
-
log(`searchCommunities(tmpid: ${timestamp}) > listen`);
|
|
36556
|
-
const searchCommunitiesLiveCollection = new SearchCommunityLiveCollectionController(params, callback);
|
|
36557
|
-
const disposers = searchCommunitiesLiveCollection.startSubscription();
|
|
36558
|
-
const cacheKey = searchCommunitiesLiveCollection.getCacheKey();
|
|
36559
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
36560
|
-
return () => {
|
|
36561
|
-
log(`searchCommunities(tmpid: ${timestamp}) > dispose`);
|
|
36562
|
-
disposers.forEach(fn => fn());
|
|
36563
|
-
};
|
|
36564
|
-
};
|
|
36565
|
-
/* end_public_function */
|
|
36566
|
-
|
|
36567
|
-
/**
|
|
36568
|
-
* TODO: handle cache receive cache option, and cache policy
|
|
36569
|
-
* TODO: check if querybyIds is supported
|
|
36570
|
-
*/
|
|
36571
|
-
class CommunitiesPaginationController extends PaginationController {
|
|
36572
|
-
async getRequest(queryParams, token) {
|
|
36573
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
36574
|
-
const options = token ? { token } : { limit };
|
|
36575
|
-
const { data: queryResponse } = await this.http.get(`/api/v3/communities`, {
|
|
36576
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(params.includeDeleted),
|
|
36577
|
-
});
|
|
36578
|
-
return queryResponse;
|
|
36579
|
-
}
|
|
36580
|
-
}
|
|
36581
|
-
|
|
36582
|
-
|
|
36583
|
-
(
|
|
36584
|
-
|
|
36585
|
-
|
|
36586
|
-
|
|
36587
|
-
}
|
|
36588
|
-
|
|
36589
|
-
|
|
36590
|
-
|
|
36591
|
-
|
|
36592
|
-
|
|
36593
|
-
|
|
36594
|
-
|
|
36595
|
-
|
|
36596
|
-
|
|
36597
|
-
|
|
36598
|
-
|
|
36599
|
-
if (
|
|
36600
|
-
|
|
36601
|
-
|
|
36602
|
-
|
|
36603
|
-
|
|
36604
|
-
|
|
36605
|
-
|
|
36606
|
-
|
|
36607
|
-
pushToCache(this.cacheKey, {
|
|
36608
|
-
|
|
36609
|
-
|
|
36610
|
-
|
|
36611
|
-
|
|
36612
|
-
|
|
36613
|
-
const
|
|
36614
|
-
|
|
36615
|
-
|
|
36616
|
-
|
|
36617
|
-
|
|
36618
|
-
|
|
36619
|
-
|
|
36620
|
-
|
|
36621
|
-
|
|
36622
|
-
|
|
36623
|
-
|
|
36624
|
-
|
|
36625
|
-
|
|
36626
|
-
|
|
36627
|
-
|
|
36628
|
-
|
|
36629
|
-
|
|
36630
|
-
|
|
36631
|
-
|
|
36632
|
-
|
|
36633
|
-
|
|
36634
|
-
|
|
36635
|
-
|
|
36636
|
-
|
|
36637
|
-
|
|
36638
|
-
|
|
36639
|
-
|
|
36640
|
-
|
|
36641
|
-
|
|
36642
|
-
|
|
36643
|
-
|
|
36644
|
-
|
|
36645
|
-
this.
|
|
36646
|
-
|
|
36647
|
-
|
|
36648
|
-
|
|
36649
|
-
|
|
36650
|
-
|
|
36651
|
-
|
|
36652
|
-
|
|
36653
|
-
|
|
36654
|
-
|
|
36655
|
-
|
|
36656
|
-
|
|
36657
|
-
|
|
36658
|
-
|
|
36659
|
-
}
|
|
36660
|
-
|
|
36661
|
-
|
|
36662
|
-
}
|
|
36663
|
-
|
|
36664
|
-
this.queryStreamController.
|
|
36665
|
-
|
|
36666
|
-
|
|
36667
|
-
|
|
36668
|
-
{ fn:
|
|
36669
|
-
{ fn:
|
|
36670
|
-
{ fn:
|
|
36671
|
-
{ fn:
|
|
36672
|
-
{ fn:
|
|
36673
|
-
|
|
36674
|
-
|
|
36675
|
-
|
|
36676
|
-
|
|
36677
|
-
|
|
36678
|
-
|
|
36679
|
-
|
|
36680
|
-
const
|
|
36681
|
-
|
|
36682
|
-
|
|
36683
|
-
|
|
36684
|
-
|
|
36685
|
-
|
|
36686
|
-
|
|
36687
|
-
|
|
36688
|
-
|
|
36689
|
-
|
|
36690
|
-
|
|
36691
|
-
|
|
36692
|
-
|
|
36693
|
-
|
|
36694
|
-
|
|
36695
|
-
});
|
|
36696
|
-
|
|
36697
|
-
|
|
36698
|
-
|
|
36699
|
-
|
|
36700
|
-
if (
|
|
36701
|
-
communities =
|
|
36702
|
-
}
|
|
36703
|
-
if (this.query.
|
|
36704
|
-
communities = communities.filter(c => { var _a; return (_a = c.
|
|
36705
|
-
}
|
|
36706
|
-
if (this.query.
|
|
36707
|
-
communities = communities
|
|
36708
|
-
}
|
|
36709
|
-
if (this.query.membership && userId) {
|
|
36710
|
-
communities = filterByCommunityMembership(communities, this.query.membership, userId);
|
|
36711
|
-
}
|
|
36712
|
-
if (!this.query.displayName) {
|
|
36713
|
-
const sortFn = (() => {
|
|
36714
|
-
switch (this.query.sortBy) {
|
|
36715
|
-
case 'firstCreated':
|
|
36716
|
-
return sortByFirstCreated;
|
|
36717
|
-
case 'lastCreated':
|
|
36718
|
-
return sortByLastCreated;
|
|
36719
|
-
case 'displayName':
|
|
36720
|
-
return sortByDisplayName;
|
|
36721
|
-
default:
|
|
36722
|
-
return sortByLastCreated;
|
|
36723
|
-
}
|
|
36724
|
-
})();
|
|
36725
|
-
communities = communities.sort(sortFn);
|
|
35445
|
+
return communities;
|
|
35446
|
+
}
|
|
35447
|
+
}
|
|
35448
|
+
|
|
35449
|
+
/* begin_public_function
|
|
35450
|
+
id: community.query
|
|
35451
|
+
*/
|
|
35452
|
+
/**
|
|
35453
|
+
* ```js
|
|
35454
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
35455
|
+
*
|
|
35456
|
+
* let communities = []
|
|
35457
|
+
* const unsub = CommunityRepository.searchCommunities({
|
|
35458
|
+
* displayName: Amity.Community['displayName'],
|
|
35459
|
+
* }, response => merge(communities, response.data))
|
|
35460
|
+
* ```
|
|
35461
|
+
*
|
|
35462
|
+
* Observe all mutations on a list of {@link Amity.Community}s
|
|
35463
|
+
*
|
|
35464
|
+
* @param params for querying communities
|
|
35465
|
+
* @param callback the function to call when new data are available
|
|
35466
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the communities
|
|
35467
|
+
*
|
|
35468
|
+
* @category Community Live Collection
|
|
35469
|
+
*/
|
|
35470
|
+
const searchCommunities = (params, callback, config) => {
|
|
35471
|
+
const { log, cache } = getActiveClient();
|
|
35472
|
+
if (!cache) {
|
|
35473
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
35474
|
+
}
|
|
35475
|
+
const timestamp = Date.now();
|
|
35476
|
+
log(`searchCommunities(tmpid: ${timestamp}) > listen`);
|
|
35477
|
+
const searchCommunitiesLiveCollection = new SearchCommunityLiveCollectionController(params, callback);
|
|
35478
|
+
const disposers = searchCommunitiesLiveCollection.startSubscription();
|
|
35479
|
+
const cacheKey = searchCommunitiesLiveCollection.getCacheKey();
|
|
35480
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
35481
|
+
return () => {
|
|
35482
|
+
log(`searchCommunities(tmpid: ${timestamp}) > dispose`);
|
|
35483
|
+
disposers.forEach(fn => fn());
|
|
35484
|
+
};
|
|
35485
|
+
};
|
|
35486
|
+
/* end_public_function */
|
|
35487
|
+
|
|
35488
|
+
/**
|
|
35489
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
35490
|
+
* TODO: check if querybyIds is supported
|
|
35491
|
+
*/
|
|
35492
|
+
class CommunitiesPaginationController extends PaginationController {
|
|
35493
|
+
async getRequest(queryParams, token) {
|
|
35494
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
35495
|
+
const options = token ? { token } : { limit };
|
|
35496
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/communities`, {
|
|
35497
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(params.includeDeleted), filter: params.membership, options }),
|
|
35498
|
+
});
|
|
35499
|
+
return queryResponse;
|
|
35500
|
+
}
|
|
35501
|
+
}
|
|
35502
|
+
|
|
35503
|
+
class CommunitiesQueryStreamController extends QueryStreamController {
|
|
35504
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
35505
|
+
super(query, cacheKey);
|
|
35506
|
+
this.notifyChange = notifyChange;
|
|
35507
|
+
this.preparePayload = preparePayload;
|
|
35508
|
+
}
|
|
35509
|
+
async saveToMainDB(response) {
|
|
35510
|
+
const processedPayload = await this.preparePayload(response);
|
|
35511
|
+
const client = getActiveClient();
|
|
35512
|
+
const cachedAt = client.cache && Date.now();
|
|
35513
|
+
if (client.cache) {
|
|
35514
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
35515
|
+
saveCommunityUsers(response.communities, response.communityUsers);
|
|
35516
|
+
}
|
|
35517
|
+
}
|
|
35518
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
35519
|
+
var _a, _b;
|
|
35520
|
+
if (refresh) {
|
|
35521
|
+
pushToCache(this.cacheKey, {
|
|
35522
|
+
data: response.communities.map(getResolver('community')),
|
|
35523
|
+
});
|
|
35524
|
+
}
|
|
35525
|
+
else {
|
|
35526
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35527
|
+
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
35528
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...communities, ...response.communities.map(getResolver('community'))])] }));
|
|
35529
|
+
}
|
|
35530
|
+
}
|
|
35531
|
+
reactor(action) {
|
|
35532
|
+
return (community) => {
|
|
35533
|
+
var _a;
|
|
35534
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35535
|
+
if (!collection)
|
|
35536
|
+
return;
|
|
35537
|
+
/*
|
|
35538
|
+
* Simply update a collection and let responder decide what to do with data
|
|
35539
|
+
*/
|
|
35540
|
+
collection.data = [...new Set([community.communityId, ...collection.data])];
|
|
35541
|
+
pushToCache(this.cacheKey, collection);
|
|
35542
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
35543
|
+
};
|
|
35544
|
+
}
|
|
35545
|
+
subscribeRTE(createSubscriber) {
|
|
35546
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
35547
|
+
}
|
|
35548
|
+
}
|
|
35549
|
+
|
|
35550
|
+
var EnumCommunityActions$3;
|
|
35551
|
+
(function (EnumCommunityActions) {
|
|
35552
|
+
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
35553
|
+
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
35554
|
+
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
35555
|
+
})(EnumCommunityActions$3 || (EnumCommunityActions$3 = {}));
|
|
35556
|
+
|
|
35557
|
+
class CommunityLiveCollectionController extends LiveCollectionController {
|
|
35558
|
+
constructor(query, callback) {
|
|
35559
|
+
const queryStreamId = hash(query);
|
|
35560
|
+
const cacheKey = ['community', 'collection', queryStreamId];
|
|
35561
|
+
const paginationController = new CommunitiesPaginationController(query);
|
|
35562
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
35563
|
+
this.query = query;
|
|
35564
|
+
this.queryStreamController = new CommunitiesQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommunityPayload);
|
|
35565
|
+
this.callback = callback.bind(this);
|
|
35566
|
+
this.loadPage({ initial: true });
|
|
35567
|
+
}
|
|
35568
|
+
setup() {
|
|
35569
|
+
var _a;
|
|
35570
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35571
|
+
if (!collection) {
|
|
35572
|
+
pushToCache(this.cacheKey, {
|
|
35573
|
+
data: [],
|
|
35574
|
+
params: {},
|
|
35575
|
+
});
|
|
35576
|
+
}
|
|
35577
|
+
}
|
|
35578
|
+
async persistModel(queryPayload) {
|
|
35579
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
35580
|
+
}
|
|
35581
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
35582
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
35583
|
+
}
|
|
35584
|
+
startSubscription() {
|
|
35585
|
+
return this.queryStreamController.subscribeRTE([
|
|
35586
|
+
{ fn: onCommunityCreated, action: EnumCommunityActions$3.OnCommunityCreated },
|
|
35587
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$3.OnCommunityDeleted },
|
|
35588
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$3.OnCommunityUpdated },
|
|
35589
|
+
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
35590
|
+
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
35591
|
+
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
35592
|
+
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
35593
|
+
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
35594
|
+
]);
|
|
35595
|
+
}
|
|
35596
|
+
notifyChange({ origin, loading, error }) {
|
|
35597
|
+
var _a, _b;
|
|
35598
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
35599
|
+
if (!collection)
|
|
35600
|
+
return;
|
|
35601
|
+
const data = this.applyFilter((_b = collection.data
|
|
35602
|
+
.map(id => pullFromCache(['community', 'get', id]))
|
|
35603
|
+
.filter(isNonNullable)
|
|
35604
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
|
|
35605
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
35606
|
+
return;
|
|
35607
|
+
this.callback({
|
|
35608
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
35609
|
+
data,
|
|
35610
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
35611
|
+
loading,
|
|
35612
|
+
error,
|
|
35613
|
+
});
|
|
35614
|
+
}
|
|
35615
|
+
applyFilter(data) {
|
|
35616
|
+
const { userId } = getActiveClient();
|
|
35617
|
+
let communities = data;
|
|
35618
|
+
if (!this.query.includeDeleted) {
|
|
35619
|
+
communities = filterByPropEquality(communities, 'isDeleted', false);
|
|
35620
|
+
}
|
|
35621
|
+
if (this.query.categoryId) {
|
|
35622
|
+
communities = communities.filter(c => { var _a; return (_a = c.categoryIds) === null || _a === void 0 ? void 0 : _a.includes(this.query.categoryId); });
|
|
35623
|
+
}
|
|
35624
|
+
if (this.query.tags) {
|
|
35625
|
+
communities = communities.filter(c => { var _a; return (_a = c.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = this.query.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
35626
|
+
}
|
|
35627
|
+
if (this.query.membership && userId) {
|
|
35628
|
+
communities = filterByCommunityMembership(communities, this.query.membership, userId);
|
|
36726
35629
|
}
|
|
35630
|
+
const sortFn = (() => {
|
|
35631
|
+
switch (this.query.sortBy) {
|
|
35632
|
+
case 'firstCreated':
|
|
35633
|
+
return sortByFirstCreated;
|
|
35634
|
+
case 'lastCreated':
|
|
35635
|
+
return sortByLastCreated;
|
|
35636
|
+
default:
|
|
35637
|
+
return sortByLastCreated;
|
|
35638
|
+
}
|
|
35639
|
+
})();
|
|
35640
|
+
communities = communities.sort(sortFn);
|
|
36727
35641
|
return communities;
|
|
36728
35642
|
}
|
|
36729
35643
|
}
|
|
@@ -37477,11 +36391,9 @@ var index$9 = /*#__PURE__*/Object.freeze({
|
|
|
37477
36391
|
deleteCommunity: deleteCommunity,
|
|
37478
36392
|
joinCommunity: joinCommunity,
|
|
37479
36393
|
leaveCommunity: leaveCommunity,
|
|
37480
|
-
getTopTrendingCommunities: getTopTrendingCommunities,
|
|
37481
36394
|
onCommunityCreated: onCommunityCreated,
|
|
37482
36395
|
onCommunityUpdated: onCommunityUpdated,
|
|
37483
36396
|
onCommunityDeleted: onCommunityDeleted,
|
|
37484
|
-
observeCommunity: observeCommunity,
|
|
37485
36397
|
searchCommunities: searchCommunities,
|
|
37486
36398
|
getCommunities: getCommunities,
|
|
37487
36399
|
getCommunity: getCommunity,
|
|
@@ -37731,21 +36643,10 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
37731
36643
|
const queryGlobalFeed = async (query) => {
|
|
37732
36644
|
const client = getActiveClient();
|
|
37733
36645
|
client.log('feed/queryGlobalFeed', query);
|
|
37734
|
-
const _a = query !== null && query !== void 0 ? query : {}, {
|
|
37735
|
-
/*
|
|
37736
|
-
* TODO: Remove useCustomRanking key from query
|
|
37737
|
-
*/
|
|
37738
|
-
if (useCustomRanking)
|
|
37739
|
-
console.warn('The param "useCustomRanking" has been deprecated. To get custom ranking feed use FeedRepository.getCustomRankingGlobalFeed instead');
|
|
37740
|
-
if (page)
|
|
37741
|
-
console.warn('The param "page" has been deprecated. Please use "queryToken" instead.');
|
|
36646
|
+
const _a = query !== null && query !== void 0 ? query : {}, { queryToken } = _a, params = __rest(_a, ["queryToken"]);
|
|
37742
36647
|
const options = (() => {
|
|
37743
36648
|
if (queryToken)
|
|
37744
36649
|
return { token: queryToken };
|
|
37745
|
-
if (page)
|
|
37746
|
-
return {
|
|
37747
|
-
token: toToken(page, 'skiplimit'),
|
|
37748
|
-
};
|
|
37749
36650
|
return undefined;
|
|
37750
36651
|
})();
|
|
37751
36652
|
const { data: queryPayload } = await client.http.get(`/api/v4/me/global-feeds`, {
|
|
@@ -37758,20 +36659,12 @@ const queryGlobalFeed = async (query) => {
|
|
|
37758
36659
|
const cachedAt = client.cache && Date.now();
|
|
37759
36660
|
if (client.cache) {
|
|
37760
36661
|
ingestInCache(Object.assign(Object.assign({}, data), { communitis: processedCommunity }));
|
|
37761
|
-
const cacheKey = [
|
|
37762
|
-
'globalFeed',
|
|
37763
|
-
'query',
|
|
37764
|
-
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
37765
|
-
];
|
|
36662
|
+
const cacheKey = ['globalFeed', 'query', Object.assign(Object.assign({}, params), { options })];
|
|
37766
36663
|
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
37767
36664
|
}
|
|
37768
|
-
const nextPage = toPage(paging.next);
|
|
37769
|
-
const prevPage = toPage(paging.previous);
|
|
37770
36665
|
return {
|
|
37771
36666
|
data: posts.map(LinkedObject.post),
|
|
37772
36667
|
cachedAt,
|
|
37773
|
-
prevPage,
|
|
37774
|
-
nextPage,
|
|
37775
36668
|
paging,
|
|
37776
36669
|
};
|
|
37777
36670
|
};
|
|
@@ -37796,12 +36689,8 @@ queryGlobalFeed.locally = (query) => {
|
|
|
37796
36689
|
client.log('post/queryGlobalFeed.locally', query);
|
|
37797
36690
|
if (!client.cache)
|
|
37798
36691
|
return;
|
|
37799
|
-
const
|
|
37800
|
-
const queryKey = [
|
|
37801
|
-
'globalFeed',
|
|
37802
|
-
'query',
|
|
37803
|
-
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
37804
|
-
];
|
|
36692
|
+
const params = __rest(query !== null && query !== void 0 ? query : {}, []);
|
|
36693
|
+
const queryKey = ['globalFeed', 'query', Object.assign({}, params)];
|
|
37805
36694
|
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
37806
36695
|
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
37807
36696
|
return;
|
|
@@ -37811,14 +36700,10 @@ queryGlobalFeed.locally = (query) => {
|
|
|
37811
36700
|
.map(({ data }) => data)
|
|
37812
36701
|
.map(LinkedObject.post);
|
|
37813
36702
|
const { paging } = data;
|
|
37814
|
-
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
37815
|
-
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
37816
36703
|
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
37817
36704
|
? {
|
|
37818
36705
|
data: posts,
|
|
37819
36706
|
cachedAt,
|
|
37820
|
-
prevPage,
|
|
37821
|
-
nextPage,
|
|
37822
36707
|
paging,
|
|
37823
36708
|
}
|
|
37824
36709
|
: undefined;
|
|
@@ -37844,14 +36729,10 @@ queryGlobalFeed.locally = (query) => {
|
|
|
37844
36729
|
const getCustomRankingGlobalFeed = async (query) => {
|
|
37845
36730
|
const client = getActiveClient();
|
|
37846
36731
|
client.log('feed/getCustomRankingGlobalFeed', query);
|
|
37847
|
-
const _a = query !== null && query !== void 0 ? query : {}, {
|
|
36732
|
+
const _a = query !== null && query !== void 0 ? query : {}, { queryToken, limit } = _a, params = __rest(_a, ["queryToken", "limit"]);
|
|
37848
36733
|
const options = (() => {
|
|
37849
36734
|
if (queryToken)
|
|
37850
36735
|
return { token: queryToken };
|
|
37851
|
-
if (page)
|
|
37852
|
-
return {
|
|
37853
|
-
token: toToken(page, 'skiplimit'),
|
|
37854
|
-
};
|
|
37855
36736
|
return undefined;
|
|
37856
36737
|
})();
|
|
37857
36738
|
const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
|
|
@@ -37863,16 +36744,10 @@ const getCustomRankingGlobalFeed = async (query) => {
|
|
|
37863
36744
|
const cachedAt = client.cache && Date.now();
|
|
37864
36745
|
if (client.cache) {
|
|
37865
36746
|
ingestInCache(data);
|
|
37866
|
-
const cacheKey = [
|
|
37867
|
-
'customGlobalFeed',
|
|
37868
|
-
'query',
|
|
37869
|
-
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
37870
|
-
];
|
|
36747
|
+
const cacheKey = ['customGlobalFeed', 'query', Object.assign(Object.assign({}, params), { options })];
|
|
37871
36748
|
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
37872
36749
|
}
|
|
37873
|
-
|
|
37874
|
-
const prevPage = toPage(paging.previous);
|
|
37875
|
-
return { data: posts.map(LinkedObject.post), cachedAt, prevPage, nextPage, paging };
|
|
36750
|
+
return { data: posts.map(LinkedObject.post), cachedAt, paging };
|
|
37876
36751
|
};
|
|
37877
36752
|
/* end_public_function */
|
|
37878
36753
|
/**
|
|
@@ -37895,12 +36770,8 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
37895
36770
|
client.log('post/getCustomRankingGlobalFeed.locally', query);
|
|
37896
36771
|
if (!client.cache)
|
|
37897
36772
|
return;
|
|
37898
|
-
const
|
|
37899
|
-
const queryKey = [
|
|
37900
|
-
'customGlobalFeed',
|
|
37901
|
-
'query',
|
|
37902
|
-
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
37903
|
-
];
|
|
36773
|
+
const params = __rest(query !== null && query !== void 0 ? query : {}, []);
|
|
36774
|
+
const queryKey = ['customGlobalFeed', 'query', Object.assign({}, params)];
|
|
37904
36775
|
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
37905
36776
|
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
37906
36777
|
return;
|
|
@@ -37908,11 +36779,9 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
37908
36779
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
37909
36780
|
.filter(Boolean)
|
|
37910
36781
|
.map(({ data }) => data);
|
|
37911
|
-
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
37912
|
-
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
37913
36782
|
const { paging } = data;
|
|
37914
36783
|
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
37915
|
-
? { data: posts.map(LinkedObject.post), cachedAt,
|
|
36784
|
+
? { data: posts.map(LinkedObject.post), cachedAt, paging }
|
|
37916
36785
|
: undefined;
|
|
37917
36786
|
};
|
|
37918
36787
|
|
|
@@ -38043,44 +36912,6 @@ const createPost = async (bundle) => {
|
|
|
38043
36912
|
};
|
|
38044
36913
|
/* end_public_function */
|
|
38045
36914
|
|
|
38046
|
-
/* begin_public_function
|
|
38047
|
-
id: post.edit
|
|
38048
|
-
*/
|
|
38049
|
-
/**
|
|
38050
|
-
* ```js
|
|
38051
|
-
* import { updatePost } from '@amityco/ts-sdk'
|
|
38052
|
-
* const updated = await updatePost(postId, {
|
|
38053
|
-
* data: { text: 'hello world' }
|
|
38054
|
-
* })
|
|
38055
|
-
* ```
|
|
38056
|
-
*
|
|
38057
|
-
* Updates an {@link Amity.Post}
|
|
38058
|
-
*
|
|
38059
|
-
* @param postId The ID of the {@link Amity.Post} to edit
|
|
38060
|
-
* @param patch The patch data to apply
|
|
38061
|
-
* @returns the updated {@link Amity.Post} object
|
|
38062
|
-
*
|
|
38063
|
-
* @category Post API
|
|
38064
|
-
* @async
|
|
38065
|
-
*/
|
|
38066
|
-
const updatePost = async (postId, patch) => {
|
|
38067
|
-
const client = getActiveClient();
|
|
38068
|
-
client.log('user/updatePost', patch);
|
|
38069
|
-
console.warn('Deprecation: updatePost has been renamed to editPost. Update post API will be deprecated soon.');
|
|
38070
|
-
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
38071
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
38072
|
-
const cachedAt = client.cache && Date.now();
|
|
38073
|
-
if (client.cache)
|
|
38074
|
-
ingestInCache(data, { cachedAt });
|
|
38075
|
-
fireEvent('local.post.updated', payload);
|
|
38076
|
-
const { posts } = data;
|
|
38077
|
-
return {
|
|
38078
|
-
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
38079
|
-
cachedAt,
|
|
38080
|
-
};
|
|
38081
|
-
};
|
|
38082
|
-
/* end_public_function */
|
|
38083
|
-
|
|
38084
36915
|
/* begin_public_function
|
|
38085
36916
|
id: post.edit, post.edit.custom_post
|
|
38086
36917
|
*/
|
|
@@ -38398,91 +37229,6 @@ const isPostFlaggedByMe = async (postId) => {
|
|
|
38398
37229
|
};
|
|
38399
37230
|
/* end_public_function */
|
|
38400
37231
|
|
|
38401
|
-
/**
|
|
38402
|
-
* ```js
|
|
38403
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
38404
|
-
*
|
|
38405
|
-
* let posts = []
|
|
38406
|
-
* const unsub = PostRepository.observePosts({
|
|
38407
|
-
* targetType: Amity.PostTargetType,
|
|
38408
|
-
* targetId: Amity.InternalPost['targetId'],
|
|
38409
|
-
* }, post => merge(posts, post))
|
|
38410
|
-
* ```
|
|
38411
|
-
*
|
|
38412
|
-
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
38413
|
-
*
|
|
38414
|
-
* @param params
|
|
38415
|
-
* @param callback the function to call when new data are available
|
|
38416
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
38417
|
-
*
|
|
38418
|
-
* @category Post Observer
|
|
38419
|
-
*/
|
|
38420
|
-
const observePosts = (params, callback) => {
|
|
38421
|
-
const { log } = getActiveClient();
|
|
38422
|
-
const timestamp = Date.now();
|
|
38423
|
-
log(`observePosts(tmpid: ${timestamp}) > listen`);
|
|
38424
|
-
const disposers = [];
|
|
38425
|
-
const router = (post, action) => {
|
|
38426
|
-
var _a, _b;
|
|
38427
|
-
if (params.targetId !== post.targetId || params.targetType !== post.targetType)
|
|
38428
|
-
return;
|
|
38429
|
-
if (callback instanceof Function)
|
|
38430
|
-
return callback(LinkedObject.post(post));
|
|
38431
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, LinkedObject.post(post));
|
|
38432
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, LinkedObject.post(post));
|
|
38433
|
-
};
|
|
38434
|
-
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')));
|
|
38435
|
-
return () => {
|
|
38436
|
-
log(`observePosts(tmpid: ${timestamp}) > dispose`);
|
|
38437
|
-
disposers.forEach(fn => fn());
|
|
38438
|
-
};
|
|
38439
|
-
};
|
|
38440
|
-
|
|
38441
|
-
/**
|
|
38442
|
-
* ```js
|
|
38443
|
-
* import { observePost } from '@amityco/ts-sdk'
|
|
38444
|
-
*
|
|
38445
|
-
* let post = {}
|
|
38446
|
-
* const dispose = observePost(postId, updated => post = updated)
|
|
38447
|
-
* ```
|
|
38448
|
-
*
|
|
38449
|
-
* Observe all mutations on a given {@link Amity.Post}
|
|
38450
|
-
*
|
|
38451
|
-
* @param postId the ID of the post to observe
|
|
38452
|
-
* @param callback the function to call when new data are available
|
|
38453
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the post
|
|
38454
|
-
*
|
|
38455
|
-
* @category Post Observer
|
|
38456
|
-
*/
|
|
38457
|
-
const observePost = (postId, callback, policy = 'cache_then_server') => {
|
|
38458
|
-
const { log } = getActiveClient();
|
|
38459
|
-
const timestamp = Date.now();
|
|
38460
|
-
log(`observePost(tmpid: ${timestamp}) > listen`);
|
|
38461
|
-
// wrapper function to make sure
|
|
38462
|
-
const router = (result, action) => {
|
|
38463
|
-
var _a, _b;
|
|
38464
|
-
if (callback instanceof Function)
|
|
38465
|
-
return callback(result);
|
|
38466
|
-
if (action !== 'onFetch')
|
|
38467
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, result);
|
|
38468
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, result);
|
|
38469
|
-
};
|
|
38470
|
-
const realtimeRouter = (result, action) => {
|
|
38471
|
-
var _a;
|
|
38472
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.postId) !== postId)
|
|
38473
|
-
return;
|
|
38474
|
-
router(Object.assign(Object.assign({}, result), { data: result.data && LinkedObject.post(result.data) }), action);
|
|
38475
|
-
};
|
|
38476
|
-
const disposers = [];
|
|
38477
|
-
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')));
|
|
38478
|
-
runQuery(createQuery(getPost$2, postId), result => (result.data || result.error) &&
|
|
38479
|
-
router(Object.assign(Object.assign({}, result), { data: result.data && LinkedObject.post(result.data) }), 'onFetch'), queryOptions(policy));
|
|
38480
|
-
return () => {
|
|
38481
|
-
log(`observePosts(tmpid: ${timestamp}) > dispose`);
|
|
38482
|
-
disposers.forEach(fn => fn());
|
|
38483
|
-
};
|
|
38484
|
-
};
|
|
38485
|
-
|
|
38486
37232
|
/* begin_public_function
|
|
38487
37233
|
id: comment.get_by_ids
|
|
38488
37234
|
*/
|
|
@@ -38958,43 +37704,6 @@ const isCommentFlaggedByMe = async (commentId) => {
|
|
|
38958
37704
|
};
|
|
38959
37705
|
/* end_public_function */
|
|
38960
37706
|
|
|
38961
|
-
/**
|
|
38962
|
-
* ```js
|
|
38963
|
-
* import { observeComments } from '@amityco/ts-sdk'
|
|
38964
|
-
*
|
|
38965
|
-
* let comments = []
|
|
38966
|
-
* const unsub = observeComments(postId, comment => merge(comments, comment))
|
|
38967
|
-
* ```
|
|
38968
|
-
*
|
|
38969
|
-
* Observe all mutations on a list of {@link Amity.InternalComment} for a given {@link Amity.Post} object
|
|
38970
|
-
*
|
|
38971
|
-
* @param postId the ID of the post where to observe the comments
|
|
38972
|
-
* @param callback the function to call when new data are available
|
|
38973
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comments
|
|
38974
|
-
*
|
|
38975
|
-
* @category InternalComment Observer
|
|
38976
|
-
*/
|
|
38977
|
-
const observeComments = (postId, callback) => {
|
|
38978
|
-
const { log } = getActiveClient();
|
|
38979
|
-
const timestamp = Date.now();
|
|
38980
|
-
log(`observeComments(tmpid: ${timestamp}) > listen`);
|
|
38981
|
-
const disposers = [];
|
|
38982
|
-
const router = (comment, action) => {
|
|
38983
|
-
var _a, _b;
|
|
38984
|
-
if (comment.referenceId !== postId)
|
|
38985
|
-
return;
|
|
38986
|
-
if (callback instanceof Function)
|
|
38987
|
-
return callback(comment);
|
|
38988
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, comment);
|
|
38989
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, comment);
|
|
38990
|
-
};
|
|
38991
|
-
disposers.push(onCommentCreated(comment => router(comment, 'onCreate')), onCommentUpdated(comment => router(comment, 'onUpdate')), onCommentDeleted(comment => router(comment, 'onDelete')), onCommentFlagged(comment => router(comment, 'onFlagged')), onCommentUnflagged(comment => router(comment, 'onUnflagged')), onCommentReactionAdded(comment => router(comment, 'onReactionAdded')), onCommentReactionRemoved(comment => router(comment, 'onReactionRemoved')));
|
|
38992
|
-
return () => {
|
|
38993
|
-
log(`observeComments(tmpid: ${timestamp}) > dispose`);
|
|
38994
|
-
disposers.forEach(fn => fn());
|
|
38995
|
-
};
|
|
38996
|
-
};
|
|
38997
|
-
|
|
38998
37707
|
const getComment$1 = async (commentId) => {
|
|
38999
37708
|
const client = getActiveClient();
|
|
39000
37709
|
client.log('comment/getComment', commentId);
|
|
@@ -39034,50 +37743,6 @@ getComment$1.locally = (commentId) => {
|
|
|
39034
37743
|
};
|
|
39035
37744
|
};
|
|
39036
37745
|
|
|
39037
|
-
/**
|
|
39038
|
-
* ```js
|
|
39039
|
-
* import { observeComment } from '@amityco/ts-sdk'
|
|
39040
|
-
*
|
|
39041
|
-
* let comment = {}
|
|
39042
|
-
* const dispose = observeComment(commentId, ({ data }) => comment = data)
|
|
39043
|
-
* ```
|
|
39044
|
-
*
|
|
39045
|
-
* Observe all mutation on a given {@link Amity.InternalComment}
|
|
39046
|
-
*
|
|
39047
|
-
* @param commentId the ID of the comment to observe
|
|
39048
|
-
* @param callback the function to call when new data are available
|
|
39049
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
39050
|
-
*
|
|
39051
|
-
* @category InternalComment Observer
|
|
39052
|
-
*/
|
|
39053
|
-
const observeComment = (commentId, callback, policy = 'cache_then_server') => {
|
|
39054
|
-
const { log } = getActiveClient();
|
|
39055
|
-
const timestamp = Date.now();
|
|
39056
|
-
log(`observeComment(tmpid: ${timestamp}) > listen`);
|
|
39057
|
-
// wrapper function to make sure
|
|
39058
|
-
const router = (result, action) => {
|
|
39059
|
-
var _a, _b;
|
|
39060
|
-
if (callback instanceof Function)
|
|
39061
|
-
return callback(result);
|
|
39062
|
-
if (action !== 'onFetch')
|
|
39063
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, result);
|
|
39064
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, result);
|
|
39065
|
-
};
|
|
39066
|
-
const realtimeRouter = (result, action) => {
|
|
39067
|
-
var _a;
|
|
39068
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.commentId) !== commentId)
|
|
39069
|
-
return;
|
|
39070
|
-
router(result, action);
|
|
39071
|
-
};
|
|
39072
|
-
const disposers = [];
|
|
39073
|
-
disposers.push(onCommentUpdated(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUpdate')), onCommentDeleted(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onDelete')), onCommentFlagged(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onFlagged')), onCommentUnflagged(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUnflagged')), onCommentReactionAdded(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onReactionAdded')), onCommentReactionRemoved(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onReactionRemoved')));
|
|
39074
|
-
runQuery(createQuery(getComment$1, commentId), result => (result.data || result.error) && router(result, 'onFetch'), queryOptions(policy));
|
|
39075
|
-
return () => {
|
|
39076
|
-
log(`observeComment(tmpid: ${timestamp}) > dispose`);
|
|
39077
|
-
disposers.forEach(fn => fn());
|
|
39078
|
-
};
|
|
39079
|
-
};
|
|
39080
|
-
|
|
39081
37746
|
/**
|
|
39082
37747
|
* ```js
|
|
39083
37748
|
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
@@ -39453,8 +38118,6 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
39453
38118
|
onCommentUnflagged: onCommentUnflagged,
|
|
39454
38119
|
onCommentReactionAdded: onCommentReactionAdded,
|
|
39455
38120
|
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
39456
|
-
observeComments: observeComments,
|
|
39457
|
-
observeComment: observeComment,
|
|
39458
38121
|
getComment: getComment,
|
|
39459
38122
|
getComments: getComments
|
|
39460
38123
|
});
|
|
@@ -40448,7 +39111,6 @@ var index$5 = /*#__PURE__*/Object.freeze({
|
|
|
40448
39111
|
__proto__: null,
|
|
40449
39112
|
getPostByIds: getPostByIds,
|
|
40450
39113
|
createPost: createPost,
|
|
40451
|
-
updatePost: updatePost,
|
|
40452
39114
|
editPost: editPost,
|
|
40453
39115
|
deletePost: deletePost,
|
|
40454
39116
|
softDeletePost: softDeletePost,
|
|
@@ -40467,8 +39129,6 @@ var index$5 = /*#__PURE__*/Object.freeze({
|
|
|
40467
39129
|
onPostUnflagged: onPostUnflagged,
|
|
40468
39130
|
onPostReactionAdded: onPostReactionAdded,
|
|
40469
39131
|
onPostReactionRemoved: onPostReactionRemoved,
|
|
40470
|
-
observePosts: observePosts,
|
|
40471
|
-
observePost: observePost,
|
|
40472
39132
|
getPost: getPost$1,
|
|
40473
39133
|
getPosts: getPosts,
|
|
40474
39134
|
getPinnedPosts: getPinnedPosts,
|
|
@@ -40661,47 +39321,6 @@ const disposeStream = async (streamId) => {
|
|
|
40661
39321
|
};
|
|
40662
39322
|
/* end_public_function */
|
|
40663
39323
|
|
|
40664
|
-
/* begin_public_function
|
|
40665
|
-
id: stream.query
|
|
40666
|
-
*/
|
|
40667
|
-
/**
|
|
40668
|
-
* @deprecated This API renamed to `getStreams`.
|
|
40669
|
-
* Please use getStreams() instead.
|
|
40670
|
-
* ```js
|
|
40671
|
-
* import { getStreams } from '@amityco/ts-sdk'
|
|
40672
|
-
* const streams = await getStreams()
|
|
40673
|
-
* ```
|
|
40674
|
-
*
|
|
40675
|
-
* Queries a paginable list of {@link Amity.InternalStream} objects
|
|
40676
|
-
*
|
|
40677
|
-
* @param query The query parameters
|
|
40678
|
-
* @returns A page of {@link Amity.InternalStream} objects
|
|
40679
|
-
*
|
|
40680
|
-
* @category Stream API
|
|
40681
|
-
* @async
|
|
40682
|
-
*/
|
|
40683
|
-
const queryStreams = async (query) => {
|
|
40684
|
-
const client = getActiveClient();
|
|
40685
|
-
client.log('stream/queryStreams', query);
|
|
40686
|
-
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
40687
|
-
const { data } = await client.http.get(`/api/v3/video-streaming`, {
|
|
40688
|
-
params: Object.assign(Object.assign({}, params), { options: {
|
|
40689
|
-
token: toToken(page, 'skiplimit'),
|
|
40690
|
-
} }),
|
|
40691
|
-
});
|
|
40692
|
-
// API-FIX: backend to response Amity.Response: const { paging, videoStreamings } = unwrapPayload(data)
|
|
40693
|
-
// API-FIX: seems returned data has a results identifier on top of data, like no other apis, and this is beautiful
|
|
40694
|
-
const { paging, results: payload } = data;
|
|
40695
|
-
const { videoStreamings } = payload;
|
|
40696
|
-
const cachedAt = client.cache && Date.now();
|
|
40697
|
-
if (client.cache)
|
|
40698
|
-
ingestInCache(payload, { cachedAt });
|
|
40699
|
-
const nextPage = toPage(paging.next);
|
|
40700
|
-
const prevPage = toPage(paging.previous);
|
|
40701
|
-
return { data: videoStreamings, cachedAt, prevPage, nextPage };
|
|
40702
|
-
};
|
|
40703
|
-
/* end_public_function */
|
|
40704
|
-
|
|
40705
39324
|
/**
|
|
40706
39325
|
* ```js
|
|
40707
39326
|
* import { onStreamStarted } from '@amityco/ts-sdk'
|
|
@@ -40723,7 +39342,7 @@ const onStreamStarted = (callback) => {
|
|
|
40723
39342
|
ingestInCache(payload);
|
|
40724
39343
|
callback(payload.videoStreamings[0]);
|
|
40725
39344
|
};
|
|
40726
|
-
return createEventSubscriber(client, 'stream/onStreamStarted', '
|
|
39345
|
+
return createEventSubscriber(client, 'stream/onStreamStarted', 'video-streaming.didStart', filter);
|
|
40727
39346
|
};
|
|
40728
39347
|
|
|
40729
39348
|
/**
|
|
@@ -40747,7 +39366,7 @@ const onStreamStopped = (callback) => {
|
|
|
40747
39366
|
ingestInCache(payload);
|
|
40748
39367
|
callback(payload.videoStreamings[0]);
|
|
40749
39368
|
};
|
|
40750
|
-
return createEventSubscriber(client, 'stream/onStreamStropped', '
|
|
39369
|
+
return createEventSubscriber(client, 'stream/onStreamStropped', 'video-streaming.didStop', filter);
|
|
40751
39370
|
};
|
|
40752
39371
|
|
|
40753
39372
|
/**
|
|
@@ -40771,7 +39390,7 @@ const onStreamRecorded = (callback) => {
|
|
|
40771
39390
|
ingestInCache(payload);
|
|
40772
39391
|
callback(payload.videoStreamings[0]);
|
|
40773
39392
|
};
|
|
40774
|
-
return createEventSubscriber(client, 'stream/onStreamRecorded', '
|
|
39393
|
+
return createEventSubscriber(client, 'stream/onStreamRecorded', 'video-streaming.didRecord', filter);
|
|
40775
39394
|
};
|
|
40776
39395
|
|
|
40777
39396
|
/**
|
|
@@ -40795,7 +39414,7 @@ const onStreamFlagged = (callback) => {
|
|
|
40795
39414
|
ingestInCache(payload);
|
|
40796
39415
|
callback(payload.videoStreamings[0]);
|
|
40797
39416
|
};
|
|
40798
|
-
return createEventSubscriber(client, 'stream/onStreamFlagged', '
|
|
39417
|
+
return createEventSubscriber(client, 'stream/onStreamFlagged', 'video-streaming.didFlag', filter);
|
|
40799
39418
|
};
|
|
40800
39419
|
|
|
40801
39420
|
/**
|
|
@@ -40819,7 +39438,7 @@ const onStreamTerminated = (callback) => {
|
|
|
40819
39438
|
ingestInCache(payload);
|
|
40820
39439
|
callback(payload.videoStreamings[0]);
|
|
40821
39440
|
};
|
|
40822
|
-
return createEventSubscriber(client, 'stream/onStreamTerminated', '
|
|
39441
|
+
return createEventSubscriber(client, 'stream/onStreamTerminated', 'video-streaming.didTerminate', filter);
|
|
40823
39442
|
};
|
|
40824
39443
|
|
|
40825
39444
|
/* eslint-disable no-use-before-define */
|
|
@@ -41028,8 +39647,6 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
41028
39647
|
updateStream: updateStream,
|
|
41029
39648
|
deleteStream: deleteStream,
|
|
41030
39649
|
disposeStream: disposeStream,
|
|
41031
|
-
queryStreams: queryStreams,
|
|
41032
|
-
getStream: getStream,
|
|
41033
39650
|
onStreamStarted: onStreamStarted,
|
|
41034
39651
|
onStreamStopped: onStreamStopped,
|
|
41035
39652
|
onStreamRecorded: onStreamRecorded,
|
|
@@ -41284,50 +39901,6 @@ const onPollDeleted = (callback) => {
|
|
|
41284
39901
|
return createEventSubscriber(client, 'poll/onPollDeleted', 'poll.deleted', filter);
|
|
41285
39902
|
};
|
|
41286
39903
|
|
|
41287
|
-
/**
|
|
41288
|
-
* ```js
|
|
41289
|
-
* import { observePoll } from '@amityco/ts-sdk'
|
|
41290
|
-
*
|
|
41291
|
-
* let poll = {}
|
|
41292
|
-
* const dispose = observePoll(pollId, updated => poll = updated)
|
|
41293
|
-
* ```
|
|
41294
|
-
*
|
|
41295
|
-
* Observe all mutation on a given {@link Amity.Poll}
|
|
41296
|
-
*
|
|
41297
|
-
* @param pollId the ID of the poll to observe
|
|
41298
|
-
* @param callback the function to call when new data are available
|
|
41299
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the poll
|
|
41300
|
-
*
|
|
41301
|
-
* @category Poll Observer
|
|
41302
|
-
*/
|
|
41303
|
-
const observePoll = (pollId, callback, policy = 'cache_then_server') => {
|
|
41304
|
-
const { log } = getActiveClient();
|
|
41305
|
-
const timestamp = Date.now();
|
|
41306
|
-
log(`observePoll(tmpid: ${timestamp}) > listen`);
|
|
41307
|
-
// wrapper function to make sure
|
|
41308
|
-
const router = (result, action) => {
|
|
41309
|
-
var _a, _b;
|
|
41310
|
-
if (callback instanceof Function)
|
|
41311
|
-
return callback(result);
|
|
41312
|
-
if (action !== 'onFetch')
|
|
41313
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, result);
|
|
41314
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, result);
|
|
41315
|
-
};
|
|
41316
|
-
const realtimeRouter = (result, action) => {
|
|
41317
|
-
var _a;
|
|
41318
|
-
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.pollId) !== pollId)
|
|
41319
|
-
return;
|
|
41320
|
-
router(result, action);
|
|
41321
|
-
};
|
|
41322
|
-
const disposers = [];
|
|
41323
|
-
disposers.push(onPollUpdated(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUpdate')), onPollDeleted(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onDelete')));
|
|
41324
|
-
runQuery(createQuery(getPoll$1, pollId), result => (result.data || result.error) && router(result, 'onFetch'), queryOptions(policy));
|
|
41325
|
-
return () => {
|
|
41326
|
-
log(`observePoll(tmpid: ${timestamp}) > dispose`);
|
|
41327
|
-
disposers.forEach(fn => fn());
|
|
41328
|
-
};
|
|
41329
|
-
};
|
|
41330
|
-
|
|
41331
39904
|
/* begin_public_function
|
|
41332
39905
|
id: poll.get
|
|
41333
39906
|
*/
|
|
@@ -41363,7 +39936,6 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
41363
39936
|
votePoll: votePoll,
|
|
41364
39937
|
onPollUpdated: onPollUpdated,
|
|
41365
39938
|
onPollDeleted: onPollDeleted,
|
|
41366
|
-
observePoll: observePoll,
|
|
41367
39939
|
getPoll: getPoll
|
|
41368
39940
|
});
|
|
41369
39941
|
|
|
@@ -41821,7 +40393,7 @@ const createOptimisticTarget = async ({ targetId, targetType, }) => {
|
|
|
41821
40393
|
optimisticTarget = Object.assign(Object.assign({}, optimisticTarget), { targetPublicId: community.data.communityId, targetUpdatedAt: (_a = community.data.updatedAt) !== null && _a !== void 0 ? _a : new Date().toISOString() });
|
|
41822
40394
|
}
|
|
41823
40395
|
if (targetType === 'user') {
|
|
41824
|
-
const user = await getUser$
|
|
40396
|
+
const user = await getUser$1(targetId);
|
|
41825
40397
|
optimisticTarget = Object.assign(Object.assign({}, optimisticTarget), { targetPublicId: user.data.userPublicId, targetUpdatedAt: (_b = user.data.updatedAt) !== null && _b !== void 0 ? _b : new Date().toISOString() });
|
|
41826
40398
|
}
|
|
41827
40399
|
pushToCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */, 'get', targetId], optimisticTarget);
|
|
@@ -42964,4 +41536,4 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
42964
41536
|
return { accessToken: data.accessToken };
|
|
42965
41537
|
};
|
|
42966
41538
|
|
|
42967
|
-
export { API_REGIONS, index as AdRepository, index$8 as CategoryRepository, index$c as ChannelRepository, index$l as Client, index$6 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$9 as CommunityRepository, ContentFeedType, DefaultCommunityPostSetting, index$7 as FeedRepository, FileAccessTypeEnum, index$i as FileRepository, FileType, index$2 as LiveStreamPlayer, MessageContentType, index$g as MessageRepository, index$3 as PollRepository, PostContentType, index$5 as PostRepository, index$h as ReactionRepository, index$1 as StoryRepository, index$4 as StreamRepository, index$f as SubChannelRepository, SubscriptionLevels, index$j as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|
|
41539
|
+
export { API_REGIONS, index as AdRepository, index$8 as CategoryRepository, index$c as ChannelRepository, index$l as Client, index$6 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$9 as CommunityRepository, ContentFeedType, DefaultCommunityPostSetting, index$7 as FeedRepository, FileAccessTypeEnum, index$i as FileRepository, FileType, index$2 as LiveStreamPlayer, MessageContentType, index$g as MessageRepository, index$3 as PollRepository, PostContentType, index$5 as PostRepository, index$h as ReactionRepository, index$1 as StoryRepository, index$4 as StreamRepository, index$f as SubChannelRepository, SubscriptionLevels, index$j as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|