@amityco/ts-sdk 7.8.1-fffd2ec.0 → 7.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +26 -26
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts +4 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/community.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/community.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/community.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts +36 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js +22 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts +11 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.d.ts +1 -4
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/poll.d.ts +3 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/poll.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/poll.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts +14 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts +16 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js +21 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js +6 -6
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.js +3 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.js +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js +3 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js +60 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js +66 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js +45 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js +60 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js +66 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js +45 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js +108 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js +78 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js +46 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts +4 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js +4 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts +6 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js +60 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/liveReactionRepository/api/createReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.d.ts +3 -3
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.js +2 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js +2 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js +26 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js +5 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js +17 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js +2 -50
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts +14 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js +126 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js +27 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js +65 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js +45 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js +61 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js +9 -4
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/tsconfig.tsbuildinfo +1 -1
- package/dist/@types/domains/client.d.ts +4 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +2 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +1 -0
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +36 -0
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/hashtag.d.ts +11 -0
- package/dist/@types/domains/hashtag.d.ts.map +1 -0
- package/dist/@types/domains/notification.d.ts +2 -1
- package/dist/@types/domains/notification.d.ts.map +1 -1
- package/dist/@types/domains/pinnedPost.d.ts +1 -4
- package/dist/@types/domains/pinnedPost.d.ts.map +1 -1
- package/dist/@types/domains/poll.d.ts +3 -1
- package/dist/@types/domains/poll.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +14 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/client/api/getShareableLinkConfiguration.d.ts +16 -0
- package/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -0
- package/dist/client/api/index.d.ts +2 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/feedRepository/api/index.d.ts +0 -1
- package/dist/feedRepository/api/index.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/index.d.ts +2 -1
- package/dist/feedRepository/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
- package/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/index.d.ts +4 -0
- package/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/dist/feedRepository/observers/utils.d.ts +6 -0
- package/dist/feedRepository/observers/utils.d.ts.map +1 -0
- package/dist/index.cjs.js +2135 -1282
- package/dist/index.esm.js +2038 -1185
- package/dist/index.umd.js +4 -4
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/dist/pollRepository/api/createPoll.d.ts +3 -3
- package/dist/pollRepository/api/createPoll.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts +1 -1
- package/dist/postRepository/api/editPost.d.ts +1 -1
- package/dist/postRepository/events/utils.d.ts.map +1 -1
- package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts +14 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts +15 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
- package/dist/postRepository/observers/index.d.ts +1 -0
- package/dist/postRepository/observers/index.d.ts.map +1 -1
- package/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
- package/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
- package/dist/postRepository/observers/utils.d.ts +13 -0
- package/dist/postRepository/observers/utils.d.ts.map +1 -0
- package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/client.ts +5 -0
- package/src/@types/domains/community.ts +1 -0
- package/src/@types/domains/content.ts +1 -0
- package/src/@types/domains/feed.ts +60 -0
- package/src/@types/domains/hashtag.ts +11 -0
- package/src/@types/domains/notification.ts +1 -0
- package/src/@types/domains/pinnedPost.ts +1 -4
- package/src/@types/domains/poll.ts +3 -1
- package/src/@types/domains/post.ts +18 -1
- package/src/@types/index.ts +2 -0
- package/src/client/api/getShareableLinkConfiguration.ts +26 -0
- package/src/client/api/index.ts +4 -0
- package/src/commentRepository/api/deleteComment.ts +6 -6
- package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +3 -3
- package/src/core/model/index.ts +2 -1
- package/src/feedRepository/api/index.ts +0 -1
- package/src/feedRepository/api/queryGlobalFeed.ts +3 -0
- package/src/feedRepository/index.ts +2 -1
- package/src/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.ts +95 -0
- package/src/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.ts +25 -0
- package/src/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.ts +101 -0
- package/src/feedRepository/observers/getCustomRankingGlobalFeed.ts +56 -0
- package/src/feedRepository/observers/getGlobalFeed/LiveCollectionController.ts +91 -0
- package/src/feedRepository/observers/getGlobalFeed/PaginationController.ts +23 -0
- package/src/feedRepository/observers/getGlobalFeed/QueryStreamController.ts +99 -0
- package/src/feedRepository/observers/getGlobalFeed.ts +56 -0
- package/src/feedRepository/observers/getUserFeed/LiveCollectionController.ts +162 -0
- package/src/feedRepository/observers/getUserFeed/PaginationController.ts +37 -0
- package/src/feedRepository/observers/getUserFeed/QueryStreamController.ts +119 -0
- package/src/feedRepository/observers/getUserFeed.ts +56 -0
- package/src/feedRepository/observers/index.ts +3 -0
- package/src/feedRepository/observers/utils.ts +85 -0
- package/src/liveReactionRepository/api/createReaction.ts +0 -1
- package/src/pollRepository/api/createPoll.ts +3 -3
- package/src/postRepository/api/createPost.ts +1 -1
- package/src/postRepository/api/editPost.ts +1 -1
- package/src/postRepository/api/queryPosts.ts +2 -2
- package/src/postRepository/events/utils.ts +35 -1
- package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.ts +5 -0
- package/src/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.ts +7 -1
- package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +27 -0
- package/src/postRepository/observers/getPosts/PostLiveCollectionController.ts +2 -74
- package/src/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.ts +183 -0
- package/src/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.ts +49 -0
- package/src/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.ts +99 -0
- package/src/postRepository/observers/index.ts +1 -0
- package/src/postRepository/observers/searchPostsByHashtag.ts +56 -0
- package/src/postRepository/observers/utils.ts +97 -0
- package/src/reactionRepository/api/addReaction.ts +1 -0
- package/src/reactionRepository/api/removeReaction.ts +1 -0
- package/src/utils/linkedObject/postLinkedObject.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.js +0 -83
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.js.map +0 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +0 -115
package/dist/index.cjs.js
CHANGED
|
@@ -153,10 +153,33 @@ exports.JoinResultStatusEnum = void 0;
|
|
|
153
153
|
JoinResultStatusEnum["Pending"] = "pending";
|
|
154
154
|
})(exports.JoinResultStatusEnum || (exports.JoinResultStatusEnum = {}));
|
|
155
155
|
|
|
156
|
+
exports.FeedDataTypeEnum = void 0;
|
|
157
|
+
(function (FeedDataTypeEnum) {
|
|
158
|
+
FeedDataTypeEnum["Text"] = "text";
|
|
159
|
+
FeedDataTypeEnum["Video"] = "video";
|
|
160
|
+
FeedDataTypeEnum["Image"] = "image";
|
|
161
|
+
FeedDataTypeEnum["File"] = "file";
|
|
162
|
+
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
163
|
+
FeedDataTypeEnum["Clip"] = "clip";
|
|
164
|
+
FeedDataTypeEnum["Poll"] = "poll";
|
|
165
|
+
})(exports.FeedDataTypeEnum || (exports.FeedDataTypeEnum = {}));
|
|
166
|
+
exports.FeedSortByEnum = void 0;
|
|
167
|
+
(function (FeedSortByEnum) {
|
|
168
|
+
FeedSortByEnum["LastCreated"] = "lastCreated";
|
|
169
|
+
FeedSortByEnum["FirstCreated"] = "firstCreated";
|
|
170
|
+
FeedSortByEnum["LastUpdated"] = "lastUpdated";
|
|
171
|
+
FeedSortByEnum["FirstUpdated"] = "firstUpdated";
|
|
172
|
+
})(exports.FeedSortByEnum || (exports.FeedSortByEnum = {}));
|
|
173
|
+
exports.FeedSourceEnum = void 0;
|
|
174
|
+
(function (FeedSourceEnum) {
|
|
175
|
+
FeedSourceEnum["Community"] = "community";
|
|
176
|
+
FeedSourceEnum["User"] = "user";
|
|
177
|
+
})(exports.FeedSourceEnum || (exports.FeedSourceEnum = {}));
|
|
178
|
+
|
|
156
179
|
function getVersion() {
|
|
157
180
|
try {
|
|
158
|
-
// the string ''v7.8.
|
|
159
|
-
return 'v7.8.
|
|
181
|
+
// the string ''v7.8.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
182
|
+
return 'v7.8.1-cjs';
|
|
160
183
|
}
|
|
161
184
|
catch (error) {
|
|
162
185
|
return '__dev__';
|
|
@@ -658,7 +681,8 @@ const PAYLOAD2MODEL = {
|
|
|
658
681
|
};
|
|
659
682
|
/** hidden */
|
|
660
683
|
const isOutdated = (prevData, nextData) => {
|
|
661
|
-
|
|
684
|
+
// Check if the new value is outdated.
|
|
685
|
+
if ('updatedAt' in nextData && 'updatedAt' in prevData) {
|
|
662
686
|
return new Date(nextData.updatedAt) < new Date(prevData.updatedAt);
|
|
663
687
|
}
|
|
664
688
|
return false;
|
|
@@ -9781,6 +9805,26 @@ const fetchLinkPreview = async (url) => {
|
|
|
9781
9805
|
return data;
|
|
9782
9806
|
};
|
|
9783
9807
|
|
|
9808
|
+
/**
|
|
9809
|
+
* ```js
|
|
9810
|
+
* import Client from '@amityco/ts-sdk'
|
|
9811
|
+
* const shareableLinkConfiguration = await Client.getShareableLinkConfiguration()
|
|
9812
|
+
* const postLinkPattern = shareableLinkConfiguration.post
|
|
9813
|
+
* ```
|
|
9814
|
+
*
|
|
9815
|
+
* Fetches a {@link Amity.ShareableLinkConfiguration} object
|
|
9816
|
+
*
|
|
9817
|
+
* @returns A Promise of {@link Amity.ShareableLinkConfiguration} object
|
|
9818
|
+
*
|
|
9819
|
+
* @category Client API
|
|
9820
|
+
* @async
|
|
9821
|
+
*/
|
|
9822
|
+
const getShareableLinkConfiguration = async () => {
|
|
9823
|
+
const client = getActiveClient();
|
|
9824
|
+
const { data } = await client.http.get(`/api/v3/network-settings/shareable-deep-links`);
|
|
9825
|
+
return data;
|
|
9826
|
+
};
|
|
9827
|
+
|
|
9784
9828
|
/**
|
|
9785
9829
|
* ```js
|
|
9786
9830
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk'
|
|
@@ -10150,6 +10194,8 @@ var index$o = /*#__PURE__*/Object.freeze({
|
|
|
10150
10194
|
enableUnreadCount: enableUnreadCount,
|
|
10151
10195
|
setUploadedFileAccessType: setUploadedFileAccessType,
|
|
10152
10196
|
fetchLinkPreview: fetchLinkPreview,
|
|
10197
|
+
getSocialSettings: getSocialSettings,
|
|
10198
|
+
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
10153
10199
|
onConnectionError: onConnectionError,
|
|
10154
10200
|
onClientDisconnected: onClientDisconnected,
|
|
10155
10201
|
onClientBanned: onClientBanned,
|
|
@@ -11853,15 +11899,18 @@ function isAmityClipPost(post) {
|
|
|
11853
11899
|
}
|
|
11854
11900
|
|
|
11855
11901
|
const postLinkedObject = (post) => {
|
|
11856
|
-
return
|
|
11902
|
+
return shallowClone(post, {
|
|
11903
|
+
childrenPosts: post.children
|
|
11857
11904
|
.map(childPost => { var _a; return (_a = pullFromCache(['post', 'get', childPost])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
11858
11905
|
.filter(isNonNullable)
|
|
11859
|
-
.map(postLinkedObject),
|
|
11906
|
+
.map(postLinkedObject),
|
|
11907
|
+
analytics: {
|
|
11860
11908
|
markAsViewed: () => {
|
|
11861
11909
|
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
11862
11910
|
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
11863
11911
|
},
|
|
11864
|
-
},
|
|
11912
|
+
},
|
|
11913
|
+
get latestComments() {
|
|
11865
11914
|
if (!post.comments)
|
|
11866
11915
|
return [];
|
|
11867
11916
|
return (post.comments
|
|
@@ -11935,7 +11984,8 @@ const postLinkedObject = (post) => {
|
|
|
11935
11984
|
return isAmityClipPost(post)
|
|
11936
11985
|
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
11937
11986
|
: undefined;
|
|
11938
|
-
}
|
|
11987
|
+
},
|
|
11988
|
+
});
|
|
11939
11989
|
};
|
|
11940
11990
|
|
|
11941
11991
|
const getCachedMarker = (message) => {
|
|
@@ -14930,7 +14980,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
14930
14980
|
]);
|
|
14931
14981
|
if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
14932
14982
|
return true;
|
|
14933
|
-
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
|
|
14983
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }), updatedAt: new Date().toISOString() });
|
|
14934
14984
|
if (referenceType === 'comment') {
|
|
14935
14985
|
fireEvent('local.comment.addReaction', {
|
|
14936
14986
|
comment: updatedModel,
|
|
@@ -15053,7 +15103,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
15053
15103
|
]);
|
|
15054
15104
|
if (!model)
|
|
15055
15105
|
return true;
|
|
15056
|
-
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }) });
|
|
15106
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }), updatedAt: new Date().toISOString() });
|
|
15057
15107
|
if (referenceType === 'comment') {
|
|
15058
15108
|
fireEvent('local.comment.removeReaction', {
|
|
15059
15109
|
comment: updatedModel,
|
|
@@ -15167,6 +15217,26 @@ const prepareSemanticSearchPostPayload = (_a) => {
|
|
|
15167
15217
|
return Object.assign(Object.assign({}, processedPostPayload), { polls });
|
|
15168
15218
|
};
|
|
15169
15219
|
|
|
15220
|
+
const processDeleteChildPost = (payload) => {
|
|
15221
|
+
var _a;
|
|
15222
|
+
const post = payload.posts[0];
|
|
15223
|
+
if (!post.parentId)
|
|
15224
|
+
return;
|
|
15225
|
+
const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
15226
|
+
if (!parentPost)
|
|
15227
|
+
return;
|
|
15228
|
+
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
|
|
15229
|
+
};
|
|
15230
|
+
const processCreateChildPost = (payload) => {
|
|
15231
|
+
var _a;
|
|
15232
|
+
const post = payload.posts[0];
|
|
15233
|
+
if (!post.parentId)
|
|
15234
|
+
return;
|
|
15235
|
+
const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
15236
|
+
if (!parentPost)
|
|
15237
|
+
return;
|
|
15238
|
+
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: [...new Set([post.postId, ...parentPost.children])] }));
|
|
15239
|
+
};
|
|
15170
15240
|
const createPostEventSubscriber = (event, callback) => {
|
|
15171
15241
|
const client = getActiveClient();
|
|
15172
15242
|
const filter = (payload) => {
|
|
@@ -15191,6 +15261,7 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
15191
15261
|
}
|
|
15192
15262
|
if (event === 'post.deleted') {
|
|
15193
15263
|
const { postId, postedUserId } = payload.posts[0];
|
|
15264
|
+
processDeleteChildPost(payload);
|
|
15194
15265
|
try {
|
|
15195
15266
|
isInTombstone('post', postId);
|
|
15196
15267
|
}
|
|
@@ -15217,6 +15288,8 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
15217
15288
|
}
|
|
15218
15289
|
queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
|
|
15219
15290
|
}
|
|
15291
|
+
if (event === 'post.created')
|
|
15292
|
+
processCreateChildPost(payload);
|
|
15220
15293
|
callback(post.data);
|
|
15221
15294
|
}
|
|
15222
15295
|
};
|
|
@@ -15243,6 +15316,8 @@ const createLocalPostEventSubscriber = (event, callback) => {
|
|
|
15243
15316
|
});
|
|
15244
15317
|
}
|
|
15245
15318
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
15319
|
+
if (event === 'local.post.deleted')
|
|
15320
|
+
processDeleteChildPost(payload);
|
|
15246
15321
|
callback(post.data);
|
|
15247
15322
|
}
|
|
15248
15323
|
};
|
|
@@ -21774,10 +21849,10 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
21774
21849
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21775
21850
|
if (!collection)
|
|
21776
21851
|
return;
|
|
21777
|
-
const data =
|
|
21852
|
+
const data = (_b = collection.data
|
|
21778
21853
|
.map(id => pullFromCache(['community', 'get', id]))
|
|
21779
21854
|
.filter(isNonNullable)
|
|
21780
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []
|
|
21855
|
+
.map(({ data }) => communityLinkedObject(data))) !== null && _b !== void 0 ? _b : [];
|
|
21781
21856
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
21782
21857
|
return;
|
|
21783
21858
|
this.callback({
|
|
@@ -23018,6 +23093,9 @@ var index$b = /*#__PURE__*/Object.freeze({
|
|
|
23018
23093
|
id: feed.query.global_feed
|
|
23019
23094
|
*/
|
|
23020
23095
|
/**
|
|
23096
|
+
*
|
|
23097
|
+
* @deprecated This function will to be deprecated. Please use getGlobalFeed instead.
|
|
23098
|
+
*
|
|
23021
23099
|
* ```js
|
|
23022
23100
|
* import { queryGlobalFeed } from '@amityco/ts-sdk'
|
|
23023
23101
|
* const posts = await queryGlobalFeed()
|
|
@@ -23100,1564 +23178,2131 @@ queryGlobalFeed.locally = (query) => {
|
|
|
23100
23178
|
: undefined;
|
|
23101
23179
|
};
|
|
23102
23180
|
|
|
23103
|
-
|
|
23104
|
-
|
|
23105
|
-
|
|
23106
|
-
|
|
23107
|
-
|
|
23108
|
-
|
|
23109
|
-
|
|
23110
|
-
|
|
23111
|
-
*
|
|
23112
|
-
* Queries a paginable list of {@link Amity.Post} objects
|
|
23113
|
-
*
|
|
23114
|
-
* @param query The query parameters
|
|
23115
|
-
* @returns A page of {@link Amity.Post} objects
|
|
23116
|
-
*
|
|
23117
|
-
* @category Feed API
|
|
23118
|
-
* @async
|
|
23119
|
-
* */
|
|
23120
|
-
const getCustomRankingGlobalFeed = async (query) => {
|
|
23121
|
-
const client = getActiveClient();
|
|
23122
|
-
client.log('feed/getCustomRankingGlobalFeed', query);
|
|
23123
|
-
const _a = query !== null && query !== void 0 ? query : {}, { queryToken, limit } = _a, params = __rest(_a, ["queryToken", "limit"]);
|
|
23124
|
-
const options = (() => {
|
|
23125
|
-
if (queryToken)
|
|
23126
|
-
return { token: queryToken };
|
|
23127
|
-
return undefined;
|
|
23128
|
-
})();
|
|
23129
|
-
const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
|
|
23130
|
-
params: Object.assign(Object.assign({}, params), { limit: !queryToken ? limit : undefined, options }),
|
|
23131
|
-
});
|
|
23132
|
-
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
23133
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23134
|
-
const { posts } = data;
|
|
23135
|
-
const cachedAt = client.cache && Date.now();
|
|
23136
|
-
if (client.cache) {
|
|
23137
|
-
ingestInCache(data);
|
|
23138
|
-
const cacheKey = ['customGlobalFeed', 'query', Object.assign(Object.assign({}, params), { options })];
|
|
23139
|
-
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
23181
|
+
class CustomRankingGlobalFeedPaginationController extends PaginationController {
|
|
23182
|
+
async getRequest(queryParams, token) {
|
|
23183
|
+
const { limit } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
23184
|
+
const options = token ? { token } : { limit };
|
|
23185
|
+
const { data: queryResponse } = await this.http.get(`/api/v5/me/global-feeds`, {
|
|
23186
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
23187
|
+
});
|
|
23188
|
+
return queryResponse;
|
|
23140
23189
|
}
|
|
23141
|
-
|
|
23142
|
-
};
|
|
23143
|
-
/* end_public_function */
|
|
23144
|
-
/**
|
|
23145
|
-
* ```js
|
|
23146
|
-
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
23147
|
-
* const posts = await FeedRepository.getCustomRankingGlobalFeed.locally()
|
|
23148
|
-
* ```
|
|
23149
|
-
*
|
|
23150
|
-
* Queries a paginable list of {@link Amity.Post} objects from cache
|
|
23151
|
-
*
|
|
23152
|
-
* @param query The query parameters
|
|
23153
|
-
* @returns A page of {@link Amity.Post} objects
|
|
23154
|
-
*
|
|
23155
|
-
* @category Feed API
|
|
23156
|
-
* @async
|
|
23157
|
-
* */
|
|
23158
|
-
getCustomRankingGlobalFeed.locally = (query) => {
|
|
23159
|
-
var _a, _b;
|
|
23160
|
-
const client = getActiveClient();
|
|
23161
|
-
client.log('post/getCustomRankingGlobalFeed.locally', query);
|
|
23162
|
-
if (!client.cache)
|
|
23163
|
-
return;
|
|
23164
|
-
const params = __rest(query !== null && query !== void 0 ? query : {}, []);
|
|
23165
|
-
const queryKey = ['customGlobalFeed', 'query', Object.assign({}, params)];
|
|
23166
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
23167
|
-
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
23168
|
-
return;
|
|
23169
|
-
const posts = data.posts
|
|
23170
|
-
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
23171
|
-
.filter(Boolean)
|
|
23172
|
-
.map(({ data }) => data);
|
|
23173
|
-
const { paging } = data;
|
|
23174
|
-
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
23175
|
-
? { data: posts.map(LinkedObject.post), cachedAt, paging }
|
|
23176
|
-
: undefined;
|
|
23177
|
-
};
|
|
23190
|
+
}
|
|
23178
23191
|
|
|
23179
|
-
var
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
|
|
23192
|
+
var EnumPostActions;
|
|
23193
|
+
(function (EnumPostActions) {
|
|
23194
|
+
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
23195
|
+
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
23196
|
+
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
23197
|
+
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
23198
|
+
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
23199
|
+
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
23200
|
+
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
23201
|
+
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
23202
|
+
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
23203
|
+
})(EnumPostActions || (EnumPostActions = {}));
|
|
23204
|
+
|
|
23205
|
+
class CustomRankingGlobalFeedQueryStreamController extends QueryStreamController {
|
|
23206
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
23207
|
+
super(query, cacheKey);
|
|
23208
|
+
this.notifyChange = notifyChange;
|
|
23209
|
+
this.preparePayload = preparePayload;
|
|
23210
|
+
}
|
|
23211
|
+
async saveToMainDB(response) {
|
|
23212
|
+
const processedPayload = await this.preparePayload(response);
|
|
23213
|
+
const client = getActiveClient();
|
|
23214
|
+
const cachedAt = client.cache && Date.now();
|
|
23215
|
+
if (client.cache) {
|
|
23216
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
23217
|
+
}
|
|
23218
|
+
}
|
|
23219
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
23220
|
+
var _a, _b;
|
|
23221
|
+
if (refresh) {
|
|
23222
|
+
pushToCache(this.cacheKey, {
|
|
23223
|
+
data: response.posts.map(getResolver('post')),
|
|
23224
|
+
});
|
|
23225
|
+
}
|
|
23226
|
+
else {
|
|
23227
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23228
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23229
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
23230
|
+
}
|
|
23231
|
+
}
|
|
23232
|
+
reactor(action) {
|
|
23233
|
+
return (post) => {
|
|
23234
|
+
var _a;
|
|
23235
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23236
|
+
if (!collection)
|
|
23237
|
+
return;
|
|
23238
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
23239
|
+
return;
|
|
23240
|
+
// Delete Action
|
|
23241
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
23242
|
+
// Parent Post - Remove from collection
|
|
23243
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
23244
|
+
}
|
|
23245
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
23246
|
+
// If the query has dataTypes array with value, check if post.dataType is include in the array
|
|
23247
|
+
if (this.query.dataTypes && this.query.dataTypes.length > 0) {
|
|
23248
|
+
if (!this.query.dataTypes.includes(post.dataType))
|
|
23249
|
+
return;
|
|
23250
|
+
}
|
|
23251
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
23252
|
+
}
|
|
23253
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
23254
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
23255
|
+
}
|
|
23256
|
+
pushToCache(this.cacheKey, collection);
|
|
23257
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
23258
|
+
};
|
|
23259
|
+
}
|
|
23260
|
+
subscribeRTE(createSubscriber) {
|
|
23261
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
23262
|
+
}
|
|
23263
|
+
}
|
|
23184
23264
|
|
|
23185
23265
|
/* begin_public_function
|
|
23186
|
-
id:
|
|
23266
|
+
id: comment.get_by_ids
|
|
23187
23267
|
*/
|
|
23188
23268
|
/**
|
|
23189
23269
|
* ```js
|
|
23190
|
-
* import {
|
|
23191
|
-
* const
|
|
23270
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23271
|
+
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
23192
23272
|
* ```
|
|
23193
23273
|
*
|
|
23194
|
-
* Fetches a collection of {@link Amity.
|
|
23274
|
+
* Fetches a collection of {@link Amity.Comment} objects
|
|
23195
23275
|
*
|
|
23196
|
-
* @param
|
|
23197
|
-
* @returns the associated collection of {@link Amity.
|
|
23276
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23277
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23198
23278
|
*
|
|
23199
|
-
* @category
|
|
23279
|
+
* @category Comment API
|
|
23200
23280
|
* @async
|
|
23201
23281
|
*/
|
|
23202
|
-
const
|
|
23282
|
+
const getCommentByIds = async (commentIds) => {
|
|
23203
23283
|
const client = getActiveClient();
|
|
23204
|
-
client.log('
|
|
23205
|
-
const
|
|
23206
|
-
let
|
|
23284
|
+
client.log('comment/getCommentByIds', commentIds);
|
|
23285
|
+
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
23286
|
+
let data;
|
|
23207
23287
|
try {
|
|
23208
23288
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23209
|
-
const response = await client.http.get(`/api/v3/
|
|
23210
|
-
params: {
|
|
23289
|
+
const response = await client.http.get(`/api/v3/comments/list`, {
|
|
23290
|
+
params: { commentIds: encodedCommentIds },
|
|
23211
23291
|
});
|
|
23212
|
-
|
|
23292
|
+
data = response.data;
|
|
23213
23293
|
}
|
|
23214
23294
|
catch (error) {
|
|
23215
|
-
|
|
23295
|
+
commentIds.forEach(commentId => {
|
|
23216
23296
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23217
|
-
pushToTombstone('
|
|
23297
|
+
pushToTombstone('comment', commentId);
|
|
23218
23298
|
}
|
|
23219
23299
|
});
|
|
23220
23300
|
throw error;
|
|
23221
23301
|
}
|
|
23222
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23223
23302
|
const cachedAt = client.cache && Date.now();
|
|
23224
23303
|
if (client.cache)
|
|
23225
23304
|
ingestInCache(data, { cachedAt });
|
|
23226
23305
|
return {
|
|
23227
|
-
data: data.
|
|
23306
|
+
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
23228
23307
|
cachedAt,
|
|
23229
23308
|
};
|
|
23230
23309
|
};
|
|
23231
23310
|
/* end_public_function */
|
|
23232
23311
|
/**
|
|
23233
23312
|
* ```js
|
|
23234
|
-
* import {
|
|
23235
|
-
* const
|
|
23313
|
+
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
23314
|
+
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
23236
23315
|
* ```
|
|
23237
23316
|
*
|
|
23238
|
-
* Fetches a collection of {@link Amity.
|
|
23317
|
+
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
23239
23318
|
*
|
|
23240
|
-
* @param
|
|
23241
|
-
* @returns the associated collection of {@link Amity.
|
|
23319
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
23320
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23242
23321
|
*
|
|
23243
|
-
* @category
|
|
23322
|
+
* @category Comment API
|
|
23244
23323
|
*/
|
|
23245
|
-
|
|
23324
|
+
getCommentByIds.locally = (commentIds) => {
|
|
23246
23325
|
var _a;
|
|
23247
23326
|
const client = getActiveClient();
|
|
23248
|
-
client.log('
|
|
23327
|
+
client.log('comment/getCommentByIds.locally', commentIds);
|
|
23249
23328
|
if (!client.cache)
|
|
23250
23329
|
return;
|
|
23251
|
-
const cached =
|
|
23252
|
-
.map(
|
|
23330
|
+
const cached = commentIds
|
|
23331
|
+
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
23253
23332
|
.filter(Boolean);
|
|
23254
|
-
const
|
|
23333
|
+
const comments = cached.map(({ data }) => data);
|
|
23255
23334
|
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
23256
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) <
|
|
23335
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
23257
23336
|
return;
|
|
23258
23337
|
return {
|
|
23259
|
-
data:
|
|
23338
|
+
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
23260
23339
|
cachedAt: oldest.cachedAt,
|
|
23261
23340
|
};
|
|
23262
23341
|
};
|
|
23263
23342
|
|
|
23264
23343
|
/* begin_public_function
|
|
23265
|
-
id:
|
|
23344
|
+
id: comment.create
|
|
23266
23345
|
*/
|
|
23267
23346
|
/**
|
|
23268
23347
|
* ```js
|
|
23269
|
-
* import {
|
|
23270
|
-
* const
|
|
23271
|
-
* targetType: 'user',
|
|
23272
|
-
* targetId: 'foobar',
|
|
23273
|
-
* data: { text: 'hello world' }
|
|
23274
|
-
* }))
|
|
23348
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23349
|
+
* const newComment = await CommentRepository.createComment(bundle)
|
|
23275
23350
|
* ```
|
|
23276
23351
|
*
|
|
23277
|
-
* Creates an {@link Amity.
|
|
23352
|
+
* Creates an {@link Amity.Comment}
|
|
23278
23353
|
*
|
|
23279
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
23280
|
-
* @returns The newly created {@link Amity.
|
|
23354
|
+
* @param bundle The data necessary to create a new {@link Amity.Comment}
|
|
23355
|
+
* @returns The newly created {@link Amity.Comment}
|
|
23281
23356
|
*
|
|
23282
|
-
* @category
|
|
23357
|
+
* @category Comment API
|
|
23283
23358
|
* @async
|
|
23284
23359
|
*/
|
|
23285
|
-
const
|
|
23360
|
+
const createComment = async (bundle) => {
|
|
23361
|
+
var _a;
|
|
23286
23362
|
const client = getActiveClient();
|
|
23287
|
-
client.log('
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
fireEvent('post.created', payload);
|
|
23294
|
-
const data = preparePostPayload(payload);
|
|
23363
|
+
client.log('comment/createComment', bundle);
|
|
23364
|
+
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
23365
|
+
const { comments } = data;
|
|
23366
|
+
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
23367
|
+
if (comments.length === 0)
|
|
23368
|
+
throw new Error('Comment not created');
|
|
23295
23369
|
const cachedAt = client.cache && Date.now();
|
|
23296
23370
|
if (client.cache)
|
|
23297
23371
|
ingestInCache(data, { cachedAt });
|
|
23298
|
-
|
|
23372
|
+
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
23373
|
+
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23374
|
+
if (post) {
|
|
23375
|
+
post.commentsCount += 1;
|
|
23376
|
+
fireEvent('local.post.updated', {
|
|
23377
|
+
posts: [post],
|
|
23378
|
+
categories: [],
|
|
23379
|
+
comments: [],
|
|
23380
|
+
communities: [],
|
|
23381
|
+
communityUsers: data.communityUsers,
|
|
23382
|
+
feeds: [],
|
|
23383
|
+
files: data.files,
|
|
23384
|
+
postChildren: [],
|
|
23385
|
+
users: data.users,
|
|
23386
|
+
videoStreamings: [],
|
|
23387
|
+
});
|
|
23388
|
+
}
|
|
23389
|
+
}
|
|
23390
|
+
else if (bundle.referenceType === 'story') {
|
|
23391
|
+
const storyIndex = pullFromCache([
|
|
23392
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23393
|
+
bundle.referenceId,
|
|
23394
|
+
]);
|
|
23395
|
+
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
23396
|
+
const cacheStory = pullFromCache([
|
|
23397
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
23398
|
+
'get',
|
|
23399
|
+
storyIndex.data,
|
|
23400
|
+
]);
|
|
23401
|
+
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
23402
|
+
fireEvent('story.updated', {
|
|
23403
|
+
stories: [
|
|
23404
|
+
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
23405
|
+
],
|
|
23406
|
+
categories: [],
|
|
23407
|
+
comments,
|
|
23408
|
+
communities: [],
|
|
23409
|
+
communityUsers: data.communityUsers,
|
|
23410
|
+
files: data.files,
|
|
23411
|
+
users: data.users,
|
|
23412
|
+
});
|
|
23413
|
+
}
|
|
23414
|
+
}
|
|
23415
|
+
}
|
|
23416
|
+
fireEvent('local.comment.created', data);
|
|
23299
23417
|
return {
|
|
23300
|
-
data: LinkedObject.
|
|
23418
|
+
data: LinkedObject.comment(comments[0]),
|
|
23301
23419
|
cachedAt,
|
|
23302
23420
|
};
|
|
23303
23421
|
};
|
|
23304
23422
|
/* end_public_function */
|
|
23305
23423
|
|
|
23306
23424
|
/* begin_public_function
|
|
23307
|
-
id:
|
|
23425
|
+
id: comment.update_comment
|
|
23308
23426
|
*/
|
|
23309
23427
|
/**
|
|
23310
23428
|
* ```js
|
|
23311
|
-
* import {
|
|
23312
|
-
* const updated = await
|
|
23429
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23430
|
+
* const updated = await CommentRepository.updateComment(commentId, {
|
|
23313
23431
|
* data: { text: 'hello world' }
|
|
23314
23432
|
* })
|
|
23315
23433
|
* ```
|
|
23316
23434
|
*
|
|
23317
|
-
* Updates an {@link Amity.
|
|
23435
|
+
* Updates an {@link Amity.Comment}
|
|
23318
23436
|
*
|
|
23319
|
-
* @param
|
|
23437
|
+
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
23320
23438
|
* @param patch The patch data to apply
|
|
23321
|
-
* @returns the updated {@link Amity.
|
|
23439
|
+
* @returns the updated {@link Amity.Comment} object
|
|
23322
23440
|
*
|
|
23323
|
-
* @category
|
|
23441
|
+
* @category Comment API
|
|
23324
23442
|
* @async
|
|
23325
23443
|
*/
|
|
23326
|
-
const
|
|
23444
|
+
const updateComment = async (commentId, patch) => {
|
|
23327
23445
|
const client = getActiveClient();
|
|
23328
|
-
client.log('user/
|
|
23329
|
-
const { data
|
|
23330
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23446
|
+
client.log('user/updateComment', patch);
|
|
23447
|
+
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
23331
23448
|
const cachedAt = client.cache && Date.now();
|
|
23332
23449
|
if (client.cache)
|
|
23333
23450
|
ingestInCache(data, { cachedAt });
|
|
23334
|
-
fireEvent('
|
|
23335
|
-
const {
|
|
23451
|
+
fireEvent('comment.updated', data);
|
|
23452
|
+
const { comments } = data;
|
|
23336
23453
|
return {
|
|
23337
|
-
data: LinkedObject.
|
|
23454
|
+
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
23338
23455
|
cachedAt,
|
|
23339
23456
|
};
|
|
23340
23457
|
};
|
|
23341
23458
|
/* end_public_function */
|
|
23342
23459
|
|
|
23460
|
+
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
23461
|
+
const applyMissingField = (rawData, isCreated = false) => {
|
|
23462
|
+
const { storyId, referenceId } = rawData;
|
|
23463
|
+
if (!isCreated) {
|
|
23464
|
+
if (referenceId)
|
|
23465
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
23466
|
+
}
|
|
23467
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
23468
|
+
};
|
|
23469
|
+
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
23470
|
+
const { stories } = data;
|
|
23471
|
+
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
23472
|
+
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
23473
|
+
};
|
|
23474
|
+
|
|
23475
|
+
const getStoryByStoryId$1 = async (storyId) => {
|
|
23476
|
+
const client = getActiveClient();
|
|
23477
|
+
client.log('story/getStoryByStoryId', storyId);
|
|
23478
|
+
// Get story referenceId from cache
|
|
23479
|
+
const cacheReferenceId = pullFromCache([
|
|
23480
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23481
|
+
storyId,
|
|
23482
|
+
]);
|
|
23483
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23484
|
+
const { data: referenceId } = cacheReferenceId;
|
|
23485
|
+
isInTombstone('story', referenceId);
|
|
23486
|
+
}
|
|
23487
|
+
let data;
|
|
23488
|
+
try {
|
|
23489
|
+
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
23490
|
+
data = convertRawStoryToInternal(response.data);
|
|
23491
|
+
}
|
|
23492
|
+
catch (error) {
|
|
23493
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23494
|
+
pushToTombstone('story', storyId);
|
|
23495
|
+
}
|
|
23496
|
+
throw error;
|
|
23497
|
+
}
|
|
23498
|
+
const cachedAt = client.cache && Date.now();
|
|
23499
|
+
if (client.cache) {
|
|
23500
|
+
ingestInCache(data, { cachedAt });
|
|
23501
|
+
}
|
|
23502
|
+
return {
|
|
23503
|
+
data: data.stories[0],
|
|
23504
|
+
cachedAt,
|
|
23505
|
+
};
|
|
23506
|
+
};
|
|
23507
|
+
getStoryByStoryId$1.locally = (storyId) => {
|
|
23508
|
+
const client = getActiveClient();
|
|
23509
|
+
client.log('story/getStorybyStoryId', storyId);
|
|
23510
|
+
// Get story referenceId from cache
|
|
23511
|
+
const cacheReferenceId = pullFromCache([
|
|
23512
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23513
|
+
storyId,
|
|
23514
|
+
]);
|
|
23515
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
23516
|
+
const { data: referenceId } = cacheReferenceId;
|
|
23517
|
+
isInTombstone('story', referenceId);
|
|
23518
|
+
}
|
|
23519
|
+
const cachedAt = client.cache && Date.now();
|
|
23520
|
+
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
23521
|
+
if (!storyCache)
|
|
23522
|
+
return;
|
|
23523
|
+
return {
|
|
23524
|
+
data: storyCache.data,
|
|
23525
|
+
cachedAt,
|
|
23526
|
+
};
|
|
23527
|
+
};
|
|
23528
|
+
|
|
23529
|
+
/* begin_public_function
|
|
23530
|
+
id: comment.soft_delete, comment.hard_delete
|
|
23531
|
+
*/
|
|
23343
23532
|
/**
|
|
23344
23533
|
* ```js
|
|
23345
|
-
* import {
|
|
23346
|
-
* const success = await
|
|
23534
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23535
|
+
* const success = await CommentRepository.deleteComment('foobar')
|
|
23347
23536
|
* ```
|
|
23348
23537
|
*
|
|
23349
|
-
* Deletes a {@link Amity.
|
|
23538
|
+
* Deletes a {@link Amity.Comment}
|
|
23350
23539
|
*
|
|
23351
|
-
* @param
|
|
23352
|
-
* @return A success boolean if the {@link Amity.
|
|
23540
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
23541
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
23353
23542
|
*
|
|
23354
|
-
* @
|
|
23543
|
+
* @category Comment API
|
|
23355
23544
|
* @async
|
|
23356
23545
|
*/
|
|
23357
|
-
const
|
|
23546
|
+
const deleteComment = async (commentId, permanent = false) => {
|
|
23358
23547
|
var _a;
|
|
23359
23548
|
const client = getActiveClient();
|
|
23360
|
-
const
|
|
23361
|
-
|
|
23549
|
+
const comment = await getComment$2(commentId);
|
|
23550
|
+
// API-FIX: This endpoint has not been implemented yet.
|
|
23551
|
+
await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
|
|
23362
23552
|
params: {
|
|
23363
|
-
|
|
23553
|
+
commentId,
|
|
23364
23554
|
permanent,
|
|
23365
23555
|
},
|
|
23366
23556
|
});
|
|
23367
|
-
//
|
|
23368
|
-
|
|
23369
|
-
|
|
23370
|
-
|
|
23371
|
-
|
|
23372
|
-
|
|
23373
|
-
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
if (key[1] !== 'get')
|
|
23380
|
-
return false;
|
|
23381
|
-
if (typeof key[2] === 'string')
|
|
23382
|
-
return key[2].includes(community.data.communityId);
|
|
23383
|
-
return false;
|
|
23384
|
-
})
|
|
23385
|
-
.map(({ data }) => data);
|
|
23386
|
-
fireEvent('community.updated', {
|
|
23387
|
-
communities: [community.data],
|
|
23557
|
+
// to support hard deletion
|
|
23558
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
23559
|
+
if (permanent) {
|
|
23560
|
+
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
23561
|
+
}
|
|
23562
|
+
else {
|
|
23563
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
23564
|
+
}
|
|
23565
|
+
if (comment.data.referenceType === 'story') {
|
|
23566
|
+
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
23567
|
+
fireEvent('local.story.updated', {
|
|
23568
|
+
stories: [story.data],
|
|
23388
23569
|
categories: [],
|
|
23389
|
-
|
|
23390
|
-
|
|
23570
|
+
comments: [],
|
|
23571
|
+
communities: [],
|
|
23572
|
+
communityUsers: [],
|
|
23391
23573
|
files: [],
|
|
23392
23574
|
users: [],
|
|
23393
23575
|
});
|
|
23394
23576
|
}
|
|
23395
|
-
// to support hard deletion
|
|
23396
|
-
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
23397
|
-
if (permanent) {
|
|
23398
|
-
setTimeout(() => {
|
|
23399
|
-
pushToTombstone('post', postId);
|
|
23400
|
-
}, 0);
|
|
23401
|
-
}
|
|
23402
23577
|
else {
|
|
23403
|
-
|
|
23578
|
+
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23579
|
+
if (post) {
|
|
23580
|
+
let removeCount;
|
|
23581
|
+
if (!deleted.parentId) {
|
|
23582
|
+
// NOTE: delete the parent comment will remove all children comments
|
|
23583
|
+
removeCount = deleted.childrenNumber + 1;
|
|
23584
|
+
}
|
|
23585
|
+
else
|
|
23586
|
+
removeCount = 1;
|
|
23587
|
+
post.commentsCount -= removeCount;
|
|
23588
|
+
fireEvent('local.post.updated', {
|
|
23589
|
+
posts: [post],
|
|
23590
|
+
categories: [],
|
|
23591
|
+
comments: [],
|
|
23592
|
+
communities: [],
|
|
23593
|
+
communityUsers: [],
|
|
23594
|
+
feeds: [],
|
|
23595
|
+
files: [],
|
|
23596
|
+
postChildren: [],
|
|
23597
|
+
users: [],
|
|
23598
|
+
videoStreamings: [],
|
|
23599
|
+
});
|
|
23600
|
+
}
|
|
23404
23601
|
}
|
|
23405
|
-
fireEvent('local.
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
comments: [],
|
|
23409
|
-
communities: [],
|
|
23410
|
-
communityUsers: [],
|
|
23411
|
-
feeds: [],
|
|
23602
|
+
fireEvent('local.comment.deleted', {
|
|
23603
|
+
comments: [deleted],
|
|
23604
|
+
commentChildren: [],
|
|
23412
23605
|
files: [],
|
|
23413
|
-
postChildren: [],
|
|
23414
23606
|
users: [],
|
|
23415
|
-
|
|
23607
|
+
communityUsers: [],
|
|
23416
23608
|
});
|
|
23417
|
-
return
|
|
23418
|
-
};
|
|
23419
|
-
|
|
23420
|
-
/* begin_public_function
|
|
23421
|
-
id: post.soft_delete
|
|
23422
|
-
*/
|
|
23423
|
-
/**
|
|
23424
|
-
* ```js
|
|
23425
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23426
|
-
* const success = await PostRepository.softDeletePost('foobar')
|
|
23427
|
-
* ```
|
|
23428
|
-
*
|
|
23429
|
-
* Soft deletes a {@link Amity.Post}
|
|
23430
|
-
*
|
|
23431
|
-
* @param postId The {@link Amity.Post} ID to soft delete
|
|
23432
|
-
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
23433
|
-
*
|
|
23434
|
-
* @category Post API
|
|
23435
|
-
* @async
|
|
23436
|
-
*/
|
|
23437
|
-
const softDeletePost = async (postId) => {
|
|
23438
|
-
const client = getActiveClient();
|
|
23439
|
-
client.log('post/softDeletePost', postId);
|
|
23440
|
-
const softDeleted = await deletePost(postId, false);
|
|
23441
|
-
return LinkedObject.post(softDeleted);
|
|
23442
|
-
};
|
|
23443
|
-
/* end_public_function */
|
|
23444
|
-
|
|
23445
|
-
/* begin_public_function
|
|
23446
|
-
id: post.hard_delete
|
|
23447
|
-
*/
|
|
23448
|
-
/**
|
|
23449
|
-
* ```js
|
|
23450
|
-
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
23451
|
-
* const success = await hardDeletePost('foobar')
|
|
23452
|
-
* ```
|
|
23453
|
-
*
|
|
23454
|
-
* Hard deletes a {@link Amity.Post}
|
|
23455
|
-
*
|
|
23456
|
-
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
23457
|
-
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
23458
|
-
*
|
|
23459
|
-
* @category Post API
|
|
23460
|
-
* @async
|
|
23461
|
-
*/
|
|
23462
|
-
const hardDeletePost = async (postId) => {
|
|
23463
|
-
const client = getActiveClient();
|
|
23464
|
-
client.log('post/hardDeletePost', postId);
|
|
23465
|
-
const hardDeleted = await deletePost(postId, true);
|
|
23466
|
-
return LinkedObject.post(hardDeleted);
|
|
23609
|
+
return deleted;
|
|
23467
23610
|
};
|
|
23468
23611
|
/* end_public_function */
|
|
23469
23612
|
|
|
23470
23613
|
/* begin_public_function
|
|
23471
|
-
id:
|
|
23614
|
+
id: comment.soft_delete
|
|
23472
23615
|
*/
|
|
23473
23616
|
/**
|
|
23474
23617
|
* ```js
|
|
23475
|
-
* import {
|
|
23476
|
-
*
|
|
23477
|
-
* const { data: post } = await approvePost('postId')
|
|
23618
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23619
|
+
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
23478
23620
|
* ```
|
|
23479
23621
|
*
|
|
23480
|
-
*
|
|
23622
|
+
* Deletes a {@link Amity.Comment}
|
|
23481
23623
|
*
|
|
23482
|
-
* @param
|
|
23483
|
-
* @return A {@link Amity.
|
|
23624
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
23625
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
23484
23626
|
*
|
|
23485
|
-
* @category
|
|
23627
|
+
* @category Comment API
|
|
23486
23628
|
* @async
|
|
23487
23629
|
*/
|
|
23488
|
-
const
|
|
23630
|
+
const softDeleteComment = async (commentId) => {
|
|
23489
23631
|
const client = getActiveClient();
|
|
23490
|
-
client.log('
|
|
23491
|
-
const
|
|
23492
|
-
|
|
23493
|
-
// fire virtual event for community update
|
|
23494
|
-
if (payload.posts[0].targetType === 'community') {
|
|
23495
|
-
fireEvent('community.updated', payload);
|
|
23496
|
-
}
|
|
23497
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23498
|
-
const cachedAt = client.cache && Date.now();
|
|
23499
|
-
if (client.cache)
|
|
23500
|
-
ingestInCache(data, { cachedAt });
|
|
23501
|
-
return {
|
|
23502
|
-
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
23503
|
-
cachedAt,
|
|
23504
|
-
};
|
|
23632
|
+
client.log('comment/softDeleteComment', commentId);
|
|
23633
|
+
const softDeleted = deleteComment(commentId);
|
|
23634
|
+
return softDeleted;
|
|
23505
23635
|
};
|
|
23506
23636
|
/* end_public_function */
|
|
23507
23637
|
|
|
23508
23638
|
/* begin_public_function
|
|
23509
|
-
id:
|
|
23639
|
+
id: comment.hard_delete
|
|
23510
23640
|
*/
|
|
23511
23641
|
/**
|
|
23512
23642
|
* ```js
|
|
23513
|
-
* import {
|
|
23514
|
-
*
|
|
23515
|
-
* const {data: post} = await declinePost('postId')
|
|
23643
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23644
|
+
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
23516
23645
|
* ```
|
|
23517
23646
|
*
|
|
23518
|
-
*
|
|
23647
|
+
* Deletes a {@link Amity.Comment}
|
|
23519
23648
|
*
|
|
23520
|
-
* @param
|
|
23521
|
-
* @return A {@link Amity.
|
|
23649
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
23650
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
23522
23651
|
*
|
|
23523
|
-
* @category
|
|
23652
|
+
* @category Comment API
|
|
23524
23653
|
* @async
|
|
23525
23654
|
*/
|
|
23526
|
-
const
|
|
23655
|
+
const hardDeleteComment = async (commentId) => {
|
|
23527
23656
|
const client = getActiveClient();
|
|
23528
|
-
client.log('
|
|
23529
|
-
const
|
|
23530
|
-
|
|
23531
|
-
if (payload.posts[0].targetType === 'community') {
|
|
23532
|
-
fireEvent('community.updated', payload);
|
|
23533
|
-
}
|
|
23534
|
-
fireEvent('post.declined', payload);
|
|
23535
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23536
|
-
const cachedAt = client.cache && Date.now();
|
|
23537
|
-
if (client.cache)
|
|
23538
|
-
ingestInCache(data, { cachedAt });
|
|
23539
|
-
return {
|
|
23540
|
-
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
23541
|
-
cachedAt,
|
|
23542
|
-
};
|
|
23657
|
+
client.log('comment/hardDeleteComment', commentId);
|
|
23658
|
+
const hardDeleted = deleteComment(commentId, true);
|
|
23659
|
+
return hardDeleted;
|
|
23543
23660
|
};
|
|
23544
23661
|
/* end_public_function */
|
|
23545
23662
|
|
|
23546
23663
|
/* begin_public_function
|
|
23547
|
-
id:
|
|
23664
|
+
id: comment.flag
|
|
23548
23665
|
*/
|
|
23549
23666
|
/**
|
|
23550
23667
|
* ```js
|
|
23551
|
-
* import {
|
|
23552
|
-
* const flagged = await
|
|
23668
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23669
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
23553
23670
|
* ```
|
|
23554
23671
|
*
|
|
23555
|
-
* @param
|
|
23556
|
-
* @param reason the reason to flag the
|
|
23557
|
-
* @returns
|
|
23672
|
+
* @param commentId The ID of the comment to flag
|
|
23673
|
+
* @param reason the reason to flag the comment
|
|
23674
|
+
* @returns the created report result
|
|
23558
23675
|
*
|
|
23559
|
-
* @category
|
|
23676
|
+
* @category Comment API
|
|
23560
23677
|
* @async
|
|
23561
23678
|
* */
|
|
23562
|
-
const
|
|
23679
|
+
const flagComment = async (commentId, reason) => {
|
|
23563
23680
|
const client = getActiveClient();
|
|
23564
|
-
client.log('
|
|
23681
|
+
client.log('comment/flagComment', commentId);
|
|
23565
23682
|
const isPredefinedReason = reason &&
|
|
23566
23683
|
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
23567
23684
|
const body = {
|
|
23568
23685
|
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
23569
23686
|
detail: reason && !isPredefinedReason ? reason : '',
|
|
23570
23687
|
};
|
|
23571
|
-
const { data: payload } = await client.http.post(`/api/v3/
|
|
23688
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
23572
23689
|
if (client.cache) {
|
|
23573
|
-
ingestInCache(
|
|
23690
|
+
ingestInCache(payload);
|
|
23574
23691
|
}
|
|
23575
|
-
fireEvent('
|
|
23692
|
+
fireEvent('comment.flagged', payload);
|
|
23576
23693
|
return !!payload;
|
|
23577
23694
|
};
|
|
23578
23695
|
/* end_public_function */
|
|
23579
23696
|
|
|
23580
23697
|
/* begin_public_function
|
|
23581
|
-
id:
|
|
23698
|
+
id: comment.unflag
|
|
23582
23699
|
*/
|
|
23583
23700
|
/**
|
|
23584
23701
|
* ```js
|
|
23585
|
-
* import {
|
|
23586
|
-
* const unflagged = await
|
|
23702
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23703
|
+
* const unflagged = await CommentRepository.unflagComment('commentId')
|
|
23587
23704
|
* ```
|
|
23588
23705
|
*
|
|
23589
|
-
* @param
|
|
23590
|
-
* @returns the
|
|
23706
|
+
* @param commentId The ID of comment to unflag
|
|
23707
|
+
* @returns the unflagged result
|
|
23591
23708
|
*
|
|
23592
|
-
* @category
|
|
23709
|
+
* @category Comment API
|
|
23593
23710
|
* @async
|
|
23594
23711
|
* */
|
|
23595
|
-
const
|
|
23712
|
+
const unflagComment = async (commentId) => {
|
|
23596
23713
|
const client = getActiveClient();
|
|
23597
|
-
client.log('
|
|
23598
|
-
const { data: payload } = await client.http.delete(`/api/v3/
|
|
23714
|
+
client.log('comment/unflagComment', commentId);
|
|
23715
|
+
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
23599
23716
|
if (client.cache) {
|
|
23600
|
-
ingestInCache(
|
|
23717
|
+
ingestInCache(payload);
|
|
23601
23718
|
}
|
|
23602
|
-
fireEvent('
|
|
23719
|
+
fireEvent('comment.unflagged', payload);
|
|
23603
23720
|
return !!payload;
|
|
23604
23721
|
};
|
|
23605
23722
|
/* end_public_function */
|
|
23606
23723
|
|
|
23607
23724
|
/* begin_public_function
|
|
23608
|
-
id:
|
|
23725
|
+
id: comment.check_flag_by_me
|
|
23609
23726
|
*/
|
|
23610
23727
|
/**
|
|
23611
23728
|
* ```js
|
|
23612
|
-
* import {
|
|
23613
|
-
* const isReported = await
|
|
23729
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23730
|
+
* const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
|
|
23614
23731
|
* ```
|
|
23615
23732
|
*
|
|
23616
|
-
* @param
|
|
23617
|
-
* @returns `true` if the
|
|
23733
|
+
* @param commentId The ID of the comment to check if flagged by current user
|
|
23734
|
+
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
23618
23735
|
*
|
|
23619
|
-
* @category
|
|
23736
|
+
* @category Comment API
|
|
23620
23737
|
* @async
|
|
23621
23738
|
* */
|
|
23622
|
-
const
|
|
23739
|
+
const isCommentFlaggedByMe = async (commentId) => {
|
|
23623
23740
|
const client = getActiveClient();
|
|
23624
|
-
client.log('
|
|
23625
|
-
const { data: { result }, } = await client.http.get(`/api/v3/
|
|
23741
|
+
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
23742
|
+
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
23626
23743
|
return result;
|
|
23627
23744
|
};
|
|
23628
23745
|
/* end_public_function */
|
|
23629
23746
|
|
|
23630
|
-
|
|
23631
|
-
id: post.create.clip_post
|
|
23632
|
-
*/
|
|
23633
|
-
/**
|
|
23634
|
-
* ```js
|
|
23635
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23636
|
-
* const created = await PostRepository.createClipPost({
|
|
23637
|
-
* targetType: 'user',
|
|
23638
|
-
* targetId: 'foobar',
|
|
23639
|
-
* dataType: 'clip',
|
|
23640
|
-
* data: { text: 'hello world' },
|
|
23641
|
-
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
23642
|
-
* }))
|
|
23643
|
-
* ```
|
|
23644
|
-
*
|
|
23645
|
-
* Creates an {@link Amity.Post}
|
|
23646
|
-
*
|
|
23647
|
-
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
23648
|
-
* @returns The newly created {@link Amity.Post}
|
|
23649
|
-
*
|
|
23650
|
-
* @category Post API
|
|
23651
|
-
* @async
|
|
23652
|
-
*/
|
|
23653
|
-
const createClipPost = async (bundle) => {
|
|
23747
|
+
const getComment$1 = async (commentId) => {
|
|
23654
23748
|
const client = getActiveClient();
|
|
23655
|
-
client.log('
|
|
23656
|
-
|
|
23657
|
-
|
|
23658
|
-
|
|
23749
|
+
client.log('comment/getComment', commentId);
|
|
23750
|
+
isInTombstone('comment', commentId);
|
|
23751
|
+
let data;
|
|
23752
|
+
try {
|
|
23753
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23754
|
+
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
23755
|
+
data = response.data;
|
|
23756
|
+
}
|
|
23757
|
+
catch (error) {
|
|
23758
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23759
|
+
pushToTombstone('comment', commentId);
|
|
23760
|
+
}
|
|
23761
|
+
throw error;
|
|
23762
|
+
}
|
|
23659
23763
|
const cachedAt = client.cache && Date.now();
|
|
23660
23764
|
if (client.cache)
|
|
23661
23765
|
ingestInCache(data, { cachedAt });
|
|
23662
|
-
const {
|
|
23766
|
+
const { comments } = data;
|
|
23663
23767
|
return {
|
|
23664
|
-
data:
|
|
23768
|
+
data: comments.find(comment => comment.commentId === commentId),
|
|
23665
23769
|
cachedAt,
|
|
23666
23770
|
};
|
|
23667
23771
|
};
|
|
23668
|
-
|
|
23772
|
+
getComment$1.locally = (commentId) => {
|
|
23773
|
+
const client = getActiveClient();
|
|
23774
|
+
client.log('comment/getComment.locally', commentId);
|
|
23775
|
+
if (!client.cache)
|
|
23776
|
+
return;
|
|
23777
|
+
const cached = pullFromCache(['comment', 'get', commentId]);
|
|
23778
|
+
if (!cached)
|
|
23779
|
+
return;
|
|
23780
|
+
return {
|
|
23781
|
+
data: cached.data,
|
|
23782
|
+
cachedAt: cached.cachedAt,
|
|
23783
|
+
};
|
|
23784
|
+
};
|
|
23669
23785
|
|
|
23670
|
-
/* begin_public_function
|
|
23671
|
-
id: comment.get_by_ids
|
|
23672
|
-
*/
|
|
23673
23786
|
/**
|
|
23674
23787
|
* ```js
|
|
23675
|
-
* import {
|
|
23676
|
-
* const
|
|
23677
|
-
*
|
|
23678
|
-
*
|
|
23679
|
-
*
|
|
23788
|
+
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
23789
|
+
* const dispose = onCommentDeleteLocal(comment => {
|
|
23790
|
+
* // ...
|
|
23791
|
+
* })
|
|
23792
|
+
* ```
|
|
23680
23793
|
*
|
|
23681
|
-
*
|
|
23682
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
23794
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
23683
23795
|
*
|
|
23684
|
-
* @
|
|
23685
|
-
* @
|
|
23796
|
+
* @param callback The function to call when the event was fired
|
|
23797
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23798
|
+
*
|
|
23799
|
+
* @category Comment Events
|
|
23686
23800
|
*/
|
|
23687
|
-
const
|
|
23688
|
-
|
|
23689
|
-
client.log('comment/getCommentByIds', commentIds);
|
|
23690
|
-
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
23691
|
-
let data;
|
|
23692
|
-
try {
|
|
23693
|
-
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
23694
|
-
const response = await client.http.get(`/api/v3/comments/list`, {
|
|
23695
|
-
params: { commentIds: encodedCommentIds },
|
|
23696
|
-
});
|
|
23697
|
-
data = response.data;
|
|
23698
|
-
}
|
|
23699
|
-
catch (error) {
|
|
23700
|
-
commentIds.forEach(commentId => {
|
|
23701
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
23702
|
-
pushToTombstone('comment', commentId);
|
|
23703
|
-
}
|
|
23704
|
-
});
|
|
23705
|
-
throw error;
|
|
23706
|
-
}
|
|
23707
|
-
const cachedAt = client.cache && Date.now();
|
|
23708
|
-
if (client.cache)
|
|
23709
|
-
ingestInCache(data, { cachedAt });
|
|
23710
|
-
return {
|
|
23711
|
-
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
23712
|
-
cachedAt,
|
|
23713
|
-
};
|
|
23714
|
-
};
|
|
23715
|
-
/* end_public_function */
|
|
23801
|
+
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
23802
|
+
|
|
23716
23803
|
/**
|
|
23717
23804
|
* ```js
|
|
23718
|
-
* import {
|
|
23719
|
-
* const
|
|
23805
|
+
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
|
|
23806
|
+
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
23807
|
+
* // ...
|
|
23808
|
+
* })
|
|
23720
23809
|
* ```
|
|
23721
23810
|
*
|
|
23722
|
-
*
|
|
23811
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
23723
23812
|
*
|
|
23724
|
-
* @param
|
|
23725
|
-
* @returns
|
|
23813
|
+
* @param callback The function to call when the event was fired
|
|
23814
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23726
23815
|
*
|
|
23727
|
-
* @category Comment
|
|
23816
|
+
* @category Comment Events
|
|
23728
23817
|
*/
|
|
23729
|
-
|
|
23730
|
-
var _a;
|
|
23818
|
+
const onLocalCommentReactionAdded = (callback) => {
|
|
23731
23819
|
const client = getActiveClient();
|
|
23732
|
-
|
|
23733
|
-
|
|
23734
|
-
|
|
23735
|
-
|
|
23736
|
-
|
|
23737
|
-
|
|
23738
|
-
|
|
23739
|
-
|
|
23740
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
23741
|
-
return;
|
|
23742
|
-
return {
|
|
23743
|
-
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
23744
|
-
cachedAt: oldest.cachedAt,
|
|
23820
|
+
const filter = ({ comment }) => {
|
|
23821
|
+
if (!client.cache) {
|
|
23822
|
+
callback(comment);
|
|
23823
|
+
}
|
|
23824
|
+
else {
|
|
23825
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
23826
|
+
callback(commentLinkedObject(comment));
|
|
23827
|
+
}
|
|
23745
23828
|
};
|
|
23829
|
+
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
23746
23830
|
};
|
|
23747
23831
|
|
|
23748
|
-
/* begin_public_function
|
|
23749
|
-
id: comment.create
|
|
23750
|
-
*/
|
|
23751
23832
|
/**
|
|
23752
23833
|
* ```js
|
|
23753
|
-
* import {
|
|
23754
|
-
* const
|
|
23834
|
+
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
|
|
23835
|
+
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
23836
|
+
* // ...
|
|
23837
|
+
* })
|
|
23755
23838
|
* ```
|
|
23756
23839
|
*
|
|
23757
|
-
*
|
|
23840
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
23758
23841
|
*
|
|
23759
|
-
* @param
|
|
23760
|
-
* @returns
|
|
23842
|
+
* @param callback The function to call when the event was fired
|
|
23843
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23761
23844
|
*
|
|
23762
|
-
* @category Comment
|
|
23763
|
-
* @async
|
|
23845
|
+
* @category Comment Events
|
|
23764
23846
|
*/
|
|
23765
|
-
const
|
|
23766
|
-
var _a;
|
|
23847
|
+
const onLocalCommentReactionRemoved = (callback) => {
|
|
23767
23848
|
const client = getActiveClient();
|
|
23768
|
-
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
23772
|
-
if (comments.length === 0)
|
|
23773
|
-
throw new Error('Comment not created');
|
|
23774
|
-
const cachedAt = client.cache && Date.now();
|
|
23775
|
-
if (client.cache)
|
|
23776
|
-
ingestInCache(data, { cachedAt });
|
|
23777
|
-
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
23778
|
-
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23779
|
-
if (post) {
|
|
23780
|
-
post.commentsCount += 1;
|
|
23781
|
-
fireEvent('local.post.updated', {
|
|
23782
|
-
posts: [post],
|
|
23783
|
-
categories: [],
|
|
23784
|
-
comments: [],
|
|
23785
|
-
communities: [],
|
|
23786
|
-
communityUsers: data.communityUsers,
|
|
23787
|
-
feeds: [],
|
|
23788
|
-
files: data.files,
|
|
23789
|
-
postChildren: [],
|
|
23790
|
-
users: data.users,
|
|
23791
|
-
videoStreamings: [],
|
|
23792
|
-
});
|
|
23849
|
+
const filter = ({ comment }) => {
|
|
23850
|
+
if (!client.cache) {
|
|
23851
|
+
callback(comment);
|
|
23793
23852
|
}
|
|
23794
|
-
|
|
23795
|
-
|
|
23796
|
-
|
|
23797
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
23798
|
-
bundle.referenceId,
|
|
23799
|
-
]);
|
|
23800
|
-
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
23801
|
-
const cacheStory = pullFromCache([
|
|
23802
|
-
"story" /* STORY_KEY_CACHE.STORY */,
|
|
23803
|
-
'get',
|
|
23804
|
-
storyIndex.data,
|
|
23805
|
-
]);
|
|
23806
|
-
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
23807
|
-
fireEvent('story.updated', {
|
|
23808
|
-
stories: [
|
|
23809
|
-
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
23810
|
-
],
|
|
23811
|
-
categories: [],
|
|
23812
|
-
comments,
|
|
23813
|
-
communities: [],
|
|
23814
|
-
communityUsers: data.communityUsers,
|
|
23815
|
-
files: data.files,
|
|
23816
|
-
users: data.users,
|
|
23817
|
-
});
|
|
23818
|
-
}
|
|
23853
|
+
else {
|
|
23854
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
23855
|
+
callback(commentLinkedObject(comment));
|
|
23819
23856
|
}
|
|
23820
|
-
}
|
|
23821
|
-
fireEvent('local.comment.created', data);
|
|
23822
|
-
return {
|
|
23823
|
-
data: LinkedObject.comment(comments[0]),
|
|
23824
|
-
cachedAt,
|
|
23825
23857
|
};
|
|
23858
|
+
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
23826
23859
|
};
|
|
23827
|
-
/* end_public_function */
|
|
23828
23860
|
|
|
23829
23861
|
/* begin_public_function
|
|
23830
|
-
id: comment.
|
|
23862
|
+
id: comment.get
|
|
23831
23863
|
*/
|
|
23832
23864
|
/**
|
|
23833
23865
|
* ```js
|
|
23834
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
23835
|
-
*
|
|
23836
|
-
*
|
|
23837
|
-
*
|
|
23866
|
+
* import { CommentRepository } from '@amityco/ts-sdk';
|
|
23867
|
+
*
|
|
23868
|
+
* let comment;
|
|
23869
|
+
*
|
|
23870
|
+
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
23871
|
+
* comment = response.data;
|
|
23872
|
+
* });
|
|
23838
23873
|
* ```
|
|
23839
23874
|
*
|
|
23840
|
-
*
|
|
23875
|
+
* Observe all mutation on a given {@link Amity.Comment}
|
|
23841
23876
|
*
|
|
23842
|
-
* @param commentId
|
|
23843
|
-
* @param
|
|
23844
|
-
* @returns
|
|
23877
|
+
* @param commentId the ID of the comment to observe
|
|
23878
|
+
* @param callback the function to call when new data are available
|
|
23879
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
23845
23880
|
*
|
|
23846
|
-
* @category Comment
|
|
23847
|
-
* @async
|
|
23881
|
+
* @category Comment Live Object
|
|
23848
23882
|
*/
|
|
23849
|
-
const
|
|
23850
|
-
|
|
23851
|
-
|
|
23852
|
-
|
|
23853
|
-
|
|
23854
|
-
|
|
23855
|
-
|
|
23856
|
-
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
|
|
23860
|
-
|
|
23861
|
-
};
|
|
23883
|
+
const getComment = (commentId, callback) => {
|
|
23884
|
+
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
23885
|
+
onCommentDeleteLocal,
|
|
23886
|
+
onCommentDeleted,
|
|
23887
|
+
onCommentFlagged,
|
|
23888
|
+
onCommentReactionAdded,
|
|
23889
|
+
onCommentReactionRemoved,
|
|
23890
|
+
onCommentUnflagged,
|
|
23891
|
+
onCommentUpdated,
|
|
23892
|
+
onLocalCommentReactionAdded,
|
|
23893
|
+
onLocalCommentReactionRemoved,
|
|
23894
|
+
]);
|
|
23862
23895
|
};
|
|
23863
23896
|
/* end_public_function */
|
|
23864
23897
|
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23898
|
+
class CommentPaginationController extends PaginationController {
|
|
23899
|
+
async getRequest(queryParams, token) {
|
|
23900
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
23901
|
+
const baseOptions = {
|
|
23902
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
23903
|
+
};
|
|
23904
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
23905
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
|
|
23906
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
23907
|
+
});
|
|
23908
|
+
return queryResponse;
|
|
23871
23909
|
}
|
|
23872
|
-
|
|
23873
|
-
};
|
|
23874
|
-
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
23875
|
-
const { stories } = data;
|
|
23876
|
-
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
23877
|
-
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
23878
|
-
};
|
|
23910
|
+
}
|
|
23879
23911
|
|
|
23880
|
-
|
|
23881
|
-
|
|
23882
|
-
|
|
23883
|
-
|
|
23884
|
-
|
|
23885
|
-
|
|
23886
|
-
|
|
23887
|
-
]
|
|
23888
|
-
|
|
23889
|
-
|
|
23890
|
-
|
|
23891
|
-
|
|
23892
|
-
|
|
23893
|
-
|
|
23894
|
-
|
|
23895
|
-
|
|
23912
|
+
var EnumCommentActions;
|
|
23913
|
+
(function (EnumCommentActions) {
|
|
23914
|
+
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
23915
|
+
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
23916
|
+
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
23917
|
+
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
23918
|
+
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
23919
|
+
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
23920
|
+
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
23921
|
+
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
23922
|
+
|
|
23923
|
+
class CommentQueryStreamController extends QueryStreamController {
|
|
23924
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
23925
|
+
super(query, cacheKey);
|
|
23926
|
+
this.notifyChange = notifyChange;
|
|
23927
|
+
this.preparePayload = preparePayload;
|
|
23896
23928
|
}
|
|
23897
|
-
|
|
23898
|
-
|
|
23899
|
-
|
|
23929
|
+
async saveToMainDB(response) {
|
|
23930
|
+
const processedPayload = await this.preparePayload(response);
|
|
23931
|
+
const client = getActiveClient();
|
|
23932
|
+
const cachedAt = client.cache && Date.now();
|
|
23933
|
+
if (client.cache) {
|
|
23934
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
23900
23935
|
}
|
|
23901
|
-
throw error;
|
|
23902
23936
|
}
|
|
23903
|
-
|
|
23904
|
-
|
|
23905
|
-
|
|
23937
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
23938
|
+
var _a, _b;
|
|
23939
|
+
if (refresh) {
|
|
23940
|
+
pushToCache(this.cacheKey, {
|
|
23941
|
+
data: response.comments.map(getResolver('comment')),
|
|
23942
|
+
});
|
|
23943
|
+
}
|
|
23944
|
+
else {
|
|
23945
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23946
|
+
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23947
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
|
|
23948
|
+
}
|
|
23906
23949
|
}
|
|
23907
|
-
|
|
23908
|
-
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
|
|
23919
|
-
|
|
23920
|
-
|
|
23921
|
-
|
|
23922
|
-
|
|
23950
|
+
reactor(action) {
|
|
23951
|
+
return (comment) => {
|
|
23952
|
+
var _a;
|
|
23953
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23954
|
+
if (this.query.referenceId !== comment.referenceId ||
|
|
23955
|
+
this.query.referenceType !== comment.referenceType ||
|
|
23956
|
+
!collection) {
|
|
23957
|
+
return;
|
|
23958
|
+
}
|
|
23959
|
+
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
23960
|
+
return;
|
|
23961
|
+
}
|
|
23962
|
+
if (!this.query.parentId && comment.parentId) {
|
|
23963
|
+
return;
|
|
23964
|
+
}
|
|
23965
|
+
if (action === EnumCommentActions.OnCommentCreated) {
|
|
23966
|
+
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
23967
|
+
}
|
|
23968
|
+
pushToCache(this.cacheKey, collection);
|
|
23969
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
23970
|
+
};
|
|
23923
23971
|
}
|
|
23924
|
-
|
|
23925
|
-
|
|
23926
|
-
|
|
23927
|
-
|
|
23928
|
-
return {
|
|
23929
|
-
data: storyCache.data,
|
|
23930
|
-
cachedAt,
|
|
23931
|
-
};
|
|
23932
|
-
};
|
|
23972
|
+
subscribeRTE(createSubscriber) {
|
|
23973
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
23974
|
+
}
|
|
23975
|
+
}
|
|
23933
23976
|
|
|
23934
|
-
/* begin_public_function
|
|
23935
|
-
id: comment.soft_delete, comment.hard_delete
|
|
23936
|
-
*/
|
|
23937
23977
|
/**
|
|
23938
23978
|
* ```js
|
|
23939
|
-
* import {
|
|
23940
|
-
* const
|
|
23979
|
+
* import { onCommentCreated } from '@amityco/ts-sdk'
|
|
23980
|
+
* const dispose = onCommentCreated(comment => {
|
|
23981
|
+
* // ...
|
|
23982
|
+
* })
|
|
23941
23983
|
* ```
|
|
23942
23984
|
*
|
|
23943
|
-
*
|
|
23985
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
23944
23986
|
*
|
|
23945
|
-
* @param
|
|
23946
|
-
* @
|
|
23987
|
+
* @param callback The function to call when the event was fired
|
|
23988
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23947
23989
|
*
|
|
23948
|
-
* @category Comment
|
|
23949
|
-
* @async
|
|
23990
|
+
* @category Comment Events
|
|
23950
23991
|
*/
|
|
23951
|
-
const
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
|
|
23955
|
-
|
|
23956
|
-
|
|
23957
|
-
|
|
23958
|
-
|
|
23959
|
-
|
|
23960
|
-
|
|
23961
|
-
|
|
23962
|
-
|
|
23963
|
-
|
|
23964
|
-
|
|
23965
|
-
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
23966
|
-
fireEvent('local.story.updated', {
|
|
23967
|
-
stories: [story.data],
|
|
23968
|
-
categories: [],
|
|
23969
|
-
comments: [],
|
|
23970
|
-
communities: [],
|
|
23971
|
-
communityUsers: [],
|
|
23972
|
-
files: [],
|
|
23973
|
-
users: [],
|
|
23974
|
-
});
|
|
23992
|
+
const onCommentCreatedLocal = (callback) => {
|
|
23993
|
+
return createLocalCommentEventSubscriber('local.comment.created', callback);
|
|
23994
|
+
};
|
|
23995
|
+
|
|
23996
|
+
class CommentLiveCollectionController extends LiveCollectionController {
|
|
23997
|
+
constructor(query, callback) {
|
|
23998
|
+
const queryStreamId = hash__default["default"](query);
|
|
23999
|
+
const cacheKey = ['comments', 'collection', queryStreamId];
|
|
24000
|
+
const paginationController = new CommentPaginationController(query);
|
|
24001
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24002
|
+
this.query = query;
|
|
24003
|
+
this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
|
|
24004
|
+
this.callback = callback.bind(this);
|
|
24005
|
+
this.loadPage({ initial: true });
|
|
23975
24006
|
}
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
}
|
|
23984
|
-
else
|
|
23985
|
-
removeCount = 1;
|
|
23986
|
-
post.commentsCount -= removeCount;
|
|
23987
|
-
fireEvent('local.post.updated', {
|
|
23988
|
-
posts: [post],
|
|
23989
|
-
categories: [],
|
|
23990
|
-
comments: [],
|
|
23991
|
-
communities: [],
|
|
23992
|
-
communityUsers: [],
|
|
23993
|
-
feeds: [],
|
|
23994
|
-
files: [],
|
|
23995
|
-
postChildren: [],
|
|
23996
|
-
users: [],
|
|
23997
|
-
videoStreamings: [],
|
|
24007
|
+
setup() {
|
|
24008
|
+
var _a;
|
|
24009
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24010
|
+
if (!collection) {
|
|
24011
|
+
pushToCache(this.cacheKey, {
|
|
24012
|
+
data: [],
|
|
24013
|
+
params: {},
|
|
23998
24014
|
});
|
|
23999
24015
|
}
|
|
24000
24016
|
}
|
|
24001
|
-
|
|
24002
|
-
|
|
24003
|
-
commentChildren: [],
|
|
24004
|
-
files: [],
|
|
24005
|
-
users: [],
|
|
24006
|
-
communityUsers: [],
|
|
24007
|
-
});
|
|
24008
|
-
if (permanent) {
|
|
24009
|
-
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
24017
|
+
async persistModel(queryPayload) {
|
|
24018
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24010
24019
|
}
|
|
24011
|
-
|
|
24012
|
-
|
|
24020
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
24021
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24022
|
+
}
|
|
24023
|
+
startSubscription() {
|
|
24024
|
+
return this.queryStreamController.subscribeRTE([
|
|
24025
|
+
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
24026
|
+
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
24027
|
+
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
24028
|
+
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
24029
|
+
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
24030
|
+
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
24031
|
+
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
24032
|
+
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24033
|
+
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
24034
|
+
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24035
|
+
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
24036
|
+
]);
|
|
24037
|
+
}
|
|
24038
|
+
notifyChange({ origin, loading, error }) {
|
|
24039
|
+
var _a, _b;
|
|
24040
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24041
|
+
if (!collection)
|
|
24042
|
+
return;
|
|
24043
|
+
const data = this.applyFilter((_b = collection.data
|
|
24044
|
+
.map(id => pullFromCache(['comment', 'get', id]))
|
|
24045
|
+
.filter(isNonNullable)
|
|
24046
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
24047
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
24048
|
+
return;
|
|
24049
|
+
this.callback({
|
|
24050
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24051
|
+
data,
|
|
24052
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24053
|
+
loading,
|
|
24054
|
+
error,
|
|
24055
|
+
});
|
|
24056
|
+
}
|
|
24057
|
+
applyFilter(data) {
|
|
24058
|
+
let comments = data;
|
|
24059
|
+
if (!this.query.includeDeleted) {
|
|
24060
|
+
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
24061
|
+
}
|
|
24062
|
+
if (this.query.parentId) {
|
|
24063
|
+
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
24064
|
+
}
|
|
24065
|
+
if (typeof this.query.hasFlag === 'boolean') {
|
|
24066
|
+
if (this.query.hasFlag) {
|
|
24067
|
+
comments = comments.filter(comment => comment.hashFlag != null);
|
|
24068
|
+
}
|
|
24069
|
+
else {
|
|
24070
|
+
comments = comments.filter(comment => comment.hashFlag == null);
|
|
24071
|
+
}
|
|
24072
|
+
}
|
|
24073
|
+
if (this.query.dataTypes) {
|
|
24074
|
+
if (this.query.dataTypes.matchType === 'exact') {
|
|
24075
|
+
comments = comments.filter(comment => {
|
|
24076
|
+
var _a, _b;
|
|
24077
|
+
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
24078
|
+
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
24079
|
+
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
24080
|
+
return false;
|
|
24081
|
+
}
|
|
24082
|
+
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
24083
|
+
});
|
|
24084
|
+
}
|
|
24085
|
+
if (this.query.dataTypes.matchType === 'any') {
|
|
24086
|
+
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
24087
|
+
}
|
|
24088
|
+
}
|
|
24089
|
+
switch (this.query.sortBy) {
|
|
24090
|
+
case 'firstCreated':
|
|
24091
|
+
comments = comments.sort(sortByFirstCreated);
|
|
24092
|
+
break;
|
|
24093
|
+
case 'lastCreated':
|
|
24094
|
+
default:
|
|
24095
|
+
comments = comments.sort(sortByLastCreated);
|
|
24096
|
+
break;
|
|
24097
|
+
}
|
|
24098
|
+
return comments;
|
|
24099
|
+
}
|
|
24100
|
+
}
|
|
24101
|
+
|
|
24102
|
+
/* begin_public_function
|
|
24103
|
+
id: comment.query
|
|
24104
|
+
*/
|
|
24105
|
+
/**
|
|
24106
|
+
* ```js
|
|
24107
|
+
* import { getComments } from '@amityco/ts-sdk'
|
|
24108
|
+
*
|
|
24109
|
+
* let comments = []
|
|
24110
|
+
* const unsub = getComments({
|
|
24111
|
+
* referenceType: Amity.InternalComment['referenceType'];
|
|
24112
|
+
* referenceId: Amity.InternalComment['referenceId'];
|
|
24113
|
+
* }, response => merge(comments, response.data))
|
|
24114
|
+
* ```
|
|
24115
|
+
*
|
|
24116
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
|
|
24117
|
+
*
|
|
24118
|
+
* @param referenceType the type of the target
|
|
24119
|
+
* @param referenceId the ID of the target
|
|
24120
|
+
* @param callback the function to call when new data are available
|
|
24121
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
24122
|
+
*
|
|
24123
|
+
* @category Comments Live Collection
|
|
24124
|
+
*/
|
|
24125
|
+
const getComments = (params, callback, config) => {
|
|
24126
|
+
const { log, cache } = getActiveClient();
|
|
24127
|
+
if (!cache) {
|
|
24128
|
+
console.log('For using Live Collection feature you need to enable Cache!');
|
|
24129
|
+
}
|
|
24130
|
+
const timestamp = Date.now();
|
|
24131
|
+
log(`getComments(tmpid: ${timestamp}) > listen`);
|
|
24132
|
+
const commentsLiveCollection = new CommentLiveCollectionController(params, callback);
|
|
24133
|
+
const disposers = commentsLiveCollection.startSubscription();
|
|
24134
|
+
const cacheKey = commentsLiveCollection.getCacheKey();
|
|
24135
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
24136
|
+
return () => {
|
|
24137
|
+
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
24138
|
+
disposers.forEach(fn => fn());
|
|
24139
|
+
};
|
|
24140
|
+
};
|
|
24141
|
+
/* end_public_function */
|
|
24142
|
+
|
|
24143
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
24144
|
+
__proto__: null,
|
|
24145
|
+
getCommentByIds: getCommentByIds,
|
|
24146
|
+
createComment: createComment,
|
|
24147
|
+
updateComment: updateComment,
|
|
24148
|
+
deleteComment: deleteComment,
|
|
24149
|
+
softDeleteComment: softDeleteComment,
|
|
24150
|
+
hardDeleteComment: hardDeleteComment,
|
|
24151
|
+
flagComment: flagComment,
|
|
24152
|
+
unflagComment: unflagComment,
|
|
24153
|
+
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
24154
|
+
onCommentCreated: onCommentCreated,
|
|
24155
|
+
onCommentUpdated: onCommentUpdated,
|
|
24156
|
+
onCommentDeleted: onCommentDeleted,
|
|
24157
|
+
onCommentFlagged: onCommentFlagged,
|
|
24158
|
+
onCommentUnflagged: onCommentUnflagged,
|
|
24159
|
+
onCommentReactionAdded: onCommentReactionAdded,
|
|
24160
|
+
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
24161
|
+
getComment: getComment,
|
|
24162
|
+
getComments: getComments
|
|
24163
|
+
});
|
|
24164
|
+
|
|
24165
|
+
const getPost$1 = async (postId) => {
|
|
24166
|
+
const client = getActiveClient();
|
|
24167
|
+
client.log('post/getPost', postId);
|
|
24168
|
+
isInTombstone('post', postId);
|
|
24169
|
+
let payload;
|
|
24170
|
+
try {
|
|
24171
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24172
|
+
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
24173
|
+
payload = response.data;
|
|
24174
|
+
}
|
|
24175
|
+
catch (error) {
|
|
24176
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24177
|
+
pushToTombstone('post', postId);
|
|
24178
|
+
}
|
|
24179
|
+
throw error;
|
|
24180
|
+
}
|
|
24181
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24182
|
+
const cachedAt = client.cache && Date.now();
|
|
24183
|
+
if (client.cache)
|
|
24184
|
+
ingestInCache(data, { cachedAt });
|
|
24185
|
+
const { posts } = data;
|
|
24186
|
+
const result = posts.find(post => post.postId === postId);
|
|
24187
|
+
return {
|
|
24188
|
+
data: result,
|
|
24189
|
+
cachedAt,
|
|
24190
|
+
};
|
|
24191
|
+
};
|
|
24192
|
+
getPost$1.locally = (postId) => {
|
|
24193
|
+
const client = getActiveClient();
|
|
24194
|
+
client.log('post/getPost.locally', postId);
|
|
24195
|
+
if (!client.cache)
|
|
24196
|
+
return;
|
|
24197
|
+
const cached = pullFromCache(['post', 'get', postId]);
|
|
24198
|
+
if (!cached)
|
|
24199
|
+
return;
|
|
24200
|
+
return {
|
|
24201
|
+
data: cached.data,
|
|
24202
|
+
cachedAt: cached.cachedAt,
|
|
24203
|
+
};
|
|
24204
|
+
};
|
|
24205
|
+
|
|
24206
|
+
/**
|
|
24207
|
+
* ```js
|
|
24208
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
24209
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
24210
|
+
* // ...
|
|
24211
|
+
* })
|
|
24212
|
+
* ```
|
|
24213
|
+
*
|
|
24214
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
24215
|
+
*
|
|
24216
|
+
* @param callback The function to call when the event was fired
|
|
24217
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24218
|
+
*
|
|
24219
|
+
* @category Post Events
|
|
24220
|
+
*/
|
|
24221
|
+
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
24222
|
+
|
|
24223
|
+
/**
|
|
24224
|
+
* ```js
|
|
24225
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
24226
|
+
* const dispose = onPostReactionAdded(post => {
|
|
24227
|
+
* // ...
|
|
24228
|
+
* })
|
|
24229
|
+
* ```
|
|
24230
|
+
*
|
|
24231
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
24232
|
+
*
|
|
24233
|
+
* @param callback The function to call when the event was fired
|
|
24234
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24235
|
+
*
|
|
24236
|
+
* @category Post Events
|
|
24237
|
+
*/
|
|
24238
|
+
const onLocalPostReactionAdded = (callback) => {
|
|
24239
|
+
const client = getActiveClient();
|
|
24240
|
+
const filter = ({ post }) => {
|
|
24241
|
+
if (!client.cache) {
|
|
24242
|
+
callback(post);
|
|
24243
|
+
}
|
|
24244
|
+
else {
|
|
24245
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
24246
|
+
callback(post);
|
|
24247
|
+
}
|
|
24248
|
+
};
|
|
24249
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
24250
|
+
};
|
|
24251
|
+
|
|
24252
|
+
/**
|
|
24253
|
+
* ```js
|
|
24254
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
|
|
24255
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
24256
|
+
* // ...
|
|
24257
|
+
* })
|
|
24258
|
+
* ```
|
|
24259
|
+
*
|
|
24260
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
24261
|
+
*
|
|
24262
|
+
* @param callback The function to call when the event was fired
|
|
24263
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24264
|
+
*
|
|
24265
|
+
* @category Post Events
|
|
24266
|
+
*/
|
|
24267
|
+
const onLocalPostReactionRemoved = (callback) => {
|
|
24268
|
+
const client = getActiveClient();
|
|
24269
|
+
const filter = ({ post }) => {
|
|
24270
|
+
if (!client.cache) {
|
|
24271
|
+
callback(post);
|
|
24272
|
+
}
|
|
24273
|
+
else {
|
|
24274
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
24275
|
+
callback(post);
|
|
24276
|
+
}
|
|
24277
|
+
};
|
|
24278
|
+
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
24279
|
+
};
|
|
24280
|
+
|
|
24281
|
+
/**
|
|
24282
|
+
* ```js
|
|
24283
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk'
|
|
24284
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
24285
|
+
* // ...
|
|
24286
|
+
* })
|
|
24287
|
+
* ```
|
|
24288
|
+
*
|
|
24289
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
24290
|
+
*
|
|
24291
|
+
* @param callback The function to call when the event was fired
|
|
24292
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
24293
|
+
*
|
|
24294
|
+
* @category Post Events
|
|
24295
|
+
*/
|
|
24296
|
+
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
24297
|
+
|
|
24298
|
+
const commentEventHandler$1 = (callback, eventHandler, cacheKey) => {
|
|
24299
|
+
return eventHandler(async (comment) => {
|
|
24300
|
+
var _a;
|
|
24301
|
+
const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24302
|
+
if (!currentCollection || !currentCollection.data.includes(comment.referenceId))
|
|
24303
|
+
return;
|
|
24304
|
+
await getPost$1(comment.referenceId);
|
|
24305
|
+
callback(comment);
|
|
24306
|
+
});
|
|
24307
|
+
};
|
|
24308
|
+
const generateCommentSubscriptions$1 = (cacheKey) => {
|
|
24309
|
+
const eventHandlers = [
|
|
24310
|
+
onCommentCreated,
|
|
24311
|
+
onCommentDeleted,
|
|
24312
|
+
onCommentReactionAdded,
|
|
24313
|
+
onCommentReactionRemoved,
|
|
24314
|
+
onCommentCreatedLocal,
|
|
24315
|
+
onCommentDeleteLocal,
|
|
24316
|
+
onLocalCommentReactionAdded,
|
|
24317
|
+
onLocalCommentReactionRemoved,
|
|
24318
|
+
];
|
|
24319
|
+
return eventHandlers.map(handler => ({
|
|
24320
|
+
fn: convertEventPayload((callback) => commentEventHandler$1(callback, handler, cacheKey), 'referenceId', 'post'),
|
|
24321
|
+
action: EnumPostActions.OnPostUpdated,
|
|
24322
|
+
}));
|
|
24323
|
+
};
|
|
24324
|
+
const getGlobalFeedSubscriptions = (cacheKey) => {
|
|
24325
|
+
return [
|
|
24326
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
24327
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
24328
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
24329
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24330
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
24331
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
24332
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
24333
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
24334
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24335
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24336
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24337
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24338
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24339
|
+
...generateCommentSubscriptions$1(cacheKey),
|
|
24340
|
+
];
|
|
24341
|
+
};
|
|
24342
|
+
|
|
24343
|
+
class CustomRankingGlobalFeedLiveCollectionController extends LiveCollectionController {
|
|
24344
|
+
constructor(query, callback) {
|
|
24345
|
+
const queryStreamId = hash__default["default"](query);
|
|
24346
|
+
const cacheKey = ['customRankingGlobalFeed', 'collection', queryStreamId];
|
|
24347
|
+
const paginationController = new CustomRankingGlobalFeedPaginationController(query);
|
|
24348
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24349
|
+
this.query = query;
|
|
24350
|
+
this.queryStreamController = new CustomRankingGlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
24351
|
+
this.callback = callback.bind(this);
|
|
24352
|
+
this.loadPage({ initial: true });
|
|
24353
|
+
}
|
|
24354
|
+
setup() {
|
|
24355
|
+
var _a;
|
|
24356
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24357
|
+
if (!collection) {
|
|
24358
|
+
pushToCache(this.cacheKey, {
|
|
24359
|
+
data: [],
|
|
24360
|
+
params: {},
|
|
24361
|
+
});
|
|
24362
|
+
}
|
|
24363
|
+
}
|
|
24364
|
+
async persistModel(queryPayload) {
|
|
24365
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24366
|
+
}
|
|
24367
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
24368
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24369
|
+
}
|
|
24370
|
+
startSubscription() {
|
|
24371
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
24372
|
+
}
|
|
24373
|
+
notifyChange({ origin, loading, error }) {
|
|
24374
|
+
var _a, _b;
|
|
24375
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24376
|
+
if (!collection)
|
|
24377
|
+
return;
|
|
24378
|
+
const data = ((_b = collection.data
|
|
24379
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
24380
|
+
.filter(isNonNullable)
|
|
24381
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
24382
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
24383
|
+
return;
|
|
24384
|
+
this.callback({
|
|
24385
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24386
|
+
data,
|
|
24387
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24388
|
+
loading,
|
|
24389
|
+
error,
|
|
24390
|
+
});
|
|
24391
|
+
}
|
|
24392
|
+
}
|
|
24393
|
+
|
|
24394
|
+
/* begin_public_function
|
|
24395
|
+
id: feed.query.custom_ranking_feed
|
|
24396
|
+
*/
|
|
24397
|
+
/**
|
|
24398
|
+
* ```js
|
|
24399
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
24400
|
+
*
|
|
24401
|
+
* let posts = []
|
|
24402
|
+
* const unsub = FeedRepository.getGlobalFeed({
|
|
24403
|
+
* dataTypes: ['video','image'],
|
|
24404
|
+
* resolveParent: true,
|
|
24405
|
+
* }, response => processResponse(response))
|
|
24406
|
+
* ```
|
|
24407
|
+
*
|
|
24408
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
24409
|
+
*
|
|
24410
|
+
* @param params.dataTypes array of data types for the posts
|
|
24411
|
+
* @param callback the function to call when new data are available
|
|
24412
|
+
* @param config
|
|
24413
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
24414
|
+
*
|
|
24415
|
+
* @category Posts Live Collection
|
|
24416
|
+
*/
|
|
24417
|
+
const getCustomRankingGlobalFeed = (params, callback, config) => {
|
|
24418
|
+
const { log, cache } = getActiveClient();
|
|
24419
|
+
if (!cache) {
|
|
24420
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
24421
|
+
}
|
|
24422
|
+
const timestamp = Date.now();
|
|
24423
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > listen`);
|
|
24424
|
+
const liveCollection = new CustomRankingGlobalFeedLiveCollectionController(params, callback);
|
|
24425
|
+
const disposers = liveCollection.startSubscription();
|
|
24426
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
24427
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
24428
|
+
return () => {
|
|
24429
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > dispose`);
|
|
24430
|
+
disposers.forEach(fn => fn());
|
|
24431
|
+
};
|
|
24432
|
+
};
|
|
24433
|
+
/* end_public_function */
|
|
24434
|
+
|
|
24435
|
+
class GlobalFeedPaginationController extends PaginationController {
|
|
24436
|
+
async getRequest(queryParams, token) {
|
|
24437
|
+
const { limit, resolveParent } = queryParams, params = __rest(queryParams, ["limit", "resolveParent"]);
|
|
24438
|
+
const options = token ? { token } : { limit };
|
|
24439
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/global-feeds`, {
|
|
24440
|
+
params: Object.assign(Object.assign({}, params), { resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
|
|
24441
|
+
});
|
|
24442
|
+
return queryResponse;
|
|
24443
|
+
}
|
|
24444
|
+
}
|
|
24445
|
+
|
|
24446
|
+
class GlobalFeedQueryStreamController extends QueryStreamController {
|
|
24447
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
24448
|
+
super(query, cacheKey);
|
|
24449
|
+
this.notifyChange = notifyChange;
|
|
24450
|
+
this.preparePayload = preparePayload;
|
|
24451
|
+
}
|
|
24452
|
+
async saveToMainDB(response) {
|
|
24453
|
+
const processedPayload = await this.preparePayload(response);
|
|
24454
|
+
const client = getActiveClient();
|
|
24455
|
+
const cachedAt = client.cache && Date.now();
|
|
24456
|
+
if (client.cache) {
|
|
24457
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
24458
|
+
}
|
|
24459
|
+
}
|
|
24460
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
24461
|
+
var _a, _b;
|
|
24462
|
+
if (refresh) {
|
|
24463
|
+
pushToCache(this.cacheKey, {
|
|
24464
|
+
data: response.posts.map(getResolver('post')),
|
|
24465
|
+
});
|
|
24466
|
+
}
|
|
24467
|
+
else {
|
|
24468
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24469
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24470
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
24471
|
+
}
|
|
24472
|
+
}
|
|
24473
|
+
reactor(action) {
|
|
24474
|
+
return (post) => {
|
|
24475
|
+
var _a;
|
|
24476
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24477
|
+
if (!collection)
|
|
24478
|
+
return;
|
|
24479
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
24480
|
+
return;
|
|
24481
|
+
// Delete Action
|
|
24482
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
24483
|
+
// Parent Post - Remove from collection
|
|
24484
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
24485
|
+
}
|
|
24486
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
24487
|
+
// If the query has dataTypes array with value, check if post.dataType is include in the array
|
|
24488
|
+
if (this.query.dataTypes && this.query.dataTypes.length > 0) {
|
|
24489
|
+
if (!this.query.dataTypes.includes(post.dataType))
|
|
24490
|
+
return;
|
|
24491
|
+
}
|
|
24492
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
24493
|
+
}
|
|
24494
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
24495
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
24496
|
+
}
|
|
24497
|
+
pushToCache(this.cacheKey, collection);
|
|
24498
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
24499
|
+
};
|
|
24500
|
+
}
|
|
24501
|
+
subscribeRTE(createSubscriber) {
|
|
24502
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
24503
|
+
}
|
|
24504
|
+
}
|
|
24505
|
+
|
|
24506
|
+
class GlobalFeedLiveCollectionController extends LiveCollectionController {
|
|
24507
|
+
constructor(query, callback) {
|
|
24508
|
+
const queryStreamId = hash__default["default"](query);
|
|
24509
|
+
const cacheKey = ['globalFeed', 'collection', queryStreamId];
|
|
24510
|
+
const paginationController = new GlobalFeedPaginationController(query);
|
|
24511
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24512
|
+
this.query = query;
|
|
24513
|
+
this.queryStreamController = new GlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
24514
|
+
this.callback = callback.bind(this);
|
|
24515
|
+
this.loadPage({ initial: true });
|
|
24516
|
+
}
|
|
24517
|
+
setup() {
|
|
24518
|
+
var _a;
|
|
24519
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24520
|
+
if (!collection) {
|
|
24521
|
+
pushToCache(this.cacheKey, {
|
|
24522
|
+
data: [],
|
|
24523
|
+
params: {},
|
|
24524
|
+
});
|
|
24525
|
+
}
|
|
24526
|
+
}
|
|
24527
|
+
async persistModel(queryPayload) {
|
|
24528
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24529
|
+
}
|
|
24530
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
24531
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24532
|
+
}
|
|
24533
|
+
startSubscription() {
|
|
24534
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
24535
|
+
}
|
|
24536
|
+
notifyChange({ origin, loading, error }) {
|
|
24537
|
+
var _a, _b;
|
|
24538
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24539
|
+
if (!collection)
|
|
24540
|
+
return;
|
|
24541
|
+
const data = ((_b = collection.data
|
|
24542
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
24543
|
+
.filter(isNonNullable)
|
|
24544
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
24545
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
24546
|
+
return;
|
|
24547
|
+
this.callback({
|
|
24548
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24549
|
+
data,
|
|
24550
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24551
|
+
loading,
|
|
24552
|
+
error,
|
|
24553
|
+
});
|
|
24554
|
+
}
|
|
24555
|
+
}
|
|
24556
|
+
|
|
24557
|
+
/* begin_public_function
|
|
24558
|
+
id: feed.query.global_feed
|
|
24559
|
+
*/
|
|
24560
|
+
/**
|
|
24561
|
+
* ```js
|
|
24562
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
24563
|
+
*
|
|
24564
|
+
* let posts = []
|
|
24565
|
+
* const unsub = FeedRepository.getGlobalFeed({
|
|
24566
|
+
* dataTypes: ['video','image'],
|
|
24567
|
+
* resolveParent: true,
|
|
24568
|
+
* }, response => processResponse(response))
|
|
24569
|
+
* ```
|
|
24570
|
+
*
|
|
24571
|
+
* Observe all mutations on a list of {@link Amity.Post} for global feed
|
|
24572
|
+
* @param params.dataTypes array of data types for the posts
|
|
24573
|
+
* @param params.resolveParent
|
|
24574
|
+
* @param callback the function to call when new data are available
|
|
24575
|
+
* @param config
|
|
24576
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
24577
|
+
*
|
|
24578
|
+
* @category Posts Live Collection
|
|
24579
|
+
*/
|
|
24580
|
+
const getGlobalFeed = (params, callback, config) => {
|
|
24581
|
+
const { log, cache } = getActiveClient();
|
|
24582
|
+
if (!cache) {
|
|
24583
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
24584
|
+
}
|
|
24585
|
+
const timestamp = Date.now();
|
|
24586
|
+
log(`getGlobalFeed(tmpid: ${timestamp}) > listen`);
|
|
24587
|
+
const liveCollection = new GlobalFeedLiveCollectionController(params, callback);
|
|
24588
|
+
const disposers = liveCollection.startSubscription();
|
|
24589
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
24590
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
24591
|
+
return () => {
|
|
24592
|
+
log(`getGlobalFeed(tmpid: ${timestamp}) > dispose`);
|
|
24593
|
+
disposers.forEach(fn => fn());
|
|
24594
|
+
};
|
|
24595
|
+
};
|
|
24596
|
+
/* end_public_function */
|
|
24597
|
+
|
|
24598
|
+
class UserFeedPaginationController extends PaginationController {
|
|
24599
|
+
async getRequest(queryParams, token) {
|
|
24600
|
+
const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["userId", "feedSources", "dataTypes", "includeDeleted", "matchingOnlyParentPost", "limit"]);
|
|
24601
|
+
const options = token ? { token } : { limit };
|
|
24602
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/user-feeds/${userId}`, {
|
|
24603
|
+
params: Object.assign(Object.assign({}, params), { options, dataTypes: (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) ? dataTypes : undefined, includePostedFeed: feedSources, isDeleted: inferIsDeleted(includeDeleted), matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) }),
|
|
24604
|
+
});
|
|
24605
|
+
return queryResponse;
|
|
24606
|
+
}
|
|
24607
|
+
}
|
|
24608
|
+
|
|
24609
|
+
class UserFeedQueryStreamController extends QueryStreamController {
|
|
24610
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
24611
|
+
super(query, cacheKey);
|
|
24612
|
+
this.notifyChange = notifyChange;
|
|
24613
|
+
this.preparePayload = preparePayload;
|
|
24614
|
+
}
|
|
24615
|
+
async saveToMainDB(response) {
|
|
24616
|
+
const processedPayload = await this.preparePayload(response);
|
|
24617
|
+
const client = getActiveClient();
|
|
24618
|
+
const cachedAt = client.cache && Date.now();
|
|
24619
|
+
if (client.cache) {
|
|
24620
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
24621
|
+
}
|
|
24622
|
+
}
|
|
24623
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
24624
|
+
var _a, _b;
|
|
24625
|
+
if (refresh) {
|
|
24626
|
+
pushToCache(this.cacheKey, {
|
|
24627
|
+
data: response.posts.map(getResolver('post')),
|
|
24628
|
+
});
|
|
24629
|
+
}
|
|
24630
|
+
else {
|
|
24631
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24632
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24633
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
24634
|
+
}
|
|
24635
|
+
}
|
|
24636
|
+
reactor(action) {
|
|
24637
|
+
return (post) => {
|
|
24638
|
+
var _a, _b;
|
|
24639
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24640
|
+
if (!collection)
|
|
24641
|
+
return;
|
|
24642
|
+
// if the collection is parent post collection and
|
|
24643
|
+
// post is not included in the collection or post is child post
|
|
24644
|
+
if ((!this.query.dataTypes || this.query.dataTypes.length === 0) &&
|
|
24645
|
+
!collection.data.includes(post.parentPostId ? post.parentPostId : post.postId))
|
|
24646
|
+
return;
|
|
24647
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
24648
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
24649
|
+
}
|
|
24650
|
+
if (post.parentPostId && post.isDeleted) {
|
|
24651
|
+
const parentPost = (_b = pullFromCache([
|
|
24652
|
+
'post',
|
|
24653
|
+
'get',
|
|
24654
|
+
post.parentPostId,
|
|
24655
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
24656
|
+
if (!parentPost)
|
|
24657
|
+
return;
|
|
24658
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
24659
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
24660
|
+
}
|
|
24661
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
24662
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
24663
|
+
}
|
|
24664
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
24665
|
+
if (this.query.dataTypes &&
|
|
24666
|
+
this.query.dataTypes.length > 0 &&
|
|
24667
|
+
!this.query.dataTypes.includes(post.dataType)) {
|
|
24668
|
+
return;
|
|
24669
|
+
}
|
|
24670
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
24671
|
+
}
|
|
24672
|
+
pushToCache(this.cacheKey, collection);
|
|
24673
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
24674
|
+
};
|
|
24675
|
+
}
|
|
24676
|
+
subscribeRTE(createSubscriber) {
|
|
24677
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
24678
|
+
}
|
|
24679
|
+
}
|
|
24680
|
+
|
|
24681
|
+
class UserFeedLiveCollectionController extends LiveCollectionController {
|
|
24682
|
+
constructor(query, callback) {
|
|
24683
|
+
const queryStreamId = hash__default["default"](query);
|
|
24684
|
+
const cacheKey = ['userFeed', 'collection', queryStreamId];
|
|
24685
|
+
const paginationController = new UserFeedPaginationController(query);
|
|
24686
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24687
|
+
this.query = query;
|
|
24688
|
+
this.queryStreamController = new UserFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
24689
|
+
this.callback = callback.bind(this);
|
|
24690
|
+
this.loadPage({ initial: true });
|
|
24691
|
+
}
|
|
24692
|
+
setup() {
|
|
24693
|
+
var _a;
|
|
24694
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24695
|
+
if (!collection) {
|
|
24696
|
+
pushToCache(this.cacheKey, {
|
|
24697
|
+
data: [],
|
|
24698
|
+
params: {},
|
|
24699
|
+
});
|
|
24700
|
+
}
|
|
24701
|
+
}
|
|
24702
|
+
async persistModel(queryPayload) {
|
|
24703
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24704
|
+
}
|
|
24705
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
24706
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24707
|
+
}
|
|
24708
|
+
startSubscription() {
|
|
24709
|
+
return this.queryStreamController.subscribeRTE([
|
|
24710
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
24711
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
24712
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
24713
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24714
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
24715
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
24716
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
24717
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
24718
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24719
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24720
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24721
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24722
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24723
|
+
{
|
|
24724
|
+
fn: convertEventPayload((callback) => {
|
|
24725
|
+
return onCommentCreated(async (comment) => {
|
|
24726
|
+
var _a;
|
|
24727
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24728
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24729
|
+
return;
|
|
24730
|
+
await getPost$1(comment.referenceId);
|
|
24731
|
+
callback(comment);
|
|
24732
|
+
});
|
|
24733
|
+
}, 'referenceId', 'post'),
|
|
24734
|
+
action: EnumPostActions.OnPostUpdated,
|
|
24735
|
+
},
|
|
24736
|
+
{
|
|
24737
|
+
fn: convertEventPayload((callback) => {
|
|
24738
|
+
return onCommentDeleted(async (comment) => {
|
|
24739
|
+
var _a;
|
|
24740
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24741
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24742
|
+
return;
|
|
24743
|
+
await getPost$1(comment.referenceId);
|
|
24744
|
+
callback(comment);
|
|
24745
|
+
});
|
|
24746
|
+
}, 'referenceId', 'post'),
|
|
24747
|
+
action: EnumPostActions.OnPostUpdated,
|
|
24748
|
+
},
|
|
24749
|
+
]);
|
|
24750
|
+
}
|
|
24751
|
+
notifyChange({ origin, loading, error }) {
|
|
24752
|
+
var _a, _b;
|
|
24753
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24754
|
+
if (!collection)
|
|
24755
|
+
return;
|
|
24756
|
+
const data = ((_b = collection.data
|
|
24757
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
24758
|
+
.filter(isNonNullable)
|
|
24759
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
24760
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
24761
|
+
return;
|
|
24762
|
+
this.callback({
|
|
24763
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24764
|
+
data,
|
|
24765
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24766
|
+
loading,
|
|
24767
|
+
error,
|
|
24768
|
+
});
|
|
24013
24769
|
}
|
|
24014
|
-
|
|
24015
|
-
};
|
|
24016
|
-
/* end_public_function */
|
|
24770
|
+
}
|
|
24017
24771
|
|
|
24018
24772
|
/* begin_public_function
|
|
24019
|
-
id:
|
|
24773
|
+
id: feed.query.user_feed
|
|
24020
24774
|
*/
|
|
24021
24775
|
/**
|
|
24022
24776
|
* ```js
|
|
24023
|
-
* import {
|
|
24024
|
-
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
24025
|
-
* ```
|
|
24026
|
-
*
|
|
24027
|
-
* Deletes a {@link Amity.Comment}
|
|
24028
|
-
*
|
|
24029
|
-
* @param commentId The {@link Amity.Comment} ID to delete
|
|
24030
|
-
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
24777
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
24031
24778
|
*
|
|
24032
|
-
*
|
|
24033
|
-
*
|
|
24034
|
-
|
|
24035
|
-
|
|
24036
|
-
|
|
24037
|
-
client.log('comment/softDeleteComment', commentId);
|
|
24038
|
-
const softDeleted = deleteComment(commentId);
|
|
24039
|
-
return softDeleted;
|
|
24040
|
-
};
|
|
24041
|
-
/* end_public_function */
|
|
24042
|
-
|
|
24043
|
-
/* begin_public_function
|
|
24044
|
-
id: comment.hard_delete
|
|
24045
|
-
*/
|
|
24046
|
-
/**
|
|
24047
|
-
* ```js
|
|
24048
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24049
|
-
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
24779
|
+
* let posts = []
|
|
24780
|
+
* const unsubscribe = FeedRepository.getUserFeed({
|
|
24781
|
+
* userId: string,
|
|
24782
|
+
* feedSources: ['user', 'community'],
|
|
24783
|
+
* }, response => response => processResponse(response))
|
|
24050
24784
|
* ```
|
|
24051
24785
|
*
|
|
24052
|
-
*
|
|
24786
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given user and feedSources
|
|
24053
24787
|
*
|
|
24054
|
-
* @param
|
|
24055
|
-
* @
|
|
24788
|
+
* @param params.userId the ID of the user
|
|
24789
|
+
* @param params.feedSources the sources of the feed
|
|
24790
|
+
* @param callback the function to call when new data are available
|
|
24791
|
+
* @param config
|
|
24792
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
24056
24793
|
*
|
|
24057
|
-
* @category
|
|
24058
|
-
* @async
|
|
24794
|
+
* @category Posts Live Collection
|
|
24059
24795
|
*/
|
|
24060
|
-
const
|
|
24061
|
-
const
|
|
24062
|
-
|
|
24063
|
-
|
|
24064
|
-
return hardDeleted;
|
|
24065
|
-
};
|
|
24066
|
-
/* end_public_function */
|
|
24067
|
-
|
|
24068
|
-
/* begin_public_function
|
|
24069
|
-
id: comment.flag
|
|
24070
|
-
*/
|
|
24071
|
-
/**
|
|
24072
|
-
* ```js
|
|
24073
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
24074
|
-
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
24075
|
-
* ```
|
|
24076
|
-
*
|
|
24077
|
-
* @param commentId The ID of the comment to flag
|
|
24078
|
-
* @param reason the reason to flag the comment
|
|
24079
|
-
* @returns the created report result
|
|
24080
|
-
*
|
|
24081
|
-
* @category Comment API
|
|
24082
|
-
* @async
|
|
24083
|
-
* */
|
|
24084
|
-
const flagComment = async (commentId, reason) => {
|
|
24085
|
-
const client = getActiveClient();
|
|
24086
|
-
client.log('comment/flagComment', commentId);
|
|
24087
|
-
const isPredefinedReason = reason &&
|
|
24088
|
-
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
24089
|
-
const body = {
|
|
24090
|
-
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
24091
|
-
detail: reason && !isPredefinedReason ? reason : '',
|
|
24092
|
-
};
|
|
24093
|
-
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
24094
|
-
if (client.cache) {
|
|
24095
|
-
ingestInCache(payload);
|
|
24796
|
+
const getUserFeed = (params, callback, config) => {
|
|
24797
|
+
const { log, cache } = getActiveClient();
|
|
24798
|
+
if (!cache) {
|
|
24799
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
24096
24800
|
}
|
|
24097
|
-
|
|
24098
|
-
|
|
24801
|
+
const timestamp = Date.now();
|
|
24802
|
+
log(`getUserFeed(tmpid: ${timestamp}) > listen`);
|
|
24803
|
+
const userFeedLiveCollection = new UserFeedLiveCollectionController(params, callback);
|
|
24804
|
+
const disposers = userFeedLiveCollection.startSubscription();
|
|
24805
|
+
const cacheKey = userFeedLiveCollection.getCacheKey();
|
|
24806
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
24807
|
+
return () => {
|
|
24808
|
+
log(`getUserFeed(tmpid: ${timestamp}) > dispose`);
|
|
24809
|
+
disposers.forEach(fn => fn());
|
|
24810
|
+
};
|
|
24099
24811
|
};
|
|
24100
24812
|
/* end_public_function */
|
|
24101
24813
|
|
|
24102
|
-
|
|
24103
|
-
|
|
24104
|
-
|
|
24105
|
-
|
|
24106
|
-
|
|
24107
|
-
|
|
24108
|
-
|
|
24109
|
-
* ```
|
|
24110
|
-
*
|
|
24111
|
-
* @param commentId The ID of comment to unflag
|
|
24112
|
-
* @returns the unflagged result
|
|
24113
|
-
*
|
|
24114
|
-
* @category Comment API
|
|
24115
|
-
* @async
|
|
24116
|
-
* */
|
|
24117
|
-
const unflagComment = async (commentId) => {
|
|
24118
|
-
const client = getActiveClient();
|
|
24119
|
-
client.log('comment/unflagComment', commentId);
|
|
24120
|
-
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
24121
|
-
if (client.cache) {
|
|
24122
|
-
ingestInCache(payload);
|
|
24123
|
-
}
|
|
24124
|
-
fireEvent('comment.unflagged', payload);
|
|
24125
|
-
return !!payload;
|
|
24126
|
-
};
|
|
24127
|
-
/* end_public_function */
|
|
24814
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
24815
|
+
__proto__: null,
|
|
24816
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
24817
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
24818
|
+
getGlobalFeed: getGlobalFeed,
|
|
24819
|
+
getUserFeed: getUserFeed
|
|
24820
|
+
});
|
|
24128
24821
|
|
|
24129
24822
|
/* begin_public_function
|
|
24130
|
-
id:
|
|
24823
|
+
id: post.get_by_ids
|
|
24131
24824
|
*/
|
|
24132
24825
|
/**
|
|
24133
24826
|
* ```js
|
|
24134
|
-
* import {
|
|
24135
|
-
* const
|
|
24827
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
24828
|
+
* const { data: posts } = await getPostByIds(['foo', 'bar'])
|
|
24136
24829
|
* ```
|
|
24137
24830
|
*
|
|
24138
|
-
*
|
|
24139
|
-
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
24831
|
+
* Fetches a collection of {@link Amity.Post} objects
|
|
24140
24832
|
*
|
|
24141
|
-
* @
|
|
24833
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
24834
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
24835
|
+
*
|
|
24836
|
+
* @category Post API
|
|
24142
24837
|
* @async
|
|
24143
|
-
|
|
24144
|
-
const
|
|
24145
|
-
const client = getActiveClient();
|
|
24146
|
-
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
24147
|
-
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
24148
|
-
return result;
|
|
24149
|
-
};
|
|
24150
|
-
/* end_public_function */
|
|
24151
|
-
|
|
24152
|
-
const getComment$1 = async (commentId) => {
|
|
24838
|
+
*/
|
|
24839
|
+
const getPostByIds = async (postIds) => {
|
|
24153
24840
|
const client = getActiveClient();
|
|
24154
|
-
client.log('
|
|
24155
|
-
|
|
24156
|
-
let
|
|
24841
|
+
client.log('post/getPostByIds', postIds);
|
|
24842
|
+
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
24843
|
+
let payload;
|
|
24157
24844
|
try {
|
|
24158
24845
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
24159
|
-
const response = await client.http.get(`/api/v3/
|
|
24160
|
-
|
|
24846
|
+
const response = await client.http.get(`/api/v3/posts/list`, {
|
|
24847
|
+
params: { postIds: encodedPostIds },
|
|
24848
|
+
});
|
|
24849
|
+
payload = response.data;
|
|
24161
24850
|
}
|
|
24162
24851
|
catch (error) {
|
|
24163
|
-
|
|
24164
|
-
|
|
24165
|
-
|
|
24852
|
+
postIds.forEach(postId => {
|
|
24853
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24854
|
+
pushToTombstone('post', postId);
|
|
24855
|
+
}
|
|
24856
|
+
});
|
|
24166
24857
|
throw error;
|
|
24167
24858
|
}
|
|
24859
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24168
24860
|
const cachedAt = client.cache && Date.now();
|
|
24169
24861
|
if (client.cache)
|
|
24170
24862
|
ingestInCache(data, { cachedAt });
|
|
24171
|
-
const { comments } = data;
|
|
24172
24863
|
return {
|
|
24173
|
-
data:
|
|
24864
|
+
data: data.posts.map(LinkedObject.post),
|
|
24174
24865
|
cachedAt,
|
|
24175
24866
|
};
|
|
24176
24867
|
};
|
|
24177
|
-
|
|
24868
|
+
/* end_public_function */
|
|
24869
|
+
/**
|
|
24870
|
+
* ```js
|
|
24871
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
24872
|
+
* const { data: posts } = getPostByIds.locally(['foo', 'bar'])
|
|
24873
|
+
* ```
|
|
24874
|
+
*
|
|
24875
|
+
* Fetches a collection of {@link Amity.Post} objects from cache
|
|
24876
|
+
*
|
|
24877
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
24878
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
24879
|
+
*
|
|
24880
|
+
* @category Post API
|
|
24881
|
+
*/
|
|
24882
|
+
getPostByIds.locally = (postIds) => {
|
|
24883
|
+
var _a;
|
|
24178
24884
|
const client = getActiveClient();
|
|
24179
|
-
client.log('
|
|
24885
|
+
client.log('post/getPostByIds.locally', postIds);
|
|
24180
24886
|
if (!client.cache)
|
|
24181
24887
|
return;
|
|
24182
|
-
const cached =
|
|
24183
|
-
|
|
24888
|
+
const cached = postIds
|
|
24889
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
24890
|
+
.filter(Boolean);
|
|
24891
|
+
const posts = cached.map(({ data }) => data);
|
|
24892
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
24893
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
24184
24894
|
return;
|
|
24185
24895
|
return {
|
|
24186
|
-
data:
|
|
24187
|
-
cachedAt:
|
|
24896
|
+
data: posts.map(LinkedObject.post),
|
|
24897
|
+
cachedAt: oldest.cachedAt,
|
|
24188
24898
|
};
|
|
24189
24899
|
};
|
|
24190
24900
|
|
|
24901
|
+
/* begin_public_function
|
|
24902
|
+
id: post.create.text_post, post.create.image_post, post.create.file_post, post.create.video_post, post.create.poll_post, post.create.livestream_post, post.create.custom_post
|
|
24903
|
+
*/
|
|
24191
24904
|
/**
|
|
24192
24905
|
* ```js
|
|
24193
|
-
* import {
|
|
24194
|
-
* const
|
|
24195
|
-
*
|
|
24196
|
-
*
|
|
24906
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24907
|
+
* const created = await PostRepository.createPost({
|
|
24908
|
+
* targetType: 'user',
|
|
24909
|
+
* targetId: 'foobar',
|
|
24910
|
+
* data: { text: 'hello world' }
|
|
24911
|
+
* }))
|
|
24197
24912
|
* ```
|
|
24198
24913
|
*
|
|
24199
|
-
*
|
|
24914
|
+
* Creates an {@link Amity.Post}
|
|
24200
24915
|
*
|
|
24201
|
-
* @param
|
|
24202
|
-
* @returns
|
|
24916
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
24917
|
+
* @returns The newly created {@link Amity.Post}
|
|
24203
24918
|
*
|
|
24204
|
-
* @category
|
|
24919
|
+
* @category Post API
|
|
24920
|
+
* @async
|
|
24205
24921
|
*/
|
|
24206
|
-
const
|
|
24922
|
+
const createPost = async (bundle) => {
|
|
24923
|
+
const client = getActiveClient();
|
|
24924
|
+
client.log('post/createPost', bundle);
|
|
24925
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
24926
|
+
// eslint-disable-next-line no-param-reassign
|
|
24927
|
+
delete bundle.dataType;
|
|
24928
|
+
}
|
|
24929
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
24930
|
+
fireEvent('post.created', payload);
|
|
24931
|
+
const data = preparePostPayload(payload);
|
|
24932
|
+
const cachedAt = client.cache && Date.now();
|
|
24933
|
+
if (client.cache)
|
|
24934
|
+
ingestInCache(data, { cachedAt });
|
|
24935
|
+
const { posts } = data;
|
|
24936
|
+
return {
|
|
24937
|
+
data: LinkedObject.post(posts[0]),
|
|
24938
|
+
cachedAt,
|
|
24939
|
+
};
|
|
24940
|
+
};
|
|
24941
|
+
/* end_public_function */
|
|
24207
24942
|
|
|
24943
|
+
/* begin_public_function
|
|
24944
|
+
id: post.edit, post.edit.custom_post
|
|
24945
|
+
*/
|
|
24208
24946
|
/**
|
|
24209
24947
|
* ```js
|
|
24210
|
-
* import {
|
|
24211
|
-
* const
|
|
24212
|
-
*
|
|
24948
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
24949
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
24950
|
+
* data: { text: 'hello world' }
|
|
24213
24951
|
* })
|
|
24214
24952
|
* ```
|
|
24215
24953
|
*
|
|
24216
|
-
*
|
|
24954
|
+
* Updates an {@link Amity.Post}
|
|
24217
24955
|
*
|
|
24218
|
-
* @param
|
|
24219
|
-
* @
|
|
24956
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
24957
|
+
* @param patch The patch data to apply
|
|
24958
|
+
* @returns the updated {@link Amity.Post} object
|
|
24220
24959
|
*
|
|
24221
|
-
* @category
|
|
24960
|
+
* @category Post API
|
|
24961
|
+
* @async
|
|
24222
24962
|
*/
|
|
24223
|
-
const
|
|
24963
|
+
const editPost = async (postId, patch) => {
|
|
24224
24964
|
const client = getActiveClient();
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
|
|
24228
|
-
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
|
|
24232
|
-
|
|
24965
|
+
client.log('user/editPost', patch);
|
|
24966
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
24967
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24968
|
+
const cachedAt = client.cache && Date.now();
|
|
24969
|
+
if (client.cache)
|
|
24970
|
+
ingestInCache(data, { cachedAt });
|
|
24971
|
+
fireEvent('local.post.updated', data);
|
|
24972
|
+
const { posts } = data;
|
|
24973
|
+
return {
|
|
24974
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
24975
|
+
cachedAt,
|
|
24233
24976
|
};
|
|
24234
|
-
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
24235
24977
|
};
|
|
24978
|
+
/* end_public_function */
|
|
24236
24979
|
|
|
24237
24980
|
/**
|
|
24238
24981
|
* ```js
|
|
24239
|
-
* import {
|
|
24240
|
-
* const
|
|
24241
|
-
* // ...
|
|
24242
|
-
* })
|
|
24982
|
+
* import { deletePost } from '@amityco/ts-sdk'
|
|
24983
|
+
* const success = await deletePost('foobar')
|
|
24243
24984
|
* ```
|
|
24244
24985
|
*
|
|
24245
|
-
*
|
|
24986
|
+
* Deletes a {@link Amity.Post}
|
|
24246
24987
|
*
|
|
24247
|
-
* @param
|
|
24248
|
-
* @
|
|
24988
|
+
* @param postId The {@link Amity.Post} ID to delete
|
|
24989
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
24249
24990
|
*
|
|
24250
|
-
* @
|
|
24991
|
+
* @private
|
|
24992
|
+
* @async
|
|
24251
24993
|
*/
|
|
24252
|
-
const
|
|
24994
|
+
const deletePost = async (postId, permanent = false) => {
|
|
24995
|
+
var _a;
|
|
24253
24996
|
const client = getActiveClient();
|
|
24254
|
-
const
|
|
24255
|
-
|
|
24256
|
-
|
|
24257
|
-
|
|
24258
|
-
|
|
24259
|
-
|
|
24260
|
-
|
|
24261
|
-
|
|
24262
|
-
|
|
24263
|
-
|
|
24997
|
+
const post = await getPost$2(postId);
|
|
24998
|
+
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
24999
|
+
params: {
|
|
25000
|
+
postId,
|
|
25001
|
+
permanent,
|
|
25002
|
+
},
|
|
25003
|
+
});
|
|
25004
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
25005
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
25006
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
25007
|
+
// later when realtime events covers that for us.
|
|
25008
|
+
if (post.data.targetType === 'community') {
|
|
25009
|
+
const community = await getCommunity$1(post.data.targetId);
|
|
25010
|
+
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
25011
|
+
const communityUsers = communityUsersCache
|
|
25012
|
+
.filter(({ key }) => {
|
|
25013
|
+
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
25014
|
+
if (key[0] !== 'communityUsers')
|
|
25015
|
+
return false;
|
|
25016
|
+
if (key[1] !== 'get')
|
|
25017
|
+
return false;
|
|
25018
|
+
if (typeof key[2] === 'string')
|
|
25019
|
+
return key[2].includes(community.data.communityId);
|
|
25020
|
+
return false;
|
|
25021
|
+
})
|
|
25022
|
+
.map(({ data }) => data);
|
|
25023
|
+
fireEvent('community.updated', {
|
|
25024
|
+
communities: [community.data],
|
|
25025
|
+
categories: [],
|
|
25026
|
+
communityUsers,
|
|
25027
|
+
feeds: [],
|
|
25028
|
+
files: [],
|
|
25029
|
+
users: [],
|
|
25030
|
+
});
|
|
25031
|
+
}
|
|
25032
|
+
// to support hard deletion
|
|
25033
|
+
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
25034
|
+
if (permanent) {
|
|
25035
|
+
setTimeout(() => {
|
|
25036
|
+
pushToTombstone('post', postId);
|
|
25037
|
+
}, 0);
|
|
25038
|
+
}
|
|
25039
|
+
else {
|
|
25040
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
25041
|
+
}
|
|
25042
|
+
fireEvent('local.post.deleted', {
|
|
25043
|
+
posts: [deleted],
|
|
25044
|
+
categories: [],
|
|
25045
|
+
comments: [],
|
|
25046
|
+
communities: [],
|
|
25047
|
+
communityUsers: [],
|
|
25048
|
+
feeds: [],
|
|
25049
|
+
files: [],
|
|
25050
|
+
postChildren: [],
|
|
25051
|
+
users: [],
|
|
25052
|
+
videoStreamings: [],
|
|
25053
|
+
});
|
|
25054
|
+
return LinkedObject.post(deleted);
|
|
24264
25055
|
};
|
|
24265
25056
|
|
|
24266
25057
|
/* begin_public_function
|
|
24267
|
-
id:
|
|
25058
|
+
id: post.soft_delete
|
|
24268
25059
|
*/
|
|
24269
25060
|
/**
|
|
24270
25061
|
* ```js
|
|
24271
|
-
* import {
|
|
24272
|
-
*
|
|
24273
|
-
* let comment;
|
|
24274
|
-
*
|
|
24275
|
-
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
24276
|
-
* comment = response.data;
|
|
24277
|
-
* });
|
|
25062
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
25063
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
24278
25064
|
* ```
|
|
24279
25065
|
*
|
|
24280
|
-
*
|
|
25066
|
+
* Soft deletes a {@link Amity.Post}
|
|
24281
25067
|
*
|
|
24282
|
-
* @param
|
|
24283
|
-
* @
|
|
24284
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
25068
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
25069
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
24285
25070
|
*
|
|
24286
|
-
* @category
|
|
25071
|
+
* @category Post API
|
|
25072
|
+
* @async
|
|
24287
25073
|
*/
|
|
24288
|
-
const
|
|
24289
|
-
|
|
24290
|
-
|
|
24291
|
-
|
|
24292
|
-
|
|
24293
|
-
onCommentReactionAdded,
|
|
24294
|
-
onCommentReactionRemoved,
|
|
24295
|
-
onCommentUnflagged,
|
|
24296
|
-
onCommentUpdated,
|
|
24297
|
-
onLocalCommentReactionAdded,
|
|
24298
|
-
onLocalCommentReactionRemoved,
|
|
24299
|
-
]);
|
|
25074
|
+
const softDeletePost = async (postId) => {
|
|
25075
|
+
const client = getActiveClient();
|
|
25076
|
+
client.log('post/softDeletePost', postId);
|
|
25077
|
+
const softDeleted = await deletePost(postId, false);
|
|
25078
|
+
return LinkedObject.post(softDeleted);
|
|
24300
25079
|
};
|
|
24301
25080
|
/* end_public_function */
|
|
24302
25081
|
|
|
24303
|
-
|
|
24304
|
-
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
|
|
24309
|
-
|
|
24310
|
-
|
|
24311
|
-
|
|
24312
|
-
|
|
24313
|
-
|
|
24314
|
-
|
|
24315
|
-
}
|
|
24316
|
-
|
|
24317
|
-
|
|
24318
|
-
|
|
24319
|
-
|
|
24320
|
-
|
|
24321
|
-
|
|
24322
|
-
|
|
24323
|
-
|
|
24324
|
-
|
|
24325
|
-
|
|
24326
|
-
|
|
24327
|
-
|
|
24328
|
-
class CommentQueryStreamController extends QueryStreamController {
|
|
24329
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
24330
|
-
super(query, cacheKey);
|
|
24331
|
-
this.notifyChange = notifyChange;
|
|
24332
|
-
this.preparePayload = preparePayload;
|
|
24333
|
-
}
|
|
24334
|
-
async saveToMainDB(response) {
|
|
24335
|
-
const processedPayload = await this.preparePayload(response);
|
|
24336
|
-
const client = getActiveClient();
|
|
24337
|
-
const cachedAt = client.cache && Date.now();
|
|
24338
|
-
if (client.cache) {
|
|
24339
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
24340
|
-
}
|
|
24341
|
-
}
|
|
24342
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
24343
|
-
var _a, _b;
|
|
24344
|
-
if (refresh) {
|
|
24345
|
-
pushToCache(this.cacheKey, {
|
|
24346
|
-
data: response.comments.map(getResolver('comment')),
|
|
24347
|
-
});
|
|
24348
|
-
}
|
|
24349
|
-
else {
|
|
24350
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24351
|
-
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24352
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
|
|
24353
|
-
}
|
|
24354
|
-
}
|
|
24355
|
-
reactor(action) {
|
|
24356
|
-
return (comment) => {
|
|
24357
|
-
var _a;
|
|
24358
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24359
|
-
if (this.query.referenceId !== comment.referenceId ||
|
|
24360
|
-
this.query.referenceType !== comment.referenceType ||
|
|
24361
|
-
!collection) {
|
|
24362
|
-
return;
|
|
24363
|
-
}
|
|
24364
|
-
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
24365
|
-
return;
|
|
24366
|
-
}
|
|
24367
|
-
if (!this.query.parentId && comment.parentId) {
|
|
24368
|
-
return;
|
|
24369
|
-
}
|
|
24370
|
-
if (action === EnumCommentActions.OnCommentCreated) {
|
|
24371
|
-
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
24372
|
-
}
|
|
24373
|
-
pushToCache(this.cacheKey, collection);
|
|
24374
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
24375
|
-
};
|
|
24376
|
-
}
|
|
24377
|
-
subscribeRTE(createSubscriber) {
|
|
24378
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
24379
|
-
}
|
|
24380
|
-
}
|
|
25082
|
+
/* begin_public_function
|
|
25083
|
+
id: post.hard_delete
|
|
25084
|
+
*/
|
|
25085
|
+
/**
|
|
25086
|
+
* ```js
|
|
25087
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
25088
|
+
* const success = await hardDeletePost('foobar')
|
|
25089
|
+
* ```
|
|
25090
|
+
*
|
|
25091
|
+
* Hard deletes a {@link Amity.Post}
|
|
25092
|
+
*
|
|
25093
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
25094
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
25095
|
+
*
|
|
25096
|
+
* @category Post API
|
|
25097
|
+
* @async
|
|
25098
|
+
*/
|
|
25099
|
+
const hardDeletePost = async (postId) => {
|
|
25100
|
+
const client = getActiveClient();
|
|
25101
|
+
client.log('post/hardDeletePost', postId);
|
|
25102
|
+
const hardDeleted = await deletePost(postId, true);
|
|
25103
|
+
return LinkedObject.post(hardDeleted);
|
|
25104
|
+
};
|
|
25105
|
+
/* end_public_function */
|
|
24381
25106
|
|
|
25107
|
+
/* begin_public_function
|
|
25108
|
+
id: post.approve
|
|
25109
|
+
*/
|
|
24382
25110
|
/**
|
|
24383
25111
|
* ```js
|
|
24384
|
-
* import {
|
|
24385
|
-
*
|
|
24386
|
-
*
|
|
24387
|
-
* })
|
|
25112
|
+
* import { approvePost } from '@amityco/ts-sdk'
|
|
25113
|
+
*
|
|
25114
|
+
* const { data: post } = await approvePost('postId')
|
|
24388
25115
|
* ```
|
|
24389
25116
|
*
|
|
24390
|
-
*
|
|
25117
|
+
* Approves a {@link Amity.Post}
|
|
24391
25118
|
*
|
|
24392
|
-
* @param
|
|
24393
|
-
* @
|
|
25119
|
+
* @param postId The {@link Amity.Post} ID to be approved
|
|
25120
|
+
* @return A {@link Amity.Post} that was approved
|
|
24394
25121
|
*
|
|
24395
|
-
* @category
|
|
25122
|
+
* @category Post API
|
|
25123
|
+
* @async
|
|
24396
25124
|
*/
|
|
24397
|
-
const
|
|
24398
|
-
|
|
24399
|
-
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24403
|
-
|
|
24404
|
-
|
|
24405
|
-
const paginationController = new CommentPaginationController(query);
|
|
24406
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24407
|
-
this.query = query;
|
|
24408
|
-
this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
|
|
24409
|
-
this.callback = callback.bind(this);
|
|
24410
|
-
this.loadPage({ initial: true });
|
|
24411
|
-
}
|
|
24412
|
-
setup() {
|
|
24413
|
-
var _a;
|
|
24414
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24415
|
-
if (!collection) {
|
|
24416
|
-
pushToCache(this.cacheKey, {
|
|
24417
|
-
data: [],
|
|
24418
|
-
params: {},
|
|
24419
|
-
});
|
|
24420
|
-
}
|
|
24421
|
-
}
|
|
24422
|
-
async persistModel(queryPayload) {
|
|
24423
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24424
|
-
}
|
|
24425
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
24426
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24427
|
-
}
|
|
24428
|
-
startSubscription() {
|
|
24429
|
-
return this.queryStreamController.subscribeRTE([
|
|
24430
|
-
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
24431
|
-
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
24432
|
-
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
24433
|
-
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
24434
|
-
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
24435
|
-
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
24436
|
-
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
24437
|
-
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24438
|
-
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
24439
|
-
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
24440
|
-
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
24441
|
-
]);
|
|
24442
|
-
}
|
|
24443
|
-
notifyChange({ origin, loading, error }) {
|
|
24444
|
-
var _a, _b;
|
|
24445
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24446
|
-
if (!collection)
|
|
24447
|
-
return;
|
|
24448
|
-
const data = this.applyFilter((_b = collection.data
|
|
24449
|
-
.map(id => pullFromCache(['comment', 'get', id]))
|
|
24450
|
-
.filter(isNonNullable)
|
|
24451
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
24452
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
24453
|
-
return;
|
|
24454
|
-
this.callback({
|
|
24455
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
24456
|
-
data,
|
|
24457
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
24458
|
-
loading,
|
|
24459
|
-
error,
|
|
24460
|
-
});
|
|
24461
|
-
}
|
|
24462
|
-
applyFilter(data) {
|
|
24463
|
-
let comments = data;
|
|
24464
|
-
if (!this.query.includeDeleted) {
|
|
24465
|
-
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
24466
|
-
}
|
|
24467
|
-
if (this.query.parentId) {
|
|
24468
|
-
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
24469
|
-
}
|
|
24470
|
-
if (typeof this.query.hasFlag === 'boolean') {
|
|
24471
|
-
if (this.query.hasFlag) {
|
|
24472
|
-
comments = comments.filter(comment => comment.hashFlag != null);
|
|
24473
|
-
}
|
|
24474
|
-
else {
|
|
24475
|
-
comments = comments.filter(comment => comment.hashFlag == null);
|
|
24476
|
-
}
|
|
24477
|
-
}
|
|
24478
|
-
if (this.query.dataTypes) {
|
|
24479
|
-
if (this.query.dataTypes.matchType === 'exact') {
|
|
24480
|
-
comments = comments.filter(comment => {
|
|
24481
|
-
var _a, _b;
|
|
24482
|
-
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
24483
|
-
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
24484
|
-
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
24485
|
-
return false;
|
|
24486
|
-
}
|
|
24487
|
-
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
24488
|
-
});
|
|
24489
|
-
}
|
|
24490
|
-
if (this.query.dataTypes.matchType === 'any') {
|
|
24491
|
-
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
24492
|
-
}
|
|
24493
|
-
}
|
|
24494
|
-
switch (this.query.sortBy) {
|
|
24495
|
-
case 'firstCreated':
|
|
24496
|
-
comments = comments.sort(sortByFirstCreated);
|
|
24497
|
-
break;
|
|
24498
|
-
case 'lastCreated':
|
|
24499
|
-
default:
|
|
24500
|
-
comments = comments.sort(sortByLastCreated);
|
|
24501
|
-
break;
|
|
24502
|
-
}
|
|
24503
|
-
return comments;
|
|
25125
|
+
const approvePost = async (postId) => {
|
|
25126
|
+
const client = getActiveClient();
|
|
25127
|
+
client.log('post/approvePost', postId);
|
|
25128
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
25129
|
+
fireEvent('post.approved', payload);
|
|
25130
|
+
// fire virtual event for community update
|
|
25131
|
+
if (payload.posts[0].targetType === 'community') {
|
|
25132
|
+
fireEvent('community.updated', payload);
|
|
24504
25133
|
}
|
|
24505
|
-
|
|
25134
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
25135
|
+
const cachedAt = client.cache && Date.now();
|
|
25136
|
+
if (client.cache)
|
|
25137
|
+
ingestInCache(data, { cachedAt });
|
|
25138
|
+
return {
|
|
25139
|
+
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
25140
|
+
cachedAt,
|
|
25141
|
+
};
|
|
25142
|
+
};
|
|
25143
|
+
/* end_public_function */
|
|
24506
25144
|
|
|
24507
25145
|
/* begin_public_function
|
|
24508
|
-
id:
|
|
25146
|
+
id: post.decline
|
|
24509
25147
|
*/
|
|
24510
25148
|
/**
|
|
24511
25149
|
* ```js
|
|
24512
|
-
* import {
|
|
25150
|
+
* import { declinePost } from '@amityco/ts-sdk'
|
|
24513
25151
|
*
|
|
24514
|
-
*
|
|
24515
|
-
* const unsub = getComments({
|
|
24516
|
-
* referenceType: Amity.InternalComment['referenceType'];
|
|
24517
|
-
* referenceId: Amity.InternalComment['referenceId'];
|
|
24518
|
-
* }, response => merge(comments, response.data))
|
|
25152
|
+
* const {data: post} = await declinePost('postId')
|
|
24519
25153
|
* ```
|
|
24520
25154
|
*
|
|
24521
|
-
*
|
|
25155
|
+
* Declines a {@link Amity.Post}
|
|
24522
25156
|
*
|
|
24523
|
-
* @param
|
|
24524
|
-
* @
|
|
24525
|
-
* @param callback the function to call when new data are available
|
|
24526
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
25157
|
+
* @param postId The {@link Amity.Post} ID to be declined
|
|
25158
|
+
* @return A {@link Amity.Post} that was declined
|
|
24527
25159
|
*
|
|
24528
|
-
* @category
|
|
25160
|
+
* @category Post API
|
|
25161
|
+
* @async
|
|
24529
25162
|
*/
|
|
24530
|
-
const
|
|
24531
|
-
const
|
|
24532
|
-
|
|
24533
|
-
|
|
25163
|
+
const declinePost = async (postId) => {
|
|
25164
|
+
const client = getActiveClient();
|
|
25165
|
+
client.log('post/declinePost', postId);
|
|
25166
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
25167
|
+
// fire virtual event
|
|
25168
|
+
if (payload.posts[0].targetType === 'community') {
|
|
25169
|
+
fireEvent('community.updated', payload);
|
|
24534
25170
|
}
|
|
24535
|
-
|
|
24536
|
-
|
|
24537
|
-
const
|
|
24538
|
-
|
|
24539
|
-
|
|
24540
|
-
|
|
24541
|
-
|
|
24542
|
-
|
|
24543
|
-
disposers.forEach(fn => fn());
|
|
25171
|
+
fireEvent('post.declined', payload);
|
|
25172
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
25173
|
+
const cachedAt = client.cache && Date.now();
|
|
25174
|
+
if (client.cache)
|
|
25175
|
+
ingestInCache(data, { cachedAt });
|
|
25176
|
+
return {
|
|
25177
|
+
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
25178
|
+
cachedAt,
|
|
24544
25179
|
};
|
|
24545
25180
|
};
|
|
24546
25181
|
/* end_public_function */
|
|
24547
25182
|
|
|
24548
|
-
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
createComment: createComment,
|
|
24552
|
-
updateComment: updateComment,
|
|
24553
|
-
deleteComment: deleteComment,
|
|
24554
|
-
softDeleteComment: softDeleteComment,
|
|
24555
|
-
hardDeleteComment: hardDeleteComment,
|
|
24556
|
-
flagComment: flagComment,
|
|
24557
|
-
unflagComment: unflagComment,
|
|
24558
|
-
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
24559
|
-
onCommentCreated: onCommentCreated,
|
|
24560
|
-
onCommentUpdated: onCommentUpdated,
|
|
24561
|
-
onCommentDeleted: onCommentDeleted,
|
|
24562
|
-
onCommentFlagged: onCommentFlagged,
|
|
24563
|
-
onCommentUnflagged: onCommentUnflagged,
|
|
24564
|
-
onCommentReactionAdded: onCommentReactionAdded,
|
|
24565
|
-
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
24566
|
-
getComment: getComment,
|
|
24567
|
-
getComments: getComments
|
|
24568
|
-
});
|
|
24569
|
-
|
|
25183
|
+
/* begin_public_function
|
|
25184
|
+
id: post.flag
|
|
25185
|
+
*/
|
|
24570
25186
|
/**
|
|
24571
25187
|
* ```js
|
|
24572
|
-
* import {
|
|
24573
|
-
* const
|
|
24574
|
-
* // ...
|
|
24575
|
-
* })
|
|
25188
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
25189
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
24576
25190
|
* ```
|
|
24577
25191
|
*
|
|
24578
|
-
*
|
|
24579
|
-
*
|
|
24580
|
-
* @
|
|
24581
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
25192
|
+
* @param postId of the post to flag
|
|
25193
|
+
* @param reason the reason to flag the post
|
|
25194
|
+
* @returns a boolean
|
|
24582
25195
|
*
|
|
24583
|
-
* @category Post
|
|
24584
|
-
|
|
24585
|
-
|
|
25196
|
+
* @category Post API
|
|
25197
|
+
* @async
|
|
25198
|
+
* */
|
|
25199
|
+
const flagPost = async (postId, reason) => {
|
|
25200
|
+
const client = getActiveClient();
|
|
25201
|
+
client.log('post/flagPost', postId);
|
|
25202
|
+
const isPredefinedReason = reason &&
|
|
25203
|
+
Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
25204
|
+
const body = {
|
|
25205
|
+
reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
25206
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
25207
|
+
};
|
|
25208
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
25209
|
+
if (client.cache) {
|
|
25210
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
25211
|
+
}
|
|
25212
|
+
fireEvent('post.flagged', payload);
|
|
25213
|
+
return !!payload;
|
|
25214
|
+
};
|
|
25215
|
+
/* end_public_function */
|
|
24586
25216
|
|
|
25217
|
+
/* begin_public_function
|
|
25218
|
+
id: post.unflag
|
|
25219
|
+
*/
|
|
24587
25220
|
/**
|
|
24588
25221
|
* ```js
|
|
24589
|
-
* import {
|
|
24590
|
-
* const
|
|
24591
|
-
* // ...
|
|
24592
|
-
* })
|
|
25222
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
25223
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
24593
25224
|
* ```
|
|
24594
25225
|
*
|
|
24595
|
-
*
|
|
24596
|
-
*
|
|
24597
|
-
* @param callback The function to call when the event was fired
|
|
24598
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
25226
|
+
* @param postId of the post to unflag
|
|
25227
|
+
* @returns the unflag post result
|
|
24599
25228
|
*
|
|
24600
|
-
* @category Post
|
|
24601
|
-
|
|
24602
|
-
|
|
25229
|
+
* @category Post API
|
|
25230
|
+
* @async
|
|
25231
|
+
* */
|
|
25232
|
+
const unflagPost = async (postId) => {
|
|
24603
25233
|
const client = getActiveClient();
|
|
24604
|
-
|
|
24605
|
-
|
|
24606
|
-
|
|
24607
|
-
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
}
|
|
24612
|
-
};
|
|
24613
|
-
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
25234
|
+
client.log('post/unflagPost', postId);
|
|
25235
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
25236
|
+
if (client.cache) {
|
|
25237
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
25238
|
+
}
|
|
25239
|
+
fireEvent('post.unflagged', payload);
|
|
25240
|
+
return !!payload;
|
|
24614
25241
|
};
|
|
25242
|
+
/* end_public_function */
|
|
24615
25243
|
|
|
25244
|
+
/* begin_public_function
|
|
25245
|
+
id: post.check_flag_by_me
|
|
25246
|
+
*/
|
|
24616
25247
|
/**
|
|
24617
25248
|
* ```js
|
|
24618
|
-
* import {
|
|
24619
|
-
* const
|
|
24620
|
-
* // ...
|
|
24621
|
-
* })
|
|
25249
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
25250
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
24622
25251
|
* ```
|
|
24623
25252
|
*
|
|
24624
|
-
*
|
|
24625
|
-
*
|
|
24626
|
-
* @param callback The function to call when the event was fired
|
|
24627
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
25253
|
+
* @param postId of the post to check if flagged by current user
|
|
25254
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
24628
25255
|
*
|
|
24629
|
-
* @category Post
|
|
24630
|
-
|
|
24631
|
-
|
|
25256
|
+
* @category Post API
|
|
25257
|
+
* @async
|
|
25258
|
+
* */
|
|
25259
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
24632
25260
|
const client = getActiveClient();
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
}
|
|
24637
|
-
else {
|
|
24638
|
-
upsertInCache(['post', 'get', post.postId], post);
|
|
24639
|
-
callback(post);
|
|
24640
|
-
}
|
|
24641
|
-
};
|
|
24642
|
-
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
25261
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
25262
|
+
const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
|
|
25263
|
+
return result;
|
|
24643
25264
|
};
|
|
25265
|
+
/* end_public_function */
|
|
24644
25266
|
|
|
25267
|
+
/* begin_public_function
|
|
25268
|
+
id: post.create.clip_post
|
|
25269
|
+
*/
|
|
24645
25270
|
/**
|
|
24646
25271
|
* ```js
|
|
24647
|
-
* import {
|
|
24648
|
-
* const
|
|
24649
|
-
*
|
|
24650
|
-
*
|
|
25272
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
25273
|
+
* const created = await PostRepository.createClipPost({
|
|
25274
|
+
* targetType: 'user',
|
|
25275
|
+
* targetId: 'foobar',
|
|
25276
|
+
* dataType: 'clip',
|
|
25277
|
+
* data: { text: 'hello world' },
|
|
25278
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
25279
|
+
* }))
|
|
24651
25280
|
* ```
|
|
24652
25281
|
*
|
|
24653
|
-
*
|
|
25282
|
+
* Creates an {@link Amity.Post}
|
|
24654
25283
|
*
|
|
24655
|
-
* @param
|
|
24656
|
-
* @returns
|
|
25284
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
25285
|
+
* @returns The newly created {@link Amity.Post}
|
|
24657
25286
|
*
|
|
24658
|
-
* @category Post
|
|
25287
|
+
* @category Post API
|
|
25288
|
+
* @async
|
|
24659
25289
|
*/
|
|
24660
|
-
const
|
|
25290
|
+
const createClipPost = async (bundle) => {
|
|
25291
|
+
const client = getActiveClient();
|
|
25292
|
+
client.log('post/createPost', bundle);
|
|
25293
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
25294
|
+
fireEvent('post.created', payload);
|
|
25295
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
25296
|
+
const cachedAt = client.cache && Date.now();
|
|
25297
|
+
if (client.cache)
|
|
25298
|
+
ingestInCache(data, { cachedAt });
|
|
25299
|
+
const { posts } = data;
|
|
25300
|
+
return {
|
|
25301
|
+
data: LinkedObject.post(posts[0]),
|
|
25302
|
+
cachedAt,
|
|
25303
|
+
};
|
|
25304
|
+
};
|
|
25305
|
+
/* end_public_function */
|
|
24661
25306
|
|
|
24662
25307
|
/* begin_public_function
|
|
24663
25308
|
id: post.get
|
|
@@ -24681,7 +25326,7 @@ const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.p
|
|
|
24681
25326
|
*
|
|
24682
25327
|
* @category Post Live Object
|
|
24683
25328
|
*/
|
|
24684
|
-
const getPost
|
|
25329
|
+
const getPost = (postId, callback) => {
|
|
24685
25330
|
const responder = (snapshot) => {
|
|
24686
25331
|
const { data } = snapshot;
|
|
24687
25332
|
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
@@ -24770,19 +25415,6 @@ class PostPaginationController extends PaginationController {
|
|
|
24770
25415
|
}
|
|
24771
25416
|
}
|
|
24772
25417
|
|
|
24773
|
-
var EnumPostActions;
|
|
24774
|
-
(function (EnumPostActions) {
|
|
24775
|
-
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
24776
|
-
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
24777
|
-
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
24778
|
-
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
24779
|
-
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
24780
|
-
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
24781
|
-
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
24782
|
-
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
24783
|
-
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
24784
|
-
})(EnumPostActions || (EnumPostActions = {}));
|
|
24785
|
-
|
|
24786
25418
|
class PostQueryStreamController extends QueryStreamController {
|
|
24787
25419
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
24788
25420
|
super(query, cacheKey);
|
|
@@ -24848,116 +25480,81 @@ class PostQueryStreamController extends QueryStreamController {
|
|
|
24848
25480
|
}
|
|
24849
25481
|
}
|
|
24850
25482
|
|
|
24851
|
-
const
|
|
24852
|
-
|
|
24853
|
-
|
|
24854
|
-
|
|
24855
|
-
|
|
24856
|
-
|
|
24857
|
-
|
|
24858
|
-
|
|
24859
|
-
|
|
24860
|
-
}
|
|
24861
|
-
catch (error) {
|
|
24862
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
24863
|
-
pushToTombstone('post', postId);
|
|
24864
|
-
}
|
|
24865
|
-
throw error;
|
|
24866
|
-
}
|
|
24867
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
24868
|
-
const cachedAt = client.cache && Date.now();
|
|
24869
|
-
if (client.cache)
|
|
24870
|
-
ingestInCache(data, { cachedAt });
|
|
24871
|
-
const { posts } = data;
|
|
24872
|
-
const result = posts.find(post => post.postId === postId);
|
|
24873
|
-
return {
|
|
24874
|
-
data: result,
|
|
24875
|
-
cachedAt,
|
|
24876
|
-
};
|
|
25483
|
+
const commentEventHandler = (callback, eventHandler, cacheKey, resolveId) => {
|
|
25484
|
+
return eventHandler(async (comment) => {
|
|
25485
|
+
var _a;
|
|
25486
|
+
const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25487
|
+
if (!currentCollection ||
|
|
25488
|
+
!currentCollection.data.includes(resolveId ? resolveId(comment.referenceId) : comment.referenceId))
|
|
25489
|
+
return;
|
|
25490
|
+
await getPost$1(comment.referenceId);
|
|
25491
|
+
callback(comment);
|
|
25492
|
+
});
|
|
24877
25493
|
};
|
|
24878
|
-
|
|
24879
|
-
const
|
|
24880
|
-
|
|
24881
|
-
|
|
24882
|
-
|
|
24883
|
-
|
|
24884
|
-
|
|
24885
|
-
|
|
24886
|
-
|
|
24887
|
-
|
|
24888
|
-
|
|
24889
|
-
|
|
25494
|
+
const generateCommentSubscriptions = ({ cacheKey, resolveId, }) => {
|
|
25495
|
+
const eventHandlers = [
|
|
25496
|
+
onCommentCreated,
|
|
25497
|
+
onCommentDeleted,
|
|
25498
|
+
onCommentReactionAdded,
|
|
25499
|
+
onCommentReactionRemoved,
|
|
25500
|
+
onCommentCreatedLocal,
|
|
25501
|
+
onCommentDeleteLocal,
|
|
25502
|
+
onLocalCommentReactionAdded,
|
|
25503
|
+
onLocalCommentReactionRemoved,
|
|
25504
|
+
];
|
|
25505
|
+
return eventHandlers.map(handler => ({
|
|
25506
|
+
fn: convertEventPayload((callback) => commentEventHandler(callback, handler, cacheKey, resolveId), 'referenceId', 'post'),
|
|
25507
|
+
action: EnumPostActions.OnPostUpdated,
|
|
25508
|
+
}));
|
|
25509
|
+
};
|
|
25510
|
+
const getPostSubscription = (cacheKey) => {
|
|
25511
|
+
return [
|
|
25512
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
25513
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
25514
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
25515
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
25516
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
25517
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
25518
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
25519
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
25520
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
25521
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
25522
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
25523
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
25524
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
25525
|
+
...generateCommentSubscriptions({ cacheKey }),
|
|
25526
|
+
];
|
|
24890
25527
|
};
|
|
24891
25528
|
|
|
24892
25529
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
24893
25530
|
constructor(query, callback) {
|
|
24894
|
-
const queryStreamId = hash__default["default"](query);
|
|
24895
|
-
const cacheKey = ['posts', 'collection', queryStreamId];
|
|
24896
|
-
const paginationController = new PostPaginationController(query);
|
|
24897
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
24898
|
-
this.query = query;
|
|
24899
|
-
this.queryStreamController = new PostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
24900
|
-
this.callback = callback.bind(this);
|
|
24901
|
-
this.loadPage({ initial: true });
|
|
24902
|
-
}
|
|
24903
|
-
setup() {
|
|
24904
|
-
var _a;
|
|
24905
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24906
|
-
if (!collection) {
|
|
24907
|
-
pushToCache(this.cacheKey, {
|
|
24908
|
-
data: [],
|
|
24909
|
-
params: {},
|
|
24910
|
-
});
|
|
24911
|
-
}
|
|
24912
|
-
}
|
|
24913
|
-
async persistModel(queryPayload) {
|
|
24914
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
24915
|
-
}
|
|
24916
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
24917
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
24918
|
-
}
|
|
24919
|
-
startSubscription() {
|
|
24920
|
-
return this.queryStreamController.subscribeRTE(
|
|
24921
|
-
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
24922
|
-
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
24923
|
-
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
24924
|
-
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24925
|
-
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
24926
|
-
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
24927
|
-
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
24928
|
-
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
24929
|
-
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24930
|
-
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24931
|
-
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
24932
|
-
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
24933
|
-
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
24934
|
-
{
|
|
24935
|
-
fn: convertEventPayload((callback) => {
|
|
24936
|
-
return onCommentCreated(async (comment) => {
|
|
24937
|
-
var _a;
|
|
24938
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24939
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24940
|
-
return;
|
|
24941
|
-
await getPost(comment.referenceId);
|
|
24942
|
-
callback(comment);
|
|
24943
|
-
});
|
|
24944
|
-
}, 'referenceId', 'post'),
|
|
24945
|
-
action: EnumPostActions.OnPostUpdated,
|
|
24946
|
-
},
|
|
24947
|
-
{
|
|
24948
|
-
fn: convertEventPayload((callback) => {
|
|
24949
|
-
return onCommentDeleted(async (comment) => {
|
|
24950
|
-
var _a;
|
|
24951
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24952
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
24953
|
-
return;
|
|
24954
|
-
await getPost(comment.referenceId);
|
|
24955
|
-
callback(comment);
|
|
24956
|
-
});
|
|
24957
|
-
}, 'referenceId', 'post'),
|
|
24958
|
-
action: EnumPostActions.OnPostUpdated,
|
|
24959
|
-
},
|
|
24960
|
-
]);
|
|
25531
|
+
const queryStreamId = hash__default["default"](query);
|
|
25532
|
+
const cacheKey = ['posts', 'collection', queryStreamId];
|
|
25533
|
+
const paginationController = new PostPaginationController(query);
|
|
25534
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
25535
|
+
this.query = query;
|
|
25536
|
+
this.queryStreamController = new PostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
25537
|
+
this.callback = callback.bind(this);
|
|
25538
|
+
this.loadPage({ initial: true });
|
|
25539
|
+
}
|
|
25540
|
+
setup() {
|
|
25541
|
+
var _a;
|
|
25542
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25543
|
+
if (!collection) {
|
|
25544
|
+
pushToCache(this.cacheKey, {
|
|
25545
|
+
data: [],
|
|
25546
|
+
params: {},
|
|
25547
|
+
});
|
|
25548
|
+
}
|
|
25549
|
+
}
|
|
25550
|
+
async persistModel(queryPayload) {
|
|
25551
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
25552
|
+
}
|
|
25553
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
25554
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
25555
|
+
}
|
|
25556
|
+
startSubscription() {
|
|
25557
|
+
return this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
|
|
24961
25558
|
}
|
|
24962
25559
|
notifyChange({ origin, loading, error }) {
|
|
24963
25560
|
var _a, _b;
|
|
@@ -25092,6 +25689,22 @@ class PinnedPostQueryStreamController extends QueryStreamController {
|
|
|
25092
25689
|
});
|
|
25093
25690
|
}
|
|
25094
25691
|
}
|
|
25692
|
+
reactor(action) {
|
|
25693
|
+
return (post) => {
|
|
25694
|
+
var _a;
|
|
25695
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
25696
|
+
if (!collection)
|
|
25697
|
+
return;
|
|
25698
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
25699
|
+
collection.data = collection.data.filter(referenceId => referenceId !== `global#${post.postId}`);
|
|
25700
|
+
}
|
|
25701
|
+
pushToCache(this.cacheKey, collection);
|
|
25702
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
25703
|
+
};
|
|
25704
|
+
}
|
|
25705
|
+
subscribeRTE(createSubscriber) {
|
|
25706
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
25707
|
+
}
|
|
25095
25708
|
}
|
|
25096
25709
|
|
|
25097
25710
|
class PinnedPostLiveCollectionController extends LiveCollectionController {
|
|
@@ -25123,7 +25736,10 @@ class PinnedPostLiveCollectionController extends LiveCollectionController {
|
|
|
25123
25736
|
}
|
|
25124
25737
|
// eslint-disable-next-line class-methods-use-this
|
|
25125
25738
|
startSubscription() {
|
|
25126
|
-
return
|
|
25739
|
+
return this.queryStreamController.subscribeRTE(generateCommentSubscriptions({
|
|
25740
|
+
cacheKey: this.cacheKey,
|
|
25741
|
+
resolveId: id => `${this.query.placement}#${id}`,
|
|
25742
|
+
}));
|
|
25127
25743
|
}
|
|
25128
25744
|
notifyChange({ origin, loading, error }) {
|
|
25129
25745
|
var _a, _b;
|
|
@@ -25275,6 +25891,10 @@ class GlobalPinnedPostLiveCollectionController extends LiveCollectionController
|
|
|
25275
25891
|
fn: onPostDeleted,
|
|
25276
25892
|
action: EnumPostActions.OnPostDeleted,
|
|
25277
25893
|
},
|
|
25894
|
+
...generateCommentSubscriptions({
|
|
25895
|
+
cacheKey: this.cacheKey,
|
|
25896
|
+
resolveId: id => `global#${id}`,
|
|
25897
|
+
}),
|
|
25278
25898
|
]);
|
|
25279
25899
|
}
|
|
25280
25900
|
notifyChange({ origin, loading, error }) {
|
|
@@ -25554,6 +26174,238 @@ const semanticSearchPosts = (params, callback, config) => {
|
|
|
25554
26174
|
};
|
|
25555
26175
|
};
|
|
25556
26176
|
|
|
26177
|
+
class SearchPostPaginationController extends PaginationController {
|
|
26178
|
+
async getRequest(queryParams, token) {
|
|
26179
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, matchingOnlyParentPost, hashtags, dataTypes, targetType = 'all' } = queryParams, params = __rest(queryParams, ["limit", "matchingOnlyParentPost", "hashtags", "dataTypes", "targetType"]);
|
|
26180
|
+
const baseOptions = {
|
|
26181
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
26182
|
+
};
|
|
26183
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
26184
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/search/posts`, {
|
|
26185
|
+
params: Object.assign(Object.assign({}, params), { hashtags,
|
|
26186
|
+
dataTypes,
|
|
26187
|
+
targetType,
|
|
26188
|
+
/*
|
|
26189
|
+
* when creating post like image, file, video BE will create 2 posts
|
|
26190
|
+
* 1. parent post to store text with dataType=text
|
|
26191
|
+
* 2. child post to store dataTypes post data
|
|
26192
|
+
*
|
|
26193
|
+
* By default, BE queries only parent post
|
|
26194
|
+
*/
|
|
26195
|
+
matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length), options }),
|
|
26196
|
+
});
|
|
26197
|
+
return queryResponse;
|
|
26198
|
+
}
|
|
26199
|
+
}
|
|
26200
|
+
|
|
26201
|
+
class SearchPostQueryStreamController extends QueryStreamController {
|
|
26202
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
26203
|
+
super(query, cacheKey);
|
|
26204
|
+
this.notifyChange = notifyChange;
|
|
26205
|
+
this.preparePayload = preparePayload;
|
|
26206
|
+
}
|
|
26207
|
+
async saveToMainDB(response) {
|
|
26208
|
+
const processedPayload = await this.preparePayload(response);
|
|
26209
|
+
const client = getActiveClient();
|
|
26210
|
+
const cachedAt = client.cache && Date.now();
|
|
26211
|
+
if (client.cache) {
|
|
26212
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
26213
|
+
}
|
|
26214
|
+
}
|
|
26215
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
26216
|
+
var _a, _b;
|
|
26217
|
+
if (refresh) {
|
|
26218
|
+
pushToCache(this.cacheKey, {
|
|
26219
|
+
data: response.posts.map(getResolver('post')),
|
|
26220
|
+
});
|
|
26221
|
+
}
|
|
26222
|
+
else {
|
|
26223
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26224
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26225
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
26226
|
+
}
|
|
26227
|
+
}
|
|
26228
|
+
reactor(action) {
|
|
26229
|
+
return (post) => {
|
|
26230
|
+
var _a, _b;
|
|
26231
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26232
|
+
if (!collection)
|
|
26233
|
+
return;
|
|
26234
|
+
if (post.parentPostId && post.isDeleted) {
|
|
26235
|
+
const parentPost = (_b = pullFromCache([
|
|
26236
|
+
'post',
|
|
26237
|
+
'get',
|
|
26238
|
+
post.parentPostId,
|
|
26239
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
26240
|
+
if (!parentPost)
|
|
26241
|
+
return;
|
|
26242
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
26243
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
26244
|
+
}
|
|
26245
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
26246
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
26247
|
+
}
|
|
26248
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
26249
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
26250
|
+
}
|
|
26251
|
+
pushToCache(this.cacheKey, collection);
|
|
26252
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
26253
|
+
};
|
|
26254
|
+
}
|
|
26255
|
+
subscribeRTE(createSubscriber) {
|
|
26256
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
26257
|
+
}
|
|
26258
|
+
}
|
|
26259
|
+
|
|
26260
|
+
class SearchPostLiveCollectionController extends LiveCollectionController {
|
|
26261
|
+
constructor(query, callback) {
|
|
26262
|
+
const queryStreamId = hash__default["default"](query);
|
|
26263
|
+
const cacheKey = ['posts', 'collection', queryStreamId];
|
|
26264
|
+
const paginationController = new SearchPostPaginationController(query);
|
|
26265
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
26266
|
+
this.query = query;
|
|
26267
|
+
this.queryStreamController = new SearchPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
26268
|
+
this.callback = callback.bind(this);
|
|
26269
|
+
this.loadPage({ initial: true });
|
|
26270
|
+
}
|
|
26271
|
+
setup() {
|
|
26272
|
+
var _a;
|
|
26273
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26274
|
+
if (!collection) {
|
|
26275
|
+
pushToCache(this.cacheKey, {
|
|
26276
|
+
data: [],
|
|
26277
|
+
params: {},
|
|
26278
|
+
});
|
|
26279
|
+
}
|
|
26280
|
+
}
|
|
26281
|
+
async persistModel(queryPayload) {
|
|
26282
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
26283
|
+
}
|
|
26284
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
26285
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
26286
|
+
}
|
|
26287
|
+
startSubscription() {
|
|
26288
|
+
return this.queryStreamController.subscribeRTE([
|
|
26289
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
26290
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
26291
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
26292
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
26293
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
26294
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
26295
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
26296
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
26297
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
26298
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
26299
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
26300
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
26301
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
26302
|
+
{
|
|
26303
|
+
fn: convertEventPayload((callback) => {
|
|
26304
|
+
return onCommentCreated(async (comment) => {
|
|
26305
|
+
var _a;
|
|
26306
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26307
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
26308
|
+
return;
|
|
26309
|
+
await getPost$1(comment.referenceId);
|
|
26310
|
+
callback(comment);
|
|
26311
|
+
});
|
|
26312
|
+
}, 'referenceId', 'post'),
|
|
26313
|
+
action: EnumPostActions.OnPostUpdated,
|
|
26314
|
+
},
|
|
26315
|
+
{
|
|
26316
|
+
fn: convertEventPayload((callback) => {
|
|
26317
|
+
return onCommentDeleted(async (comment) => {
|
|
26318
|
+
var _a;
|
|
26319
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26320
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
26321
|
+
return;
|
|
26322
|
+
await getPost$1(comment.referenceId);
|
|
26323
|
+
callback(comment);
|
|
26324
|
+
});
|
|
26325
|
+
}, 'referenceId', 'post'),
|
|
26326
|
+
action: EnumPostActions.OnPostUpdated,
|
|
26327
|
+
},
|
|
26328
|
+
]);
|
|
26329
|
+
}
|
|
26330
|
+
notifyChange({ origin, loading, error }) {
|
|
26331
|
+
var _a, _b;
|
|
26332
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26333
|
+
if (!collection)
|
|
26334
|
+
return;
|
|
26335
|
+
const data = this.applyFilter((_b = collection.data
|
|
26336
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
26337
|
+
.filter(isNonNullable)
|
|
26338
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
26339
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
26340
|
+
return;
|
|
26341
|
+
this.callback({
|
|
26342
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
26343
|
+
data,
|
|
26344
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
26345
|
+
loading,
|
|
26346
|
+
error,
|
|
26347
|
+
});
|
|
26348
|
+
}
|
|
26349
|
+
applyFilter(data) {
|
|
26350
|
+
var _a;
|
|
26351
|
+
let posts = data;
|
|
26352
|
+
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
26353
|
+
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
26354
|
+
}
|
|
26355
|
+
switch (this.query.sortBy) {
|
|
26356
|
+
case 'firstCreated':
|
|
26357
|
+
posts = posts.sort(sortByFirstCreated);
|
|
26358
|
+
break;
|
|
26359
|
+
case 'lastCreated':
|
|
26360
|
+
default:
|
|
26361
|
+
posts = posts.sort(sortByLastCreated);
|
|
26362
|
+
break;
|
|
26363
|
+
}
|
|
26364
|
+
return posts;
|
|
26365
|
+
}
|
|
26366
|
+
}
|
|
26367
|
+
|
|
26368
|
+
/* begin_public_function
|
|
26369
|
+
id: post.query
|
|
26370
|
+
*/
|
|
26371
|
+
/**
|
|
26372
|
+
* ```js
|
|
26373
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
26374
|
+
*
|
|
26375
|
+
* let posts = []
|
|
26376
|
+
* const unsub = PostRepository.searchPostsByHashtag({
|
|
26377
|
+
* hashtags: ['amity'],
|
|
26378
|
+
* limit: 10,
|
|
26379
|
+
* }, response => merge(posts, response.data))
|
|
26380
|
+
* ```
|
|
26381
|
+
*
|
|
26382
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
26383
|
+
*
|
|
26384
|
+
* @param params.hashtags the hashtags to search for
|
|
26385
|
+
* @param callback the function to call when new data are available
|
|
26386
|
+
* @param config
|
|
26387
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
26388
|
+
*
|
|
26389
|
+
* @category Posts Live Collection
|
|
26390
|
+
*/
|
|
26391
|
+
const searchPostsByHashtag = (params, callback, config) => {
|
|
26392
|
+
const { log, cache } = getActiveClient();
|
|
26393
|
+
if (!cache) {
|
|
26394
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
26395
|
+
}
|
|
26396
|
+
const timestamp = Date.now();
|
|
26397
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > listen`);
|
|
26398
|
+
const postsLiveCollection = new SearchPostLiveCollectionController(params, callback);
|
|
26399
|
+
const disposers = postsLiveCollection.startSubscription();
|
|
26400
|
+
const cacheKey = postsLiveCollection.getCacheKey();
|
|
26401
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
26402
|
+
return () => {
|
|
26403
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > dispose`);
|
|
26404
|
+
disposers.forEach(fn => fn());
|
|
26405
|
+
};
|
|
26406
|
+
};
|
|
26407
|
+
/* end_public_function */
|
|
26408
|
+
|
|
25557
26409
|
var index$8 = /*#__PURE__*/Object.freeze({
|
|
25558
26410
|
__proto__: null,
|
|
25559
26411
|
getPostByIds: getPostByIds,
|
|
@@ -25577,11 +26429,12 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
25577
26429
|
onPostUnflagged: onPostUnflagged,
|
|
25578
26430
|
onPostReactionAdded: onPostReactionAdded,
|
|
25579
26431
|
onPostReactionRemoved: onPostReactionRemoved,
|
|
25580
|
-
getPost: getPost
|
|
26432
|
+
getPost: getPost,
|
|
25581
26433
|
getPosts: getPosts,
|
|
25582
26434
|
getPinnedPosts: getPinnedPosts,
|
|
25583
26435
|
getGlobalPinnedPosts: getGlobalPinnedPosts,
|
|
25584
|
-
semanticSearchPosts: semanticSearchPosts
|
|
26436
|
+
semanticSearchPosts: semanticSearchPosts,
|
|
26437
|
+
searchPostsByHashtag: searchPostsByHashtag
|
|
25585
26438
|
});
|
|
25586
26439
|
|
|
25587
26440
|
/* begin_public_function
|
|
@@ -26186,8 +27039,8 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
26186
27039
|
* const created = await createPoll({
|
|
26187
27040
|
* question: 'question',
|
|
26188
27041
|
* answers: [
|
|
26189
|
-
* { dataType: 'text', data: 'answer1' },
|
|
26190
|
-
* { dataType: 'text', data: 'answer2' },
|
|
27042
|
+
* { dataType: 'text', data: 'answer1', fileId: 'fileId1' },
|
|
27043
|
+
* { dataType: 'text', data: 'answer2', fileId: 'fileId2' },
|
|
26191
27044
|
* ],
|
|
26192
27045
|
* closedIn: 1649136484
|
|
26193
27046
|
* }))
|
|
@@ -26460,7 +27313,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
26460
27313
|
getPoll: getPoll
|
|
26461
27314
|
});
|
|
26462
27315
|
|
|
26463
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
27316
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
|
|
26464
27317
|
/*
|
|
26465
27318
|
* The crypto algorithm used for importing key and signing string
|
|
26466
27319
|
*/
|
|
@@ -28780,13 +29633,13 @@ exports.AdRepository = index$3;
|
|
|
28780
29633
|
exports.CategoryRepository = index$b;
|
|
28781
29634
|
exports.ChannelRepository = index$f;
|
|
28782
29635
|
exports.Client = index$o;
|
|
28783
|
-
exports.CommentRepository = index$
|
|
29636
|
+
exports.CommentRepository = index$a;
|
|
28784
29637
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
28785
29638
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
28786
29639
|
exports.CommunityRepository = index$c;
|
|
28787
29640
|
exports.ContentFeedType = ContentFeedType;
|
|
28788
29641
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
28789
|
-
exports.FeedRepository = index$
|
|
29642
|
+
exports.FeedRepository = index$9;
|
|
28790
29643
|
exports.FileRepository = index$l;
|
|
28791
29644
|
exports.FileType = FileType;
|
|
28792
29645
|
exports.InvitationRepository = index$1;
|