@amityco/ts-sdk-react-native 7.8.1-a583f03.0 → 7.8.2-423c4c9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts +4 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/client.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/community.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/community.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/community.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/content.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts +36 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/feed.js +22 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/feed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts +11 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js +2 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/notification.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.d.ts +1 -4
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/poll.d.ts +3 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/poll.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/poll.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts +14 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/domains/post.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/@types/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts +16 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js +21 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/client/api/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js +6 -6
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.js +3 -2
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/core/model/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/core/model/index.js +2 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/core/model/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts +0 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js +0 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js +3 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/index.js +2 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js +60 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js +13 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js +66 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js +45 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js +60 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js +13 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js +66 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js +45 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js +108 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js +15 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js +78 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js +46 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts +4 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js +4 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts +6 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js +60 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.d.ts +3 -3
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.js +2 -2
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js +2 -2
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/events/utils.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js +26 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js +5 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js +5 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js +17 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js +2 -50
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts +14 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js +126 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js +27 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js +65 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js +45 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js +61 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js +9 -4
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/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 +2130 -1277
- package/dist/index.esm.js +2037 -1184
- package/dist/index.umd.js +3 -3
- 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/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/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.js +0 -83
- package/.rollup.cache/home/runner/work/AmityReactNativeTypescriptSDK/AmityReactNativeTypescriptSDK/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.esm.js
CHANGED
|
@@ -139,10 +139,33 @@ var JoinResultStatusEnum;
|
|
|
139
139
|
JoinResultStatusEnum["Pending"] = "pending";
|
|
140
140
|
})(JoinResultStatusEnum || (JoinResultStatusEnum = {}));
|
|
141
141
|
|
|
142
|
+
var FeedDataTypeEnum;
|
|
143
|
+
(function (FeedDataTypeEnum) {
|
|
144
|
+
FeedDataTypeEnum["Text"] = "text";
|
|
145
|
+
FeedDataTypeEnum["Video"] = "video";
|
|
146
|
+
FeedDataTypeEnum["Image"] = "image";
|
|
147
|
+
FeedDataTypeEnum["File"] = "file";
|
|
148
|
+
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
149
|
+
FeedDataTypeEnum["Clip"] = "clip";
|
|
150
|
+
FeedDataTypeEnum["Poll"] = "poll";
|
|
151
|
+
})(FeedDataTypeEnum || (FeedDataTypeEnum = {}));
|
|
152
|
+
var FeedSortByEnum;
|
|
153
|
+
(function (FeedSortByEnum) {
|
|
154
|
+
FeedSortByEnum["LastCreated"] = "lastCreated";
|
|
155
|
+
FeedSortByEnum["FirstCreated"] = "firstCreated";
|
|
156
|
+
FeedSortByEnum["LastUpdated"] = "lastUpdated";
|
|
157
|
+
FeedSortByEnum["FirstUpdated"] = "firstUpdated";
|
|
158
|
+
})(FeedSortByEnum || (FeedSortByEnum = {}));
|
|
159
|
+
var FeedSourceEnum;
|
|
160
|
+
(function (FeedSourceEnum) {
|
|
161
|
+
FeedSourceEnum["Community"] = "community";
|
|
162
|
+
FeedSourceEnum["User"] = "user";
|
|
163
|
+
})(FeedSourceEnum || (FeedSourceEnum = {}));
|
|
164
|
+
|
|
142
165
|
function getVersion() {
|
|
143
166
|
try {
|
|
144
|
-
// the string ''v7.8.
|
|
145
|
-
return 'v7.8.
|
|
167
|
+
// the string ''v7.8.1-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
168
|
+
return 'v7.8.1-esm';
|
|
146
169
|
}
|
|
147
170
|
catch (error) {
|
|
148
171
|
return '__dev__';
|
|
@@ -644,7 +667,8 @@ const PAYLOAD2MODEL = {
|
|
|
644
667
|
};
|
|
645
668
|
/** hidden */
|
|
646
669
|
const isOutdated = (prevData, nextData) => {
|
|
647
|
-
|
|
670
|
+
// Check if the new value is outdated.
|
|
671
|
+
if ('updatedAt' in nextData && 'updatedAt' in prevData) {
|
|
648
672
|
return new Date(nextData.updatedAt) < new Date(prevData.updatedAt);
|
|
649
673
|
}
|
|
650
674
|
return false;
|
|
@@ -26017,6 +26041,26 @@ const fetchLinkPreview = async (url) => {
|
|
|
26017
26041
|
return data;
|
|
26018
26042
|
};
|
|
26019
26043
|
|
|
26044
|
+
/**
|
|
26045
|
+
* ```js
|
|
26046
|
+
* import Client from '@amityco/ts-sdk'
|
|
26047
|
+
* const shareableLinkConfiguration = await Client.getShareableLinkConfiguration()
|
|
26048
|
+
* const postLinkPattern = shareableLinkConfiguration.post
|
|
26049
|
+
* ```
|
|
26050
|
+
*
|
|
26051
|
+
* Fetches a {@link Amity.ShareableLinkConfiguration} object
|
|
26052
|
+
*
|
|
26053
|
+
* @returns A Promise of {@link Amity.ShareableLinkConfiguration} object
|
|
26054
|
+
*
|
|
26055
|
+
* @category Client API
|
|
26056
|
+
* @async
|
|
26057
|
+
*/
|
|
26058
|
+
const getShareableLinkConfiguration = async () => {
|
|
26059
|
+
const client = getActiveClient();
|
|
26060
|
+
const { data } = await client.http.get(`/api/v3/network-settings/shareable-deep-links`);
|
|
26061
|
+
return data;
|
|
26062
|
+
};
|
|
26063
|
+
|
|
26020
26064
|
/**
|
|
26021
26065
|
* ```js
|
|
26022
26066
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk-react-native'
|
|
@@ -26389,6 +26433,8 @@ var index$o = /*#__PURE__*/Object.freeze({
|
|
|
26389
26433
|
unregisterPushNotification: unregisterPushNotification,
|
|
26390
26434
|
onRTEConnectionStateChange: onRTEConnectionStateChange,
|
|
26391
26435
|
fetchLinkPreview: fetchLinkPreview,
|
|
26436
|
+
getSocialSettings: getSocialSettings,
|
|
26437
|
+
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
26392
26438
|
onConnectionError: onConnectionError,
|
|
26393
26439
|
onClientDisconnected: onClientDisconnected,
|
|
26394
26440
|
onClientBanned: onClientBanned,
|
|
@@ -28092,15 +28138,18 @@ function isAmityClipPost(post) {
|
|
|
28092
28138
|
}
|
|
28093
28139
|
|
|
28094
28140
|
const postLinkedObject = (post) => {
|
|
28095
|
-
return
|
|
28141
|
+
return shallowClone(post, {
|
|
28142
|
+
childrenPosts: post.children
|
|
28096
28143
|
.map(childPost => { var _a; return (_a = pullFromCache(['post', 'get', childPost])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
28097
28144
|
.filter(isNonNullable)
|
|
28098
|
-
.map(postLinkedObject),
|
|
28145
|
+
.map(postLinkedObject),
|
|
28146
|
+
analytics: {
|
|
28099
28147
|
markAsViewed: () => {
|
|
28100
28148
|
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
28101
28149
|
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
28102
28150
|
},
|
|
28103
|
-
},
|
|
28151
|
+
},
|
|
28152
|
+
get latestComments() {
|
|
28104
28153
|
if (!post.comments)
|
|
28105
28154
|
return [];
|
|
28106
28155
|
return (post.comments
|
|
@@ -28174,7 +28223,8 @@ const postLinkedObject = (post) => {
|
|
|
28174
28223
|
return isAmityClipPost(post)
|
|
28175
28224
|
? (_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
|
|
28176
28225
|
: undefined;
|
|
28177
|
-
}
|
|
28226
|
+
},
|
|
28227
|
+
});
|
|
28178
28228
|
};
|
|
28179
28229
|
|
|
28180
28230
|
const getCachedMarker = (message) => {
|
|
@@ -31169,7 +31219,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
31169
31219
|
]);
|
|
31170
31220
|
if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
31171
31221
|
return true;
|
|
31172
|
-
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 }) });
|
|
31222
|
+
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() });
|
|
31173
31223
|
if (referenceType === 'comment') {
|
|
31174
31224
|
fireEvent('local.comment.addReaction', {
|
|
31175
31225
|
comment: updatedModel,
|
|
@@ -31292,7 +31342,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
31292
31342
|
]);
|
|
31293
31343
|
if (!model)
|
|
31294
31344
|
return true;
|
|
31295
|
-
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) }) });
|
|
31345
|
+
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() });
|
|
31296
31346
|
if (referenceType === 'comment') {
|
|
31297
31347
|
fireEvent('local.comment.removeReaction', {
|
|
31298
31348
|
comment: updatedModel,
|
|
@@ -31406,6 +31456,26 @@ const prepareSemanticSearchPostPayload = (_a) => {
|
|
|
31406
31456
|
return Object.assign(Object.assign({}, processedPostPayload), { polls });
|
|
31407
31457
|
};
|
|
31408
31458
|
|
|
31459
|
+
const processDeleteChildPost = (payload) => {
|
|
31460
|
+
var _a;
|
|
31461
|
+
const post = payload.posts[0];
|
|
31462
|
+
if (!post.parentId)
|
|
31463
|
+
return;
|
|
31464
|
+
const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
31465
|
+
if (!parentPost)
|
|
31466
|
+
return;
|
|
31467
|
+
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
|
|
31468
|
+
};
|
|
31469
|
+
const processCreateChildPost = (payload) => {
|
|
31470
|
+
var _a;
|
|
31471
|
+
const post = payload.posts[0];
|
|
31472
|
+
if (!post.parentId)
|
|
31473
|
+
return;
|
|
31474
|
+
const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
31475
|
+
if (!parentPost)
|
|
31476
|
+
return;
|
|
31477
|
+
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: [...new Set([post.postId, ...parentPost.children])] }));
|
|
31478
|
+
};
|
|
31409
31479
|
const createPostEventSubscriber = (event, callback) => {
|
|
31410
31480
|
const client = getActiveClient();
|
|
31411
31481
|
const filter = (payload) => {
|
|
@@ -31430,6 +31500,7 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
31430
31500
|
}
|
|
31431
31501
|
if (event === 'post.deleted') {
|
|
31432
31502
|
const { postId, postedUserId } = payload.posts[0];
|
|
31503
|
+
processDeleteChildPost(payload);
|
|
31433
31504
|
try {
|
|
31434
31505
|
isInTombstone('post', postId);
|
|
31435
31506
|
}
|
|
@@ -31456,6 +31527,8 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
31456
31527
|
}
|
|
31457
31528
|
queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
|
|
31458
31529
|
}
|
|
31530
|
+
if (event === 'post.created')
|
|
31531
|
+
processCreateChildPost(payload);
|
|
31459
31532
|
callback(post.data);
|
|
31460
31533
|
}
|
|
31461
31534
|
};
|
|
@@ -31482,6 +31555,8 @@ const createLocalPostEventSubscriber = (event, callback) => {
|
|
|
31482
31555
|
});
|
|
31483
31556
|
}
|
|
31484
31557
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
31558
|
+
if (event === 'local.post.deleted')
|
|
31559
|
+
processDeleteChildPost(payload);
|
|
31485
31560
|
callback(post.data);
|
|
31486
31561
|
}
|
|
31487
31562
|
};
|
|
@@ -38013,10 +38088,10 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
38013
38088
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38014
38089
|
if (!collection)
|
|
38015
38090
|
return;
|
|
38016
|
-
const data =
|
|
38091
|
+
const data = (_b = collection.data
|
|
38017
38092
|
.map(id => pullFromCache(['community', 'get', id]))
|
|
38018
38093
|
.filter(isNonNullable)
|
|
38019
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []
|
|
38094
|
+
.map(({ data }) => communityLinkedObject(data))) !== null && _b !== void 0 ? _b : [];
|
|
38020
38095
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
38021
38096
|
return;
|
|
38022
38097
|
this.callback({
|
|
@@ -39257,6 +39332,9 @@ var index$b = /*#__PURE__*/Object.freeze({
|
|
|
39257
39332
|
id: feed.query.global_feed
|
|
39258
39333
|
*/
|
|
39259
39334
|
/**
|
|
39335
|
+
*
|
|
39336
|
+
* @deprecated This function will to be deprecated. Please use getGlobalFeed instead.
|
|
39337
|
+
*
|
|
39260
39338
|
* ```js
|
|
39261
39339
|
* import { queryGlobalFeed } from '@amityco/ts-sdk-react-native'
|
|
39262
39340
|
* const posts = await queryGlobalFeed()
|
|
@@ -39339,1086 +39417,1023 @@ queryGlobalFeed.locally = (query) => {
|
|
|
39339
39417
|
: undefined;
|
|
39340
39418
|
};
|
|
39341
39419
|
|
|
39342
|
-
|
|
39343
|
-
|
|
39344
|
-
|
|
39345
|
-
|
|
39346
|
-
|
|
39347
|
-
|
|
39348
|
-
|
|
39349
|
-
|
|
39350
|
-
*
|
|
39351
|
-
* Queries a paginable list of {@link Amity.Post} objects
|
|
39352
|
-
*
|
|
39353
|
-
* @param query The query parameters
|
|
39354
|
-
* @returns A page of {@link Amity.Post} objects
|
|
39355
|
-
*
|
|
39356
|
-
* @category Feed API
|
|
39357
|
-
* @async
|
|
39358
|
-
* */
|
|
39359
|
-
const getCustomRankingGlobalFeed = async (query) => {
|
|
39360
|
-
const client = getActiveClient();
|
|
39361
|
-
client.log('feed/getCustomRankingGlobalFeed', query);
|
|
39362
|
-
const _a = query !== null && query !== void 0 ? query : {}, { queryToken, limit } = _a, params = __rest(_a, ["queryToken", "limit"]);
|
|
39363
|
-
const options = (() => {
|
|
39364
|
-
if (queryToken)
|
|
39365
|
-
return { token: queryToken };
|
|
39366
|
-
return undefined;
|
|
39367
|
-
})();
|
|
39368
|
-
const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
|
|
39369
|
-
params: Object.assign(Object.assign({}, params), { limit: !queryToken ? limit : undefined, options }),
|
|
39370
|
-
});
|
|
39371
|
-
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
39372
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39373
|
-
const { posts } = data;
|
|
39374
|
-
const cachedAt = client.cache && Date.now();
|
|
39375
|
-
if (client.cache) {
|
|
39376
|
-
ingestInCache(data);
|
|
39377
|
-
const cacheKey = ['customGlobalFeed', 'query', Object.assign(Object.assign({}, params), { options })];
|
|
39378
|
-
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
39420
|
+
class CustomRankingGlobalFeedPaginationController extends PaginationController {
|
|
39421
|
+
async getRequest(queryParams, token) {
|
|
39422
|
+
const { limit } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
39423
|
+
const options = token ? { token } : { limit };
|
|
39424
|
+
const { data: queryResponse } = await this.http.get(`/api/v5/me/global-feeds`, {
|
|
39425
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
39426
|
+
});
|
|
39427
|
+
return queryResponse;
|
|
39379
39428
|
}
|
|
39380
|
-
|
|
39381
|
-
};
|
|
39382
|
-
/* end_public_function */
|
|
39383
|
-
/**
|
|
39384
|
-
* ```js
|
|
39385
|
-
* import { FeedRepository } from '@amityco/ts-sdk-react-native'
|
|
39386
|
-
* const posts = await FeedRepository.getCustomRankingGlobalFeed.locally()
|
|
39387
|
-
* ```
|
|
39388
|
-
*
|
|
39389
|
-
* Queries a paginable list of {@link Amity.Post} objects from cache
|
|
39390
|
-
*
|
|
39391
|
-
* @param query The query parameters
|
|
39392
|
-
* @returns A page of {@link Amity.Post} objects
|
|
39393
|
-
*
|
|
39394
|
-
* @category Feed API
|
|
39395
|
-
* @async
|
|
39396
|
-
* */
|
|
39397
|
-
getCustomRankingGlobalFeed.locally = (query) => {
|
|
39398
|
-
var _a, _b;
|
|
39399
|
-
const client = getActiveClient();
|
|
39400
|
-
client.log('post/getCustomRankingGlobalFeed.locally', query);
|
|
39401
|
-
if (!client.cache)
|
|
39402
|
-
return;
|
|
39403
|
-
const params = __rest(query !== null && query !== void 0 ? query : {}, []);
|
|
39404
|
-
const queryKey = ['customGlobalFeed', 'query', Object.assign({}, params)];
|
|
39405
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
39406
|
-
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
39407
|
-
return;
|
|
39408
|
-
const posts = data.posts
|
|
39409
|
-
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
39410
|
-
.filter(Boolean)
|
|
39411
|
-
.map(({ data }) => data);
|
|
39412
|
-
const { paging } = data;
|
|
39413
|
-
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
39414
|
-
? { data: posts.map(LinkedObject.post), cachedAt, paging }
|
|
39415
|
-
: undefined;
|
|
39416
|
-
};
|
|
39429
|
+
}
|
|
39417
39430
|
|
|
39418
|
-
var
|
|
39419
|
-
|
|
39420
|
-
|
|
39421
|
-
|
|
39422
|
-
|
|
39431
|
+
var EnumPostActions;
|
|
39432
|
+
(function (EnumPostActions) {
|
|
39433
|
+
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
39434
|
+
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
39435
|
+
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
39436
|
+
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
39437
|
+
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
39438
|
+
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
39439
|
+
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
39440
|
+
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
39441
|
+
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
39442
|
+
})(EnumPostActions || (EnumPostActions = {}));
|
|
39443
|
+
|
|
39444
|
+
class CustomRankingGlobalFeedQueryStreamController extends QueryStreamController {
|
|
39445
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
39446
|
+
super(query, cacheKey);
|
|
39447
|
+
this.notifyChange = notifyChange;
|
|
39448
|
+
this.preparePayload = preparePayload;
|
|
39449
|
+
}
|
|
39450
|
+
async saveToMainDB(response) {
|
|
39451
|
+
const processedPayload = await this.preparePayload(response);
|
|
39452
|
+
const client = getActiveClient();
|
|
39453
|
+
const cachedAt = client.cache && Date.now();
|
|
39454
|
+
if (client.cache) {
|
|
39455
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
39456
|
+
}
|
|
39457
|
+
}
|
|
39458
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
39459
|
+
var _a, _b;
|
|
39460
|
+
if (refresh) {
|
|
39461
|
+
pushToCache(this.cacheKey, {
|
|
39462
|
+
data: response.posts.map(getResolver('post')),
|
|
39463
|
+
});
|
|
39464
|
+
}
|
|
39465
|
+
else {
|
|
39466
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39467
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
39468
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
39469
|
+
}
|
|
39470
|
+
}
|
|
39471
|
+
reactor(action) {
|
|
39472
|
+
return (post) => {
|
|
39473
|
+
var _a;
|
|
39474
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39475
|
+
if (!collection)
|
|
39476
|
+
return;
|
|
39477
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
39478
|
+
return;
|
|
39479
|
+
// Delete Action
|
|
39480
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
39481
|
+
// Parent Post - Remove from collection
|
|
39482
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
39483
|
+
}
|
|
39484
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
39485
|
+
// If the query has dataTypes array with value, check if post.dataType is include in the array
|
|
39486
|
+
if (this.query.dataTypes && this.query.dataTypes.length > 0) {
|
|
39487
|
+
if (!this.query.dataTypes.includes(post.dataType))
|
|
39488
|
+
return;
|
|
39489
|
+
}
|
|
39490
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
39491
|
+
}
|
|
39492
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
39493
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
39494
|
+
}
|
|
39495
|
+
pushToCache(this.cacheKey, collection);
|
|
39496
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
39497
|
+
};
|
|
39498
|
+
}
|
|
39499
|
+
subscribeRTE(createSubscriber) {
|
|
39500
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
39501
|
+
}
|
|
39502
|
+
}
|
|
39423
39503
|
|
|
39424
39504
|
/* begin_public_function
|
|
39425
|
-
id:
|
|
39505
|
+
id: comment.get_by_ids
|
|
39426
39506
|
*/
|
|
39427
39507
|
/**
|
|
39428
39508
|
* ```js
|
|
39429
|
-
* import {
|
|
39430
|
-
* const
|
|
39509
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39510
|
+
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
39431
39511
|
* ```
|
|
39432
39512
|
*
|
|
39433
|
-
* Fetches a collection of {@link Amity.
|
|
39513
|
+
* Fetches a collection of {@link Amity.Comment} objects
|
|
39434
39514
|
*
|
|
39435
|
-
* @param
|
|
39436
|
-
* @returns the associated collection of {@link Amity.
|
|
39515
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39516
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39437
39517
|
*
|
|
39438
|
-
* @category
|
|
39518
|
+
* @category Comment API
|
|
39439
39519
|
* @async
|
|
39440
39520
|
*/
|
|
39441
|
-
const
|
|
39521
|
+
const getCommentByIds = async (commentIds) => {
|
|
39442
39522
|
const client = getActiveClient();
|
|
39443
|
-
client.log('
|
|
39444
|
-
const
|
|
39445
|
-
let
|
|
39523
|
+
client.log('comment/getCommentByIds', commentIds);
|
|
39524
|
+
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
39525
|
+
let data;
|
|
39446
39526
|
try {
|
|
39447
39527
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
39448
|
-
const response = await client.http.get(`/api/v3/
|
|
39449
|
-
params: {
|
|
39528
|
+
const response = await client.http.get(`/api/v3/comments/list`, {
|
|
39529
|
+
params: { commentIds: encodedCommentIds },
|
|
39450
39530
|
});
|
|
39451
|
-
|
|
39531
|
+
data = response.data;
|
|
39452
39532
|
}
|
|
39453
39533
|
catch (error) {
|
|
39454
|
-
|
|
39534
|
+
commentIds.forEach(commentId => {
|
|
39455
39535
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39456
|
-
pushToTombstone('
|
|
39536
|
+
pushToTombstone('comment', commentId);
|
|
39457
39537
|
}
|
|
39458
39538
|
});
|
|
39459
39539
|
throw error;
|
|
39460
39540
|
}
|
|
39461
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39462
39541
|
const cachedAt = client.cache && Date.now();
|
|
39463
39542
|
if (client.cache)
|
|
39464
39543
|
ingestInCache(data, { cachedAt });
|
|
39465
39544
|
return {
|
|
39466
|
-
data: data.
|
|
39545
|
+
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
39467
39546
|
cachedAt,
|
|
39468
39547
|
};
|
|
39469
39548
|
};
|
|
39470
39549
|
/* end_public_function */
|
|
39471
39550
|
/**
|
|
39472
39551
|
* ```js
|
|
39473
|
-
* import {
|
|
39474
|
-
* const
|
|
39552
|
+
* import { getCommentByIds } from '@amityco/ts-sdk-react-native'
|
|
39553
|
+
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
39475
39554
|
* ```
|
|
39476
39555
|
*
|
|
39477
|
-
* Fetches a collection of {@link Amity.
|
|
39556
|
+
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
39478
39557
|
*
|
|
39479
|
-
* @param
|
|
39480
|
-
* @returns the associated collection of {@link Amity.
|
|
39558
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39559
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39481
39560
|
*
|
|
39482
|
-
* @category
|
|
39561
|
+
* @category Comment API
|
|
39483
39562
|
*/
|
|
39484
|
-
|
|
39563
|
+
getCommentByIds.locally = (commentIds) => {
|
|
39485
39564
|
var _a;
|
|
39486
39565
|
const client = getActiveClient();
|
|
39487
|
-
client.log('
|
|
39566
|
+
client.log('comment/getCommentByIds.locally', commentIds);
|
|
39488
39567
|
if (!client.cache)
|
|
39489
39568
|
return;
|
|
39490
|
-
const cached =
|
|
39491
|
-
.map(
|
|
39569
|
+
const cached = commentIds
|
|
39570
|
+
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
39492
39571
|
.filter(Boolean);
|
|
39493
|
-
const
|
|
39572
|
+
const comments = cached.map(({ data }) => data);
|
|
39494
39573
|
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
39495
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) <
|
|
39574
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
39496
39575
|
return;
|
|
39497
39576
|
return {
|
|
39498
|
-
data:
|
|
39577
|
+
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
39499
39578
|
cachedAt: oldest.cachedAt,
|
|
39500
39579
|
};
|
|
39501
39580
|
};
|
|
39502
39581
|
|
|
39503
39582
|
/* begin_public_function
|
|
39504
|
-
id:
|
|
39583
|
+
id: comment.create
|
|
39505
39584
|
*/
|
|
39506
39585
|
/**
|
|
39507
39586
|
* ```js
|
|
39508
|
-
* import {
|
|
39509
|
-
* const
|
|
39510
|
-
* targetType: 'user',
|
|
39511
|
-
* targetId: 'foobar',
|
|
39512
|
-
* data: { text: 'hello world' }
|
|
39513
|
-
* }))
|
|
39587
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39588
|
+
* const newComment = await CommentRepository.createComment(bundle)
|
|
39514
39589
|
* ```
|
|
39515
39590
|
*
|
|
39516
|
-
* Creates an {@link Amity.
|
|
39591
|
+
* Creates an {@link Amity.Comment}
|
|
39517
39592
|
*
|
|
39518
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
39519
|
-
* @returns The newly created {@link Amity.
|
|
39593
|
+
* @param bundle The data necessary to create a new {@link Amity.Comment}
|
|
39594
|
+
* @returns The newly created {@link Amity.Comment}
|
|
39520
39595
|
*
|
|
39521
|
-
* @category
|
|
39596
|
+
* @category Comment API
|
|
39522
39597
|
* @async
|
|
39523
39598
|
*/
|
|
39524
|
-
const
|
|
39599
|
+
const createComment = async (bundle) => {
|
|
39600
|
+
var _a;
|
|
39525
39601
|
const client = getActiveClient();
|
|
39526
|
-
client.log('
|
|
39527
|
-
|
|
39528
|
-
|
|
39529
|
-
|
|
39530
|
-
|
|
39531
|
-
|
|
39532
|
-
fireEvent('post.created', payload);
|
|
39533
|
-
const data = preparePostPayload(payload);
|
|
39602
|
+
client.log('comment/createComment', bundle);
|
|
39603
|
+
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
39604
|
+
const { comments } = data;
|
|
39605
|
+
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
39606
|
+
if (comments.length === 0)
|
|
39607
|
+
throw new Error('Comment not created');
|
|
39534
39608
|
const cachedAt = client.cache && Date.now();
|
|
39535
39609
|
if (client.cache)
|
|
39536
39610
|
ingestInCache(data, { cachedAt });
|
|
39537
|
-
|
|
39611
|
+
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
39612
|
+
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39613
|
+
if (post) {
|
|
39614
|
+
post.commentsCount += 1;
|
|
39615
|
+
fireEvent('local.post.updated', {
|
|
39616
|
+
posts: [post],
|
|
39617
|
+
categories: [],
|
|
39618
|
+
comments: [],
|
|
39619
|
+
communities: [],
|
|
39620
|
+
communityUsers: data.communityUsers,
|
|
39621
|
+
feeds: [],
|
|
39622
|
+
files: data.files,
|
|
39623
|
+
postChildren: [],
|
|
39624
|
+
users: data.users,
|
|
39625
|
+
videoStreamings: [],
|
|
39626
|
+
});
|
|
39627
|
+
}
|
|
39628
|
+
}
|
|
39629
|
+
else if (bundle.referenceType === 'story') {
|
|
39630
|
+
const storyIndex = pullFromCache([
|
|
39631
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39632
|
+
bundle.referenceId,
|
|
39633
|
+
]);
|
|
39634
|
+
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
39635
|
+
const cacheStory = pullFromCache([
|
|
39636
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
39637
|
+
'get',
|
|
39638
|
+
storyIndex.data,
|
|
39639
|
+
]);
|
|
39640
|
+
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
39641
|
+
fireEvent('story.updated', {
|
|
39642
|
+
stories: [
|
|
39643
|
+
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
39644
|
+
],
|
|
39645
|
+
categories: [],
|
|
39646
|
+
comments,
|
|
39647
|
+
communities: [],
|
|
39648
|
+
communityUsers: data.communityUsers,
|
|
39649
|
+
files: data.files,
|
|
39650
|
+
users: data.users,
|
|
39651
|
+
});
|
|
39652
|
+
}
|
|
39653
|
+
}
|
|
39654
|
+
}
|
|
39655
|
+
fireEvent('local.comment.created', data);
|
|
39538
39656
|
return {
|
|
39539
|
-
data: LinkedObject.
|
|
39657
|
+
data: LinkedObject.comment(comments[0]),
|
|
39540
39658
|
cachedAt,
|
|
39541
39659
|
};
|
|
39542
39660
|
};
|
|
39543
39661
|
/* end_public_function */
|
|
39544
39662
|
|
|
39545
39663
|
/* begin_public_function
|
|
39546
|
-
id:
|
|
39664
|
+
id: comment.update_comment
|
|
39547
39665
|
*/
|
|
39548
39666
|
/**
|
|
39549
39667
|
* ```js
|
|
39550
|
-
* import {
|
|
39551
|
-
* const updated = await
|
|
39668
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39669
|
+
* const updated = await CommentRepository.updateComment(commentId, {
|
|
39552
39670
|
* data: { text: 'hello world' }
|
|
39553
39671
|
* })
|
|
39554
39672
|
* ```
|
|
39555
39673
|
*
|
|
39556
|
-
* Updates an {@link Amity.
|
|
39674
|
+
* Updates an {@link Amity.Comment}
|
|
39557
39675
|
*
|
|
39558
|
-
* @param
|
|
39676
|
+
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
39559
39677
|
* @param patch The patch data to apply
|
|
39560
|
-
* @returns the updated {@link Amity.
|
|
39678
|
+
* @returns the updated {@link Amity.Comment} object
|
|
39561
39679
|
*
|
|
39562
|
-
* @category
|
|
39680
|
+
* @category Comment API
|
|
39563
39681
|
* @async
|
|
39564
39682
|
*/
|
|
39565
|
-
const
|
|
39683
|
+
const updateComment = async (commentId, patch) => {
|
|
39566
39684
|
const client = getActiveClient();
|
|
39567
|
-
client.log('user/
|
|
39568
|
-
const { data
|
|
39569
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39685
|
+
client.log('user/updateComment', patch);
|
|
39686
|
+
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
39570
39687
|
const cachedAt = client.cache && Date.now();
|
|
39571
39688
|
if (client.cache)
|
|
39572
39689
|
ingestInCache(data, { cachedAt });
|
|
39573
|
-
fireEvent('
|
|
39574
|
-
const {
|
|
39690
|
+
fireEvent('comment.updated', data);
|
|
39691
|
+
const { comments } = data;
|
|
39575
39692
|
return {
|
|
39576
|
-
data: LinkedObject.
|
|
39693
|
+
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
39577
39694
|
cachedAt,
|
|
39578
39695
|
};
|
|
39579
39696
|
};
|
|
39580
39697
|
/* end_public_function */
|
|
39581
39698
|
|
|
39699
|
+
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
39700
|
+
const applyMissingField = (rawData, isCreated = false) => {
|
|
39701
|
+
const { storyId, referenceId } = rawData;
|
|
39702
|
+
if (!isCreated) {
|
|
39703
|
+
if (referenceId)
|
|
39704
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
39705
|
+
}
|
|
39706
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
39707
|
+
};
|
|
39708
|
+
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
39709
|
+
const { stories } = data;
|
|
39710
|
+
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
39711
|
+
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
39712
|
+
};
|
|
39713
|
+
|
|
39714
|
+
const getStoryByStoryId$1 = async (storyId) => {
|
|
39715
|
+
const client = getActiveClient();
|
|
39716
|
+
client.log('story/getStoryByStoryId', storyId);
|
|
39717
|
+
// Get story referenceId from cache
|
|
39718
|
+
const cacheReferenceId = pullFromCache([
|
|
39719
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39720
|
+
storyId,
|
|
39721
|
+
]);
|
|
39722
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
39723
|
+
const { data: referenceId } = cacheReferenceId;
|
|
39724
|
+
isInTombstone('story', referenceId);
|
|
39725
|
+
}
|
|
39726
|
+
let data;
|
|
39727
|
+
try {
|
|
39728
|
+
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
39729
|
+
data = convertRawStoryToInternal(response.data);
|
|
39730
|
+
}
|
|
39731
|
+
catch (error) {
|
|
39732
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39733
|
+
pushToTombstone('story', storyId);
|
|
39734
|
+
}
|
|
39735
|
+
throw error;
|
|
39736
|
+
}
|
|
39737
|
+
const cachedAt = client.cache && Date.now();
|
|
39738
|
+
if (client.cache) {
|
|
39739
|
+
ingestInCache(data, { cachedAt });
|
|
39740
|
+
}
|
|
39741
|
+
return {
|
|
39742
|
+
data: data.stories[0],
|
|
39743
|
+
cachedAt,
|
|
39744
|
+
};
|
|
39745
|
+
};
|
|
39746
|
+
getStoryByStoryId$1.locally = (storyId) => {
|
|
39747
|
+
const client = getActiveClient();
|
|
39748
|
+
client.log('story/getStorybyStoryId', storyId);
|
|
39749
|
+
// Get story referenceId from cache
|
|
39750
|
+
const cacheReferenceId = pullFromCache([
|
|
39751
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39752
|
+
storyId,
|
|
39753
|
+
]);
|
|
39754
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
39755
|
+
const { data: referenceId } = cacheReferenceId;
|
|
39756
|
+
isInTombstone('story', referenceId);
|
|
39757
|
+
}
|
|
39758
|
+
const cachedAt = client.cache && Date.now();
|
|
39759
|
+
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
39760
|
+
if (!storyCache)
|
|
39761
|
+
return;
|
|
39762
|
+
return {
|
|
39763
|
+
data: storyCache.data,
|
|
39764
|
+
cachedAt,
|
|
39765
|
+
};
|
|
39766
|
+
};
|
|
39767
|
+
|
|
39768
|
+
/* begin_public_function
|
|
39769
|
+
id: comment.soft_delete, comment.hard_delete
|
|
39770
|
+
*/
|
|
39582
39771
|
/**
|
|
39583
39772
|
* ```js
|
|
39584
|
-
* import {
|
|
39585
|
-
* const success = await
|
|
39773
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39774
|
+
* const success = await CommentRepository.deleteComment('foobar')
|
|
39586
39775
|
* ```
|
|
39587
39776
|
*
|
|
39588
|
-
* Deletes a {@link Amity.
|
|
39777
|
+
* Deletes a {@link Amity.Comment}
|
|
39589
39778
|
*
|
|
39590
|
-
* @param
|
|
39591
|
-
* @return A success boolean if the {@link Amity.
|
|
39779
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39780
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39592
39781
|
*
|
|
39593
|
-
* @
|
|
39782
|
+
* @category Comment API
|
|
39594
39783
|
* @async
|
|
39595
39784
|
*/
|
|
39596
|
-
const
|
|
39785
|
+
const deleteComment = async (commentId, permanent = false) => {
|
|
39597
39786
|
var _a;
|
|
39598
39787
|
const client = getActiveClient();
|
|
39599
|
-
const
|
|
39600
|
-
|
|
39788
|
+
const comment = await getComment$2(commentId);
|
|
39789
|
+
// API-FIX: This endpoint has not been implemented yet.
|
|
39790
|
+
await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
|
|
39601
39791
|
params: {
|
|
39602
|
-
|
|
39792
|
+
commentId,
|
|
39603
39793
|
permanent,
|
|
39604
39794
|
},
|
|
39605
39795
|
});
|
|
39606
|
-
//
|
|
39607
|
-
|
|
39608
|
-
|
|
39609
|
-
|
|
39610
|
-
|
|
39611
|
-
|
|
39612
|
-
|
|
39613
|
-
|
|
39614
|
-
|
|
39615
|
-
|
|
39616
|
-
|
|
39617
|
-
|
|
39618
|
-
if (key[1] !== 'get')
|
|
39619
|
-
return false;
|
|
39620
|
-
if (typeof key[2] === 'string')
|
|
39621
|
-
return key[2].includes(community.data.communityId);
|
|
39622
|
-
return false;
|
|
39623
|
-
})
|
|
39624
|
-
.map(({ data }) => data);
|
|
39625
|
-
fireEvent('community.updated', {
|
|
39626
|
-
communities: [community.data],
|
|
39796
|
+
// to support hard deletion
|
|
39797
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
39798
|
+
if (permanent) {
|
|
39799
|
+
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
39800
|
+
}
|
|
39801
|
+
else {
|
|
39802
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
39803
|
+
}
|
|
39804
|
+
if (comment.data.referenceType === 'story') {
|
|
39805
|
+
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
39806
|
+
fireEvent('local.story.updated', {
|
|
39807
|
+
stories: [story.data],
|
|
39627
39808
|
categories: [],
|
|
39628
|
-
|
|
39629
|
-
|
|
39809
|
+
comments: [],
|
|
39810
|
+
communities: [],
|
|
39811
|
+
communityUsers: [],
|
|
39630
39812
|
files: [],
|
|
39631
39813
|
users: [],
|
|
39632
39814
|
});
|
|
39633
39815
|
}
|
|
39634
|
-
// to support hard deletion
|
|
39635
|
-
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
39636
|
-
if (permanent) {
|
|
39637
|
-
setTimeout(() => {
|
|
39638
|
-
pushToTombstone('post', postId);
|
|
39639
|
-
}, 0);
|
|
39640
|
-
}
|
|
39641
39816
|
else {
|
|
39642
|
-
|
|
39817
|
+
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39818
|
+
if (post) {
|
|
39819
|
+
let removeCount;
|
|
39820
|
+
if (!deleted.parentId) {
|
|
39821
|
+
// NOTE: delete the parent comment will remove all children comments
|
|
39822
|
+
removeCount = deleted.childrenNumber + 1;
|
|
39823
|
+
}
|
|
39824
|
+
else
|
|
39825
|
+
removeCount = 1;
|
|
39826
|
+
post.commentsCount -= removeCount;
|
|
39827
|
+
fireEvent('local.post.updated', {
|
|
39828
|
+
posts: [post],
|
|
39829
|
+
categories: [],
|
|
39830
|
+
comments: [],
|
|
39831
|
+
communities: [],
|
|
39832
|
+
communityUsers: [],
|
|
39833
|
+
feeds: [],
|
|
39834
|
+
files: [],
|
|
39835
|
+
postChildren: [],
|
|
39836
|
+
users: [],
|
|
39837
|
+
videoStreamings: [],
|
|
39838
|
+
});
|
|
39839
|
+
}
|
|
39643
39840
|
}
|
|
39644
|
-
fireEvent('local.
|
|
39645
|
-
|
|
39646
|
-
|
|
39647
|
-
comments: [],
|
|
39648
|
-
communities: [],
|
|
39649
|
-
communityUsers: [],
|
|
39650
|
-
feeds: [],
|
|
39841
|
+
fireEvent('local.comment.deleted', {
|
|
39842
|
+
comments: [deleted],
|
|
39843
|
+
commentChildren: [],
|
|
39651
39844
|
files: [],
|
|
39652
|
-
postChildren: [],
|
|
39653
39845
|
users: [],
|
|
39654
|
-
|
|
39846
|
+
communityUsers: [],
|
|
39655
39847
|
});
|
|
39656
|
-
return
|
|
39657
|
-
};
|
|
39658
|
-
|
|
39659
|
-
/* begin_public_function
|
|
39660
|
-
id: post.soft_delete
|
|
39661
|
-
*/
|
|
39662
|
-
/**
|
|
39663
|
-
* ```js
|
|
39664
|
-
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
39665
|
-
* const success = await PostRepository.softDeletePost('foobar')
|
|
39666
|
-
* ```
|
|
39667
|
-
*
|
|
39668
|
-
* Soft deletes a {@link Amity.Post}
|
|
39669
|
-
*
|
|
39670
|
-
* @param postId The {@link Amity.Post} ID to soft delete
|
|
39671
|
-
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
39672
|
-
*
|
|
39673
|
-
* @category Post API
|
|
39674
|
-
* @async
|
|
39675
|
-
*/
|
|
39676
|
-
const softDeletePost = async (postId) => {
|
|
39677
|
-
const client = getActiveClient();
|
|
39678
|
-
client.log('post/softDeletePost', postId);
|
|
39679
|
-
const softDeleted = await deletePost(postId, false);
|
|
39680
|
-
return LinkedObject.post(softDeleted);
|
|
39681
|
-
};
|
|
39682
|
-
/* end_public_function */
|
|
39683
|
-
|
|
39684
|
-
/* begin_public_function
|
|
39685
|
-
id: post.hard_delete
|
|
39686
|
-
*/
|
|
39687
|
-
/**
|
|
39688
|
-
* ```js
|
|
39689
|
-
* import { hardDeletePost } from '@amityco/ts-sdk-react-native'
|
|
39690
|
-
* const success = await hardDeletePost('foobar')
|
|
39691
|
-
* ```
|
|
39692
|
-
*
|
|
39693
|
-
* Hard deletes a {@link Amity.Post}
|
|
39694
|
-
*
|
|
39695
|
-
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
39696
|
-
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
39697
|
-
*
|
|
39698
|
-
* @category Post API
|
|
39699
|
-
* @async
|
|
39700
|
-
*/
|
|
39701
|
-
const hardDeletePost = async (postId) => {
|
|
39702
|
-
const client = getActiveClient();
|
|
39703
|
-
client.log('post/hardDeletePost', postId);
|
|
39704
|
-
const hardDeleted = await deletePost(postId, true);
|
|
39705
|
-
return LinkedObject.post(hardDeleted);
|
|
39848
|
+
return deleted;
|
|
39706
39849
|
};
|
|
39707
39850
|
/* end_public_function */
|
|
39708
39851
|
|
|
39709
39852
|
/* begin_public_function
|
|
39710
|
-
id:
|
|
39853
|
+
id: comment.soft_delete
|
|
39711
39854
|
*/
|
|
39712
39855
|
/**
|
|
39713
39856
|
* ```js
|
|
39714
|
-
* import {
|
|
39715
|
-
*
|
|
39716
|
-
* const { data: post } = await approvePost('postId')
|
|
39857
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39858
|
+
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
39717
39859
|
* ```
|
|
39718
39860
|
*
|
|
39719
|
-
*
|
|
39861
|
+
* Deletes a {@link Amity.Comment}
|
|
39720
39862
|
*
|
|
39721
|
-
* @param
|
|
39722
|
-
* @return A {@link Amity.
|
|
39863
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39864
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39723
39865
|
*
|
|
39724
|
-
* @category
|
|
39866
|
+
* @category Comment API
|
|
39725
39867
|
* @async
|
|
39726
39868
|
*/
|
|
39727
|
-
const
|
|
39869
|
+
const softDeleteComment = async (commentId) => {
|
|
39728
39870
|
const client = getActiveClient();
|
|
39729
|
-
client.log('
|
|
39730
|
-
const
|
|
39731
|
-
|
|
39732
|
-
// fire virtual event for community update
|
|
39733
|
-
if (payload.posts[0].targetType === 'community') {
|
|
39734
|
-
fireEvent('community.updated', payload);
|
|
39735
|
-
}
|
|
39736
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39737
|
-
const cachedAt = client.cache && Date.now();
|
|
39738
|
-
if (client.cache)
|
|
39739
|
-
ingestInCache(data, { cachedAt });
|
|
39740
|
-
return {
|
|
39741
|
-
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
39742
|
-
cachedAt,
|
|
39743
|
-
};
|
|
39871
|
+
client.log('comment/softDeleteComment', commentId);
|
|
39872
|
+
const softDeleted = deleteComment(commentId);
|
|
39873
|
+
return softDeleted;
|
|
39744
39874
|
};
|
|
39745
39875
|
/* end_public_function */
|
|
39746
39876
|
|
|
39747
39877
|
/* begin_public_function
|
|
39748
|
-
id:
|
|
39878
|
+
id: comment.hard_delete
|
|
39749
39879
|
*/
|
|
39750
39880
|
/**
|
|
39751
39881
|
* ```js
|
|
39752
|
-
* import {
|
|
39753
|
-
*
|
|
39754
|
-
* const {data: post} = await declinePost('postId')
|
|
39882
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39883
|
+
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
39755
39884
|
* ```
|
|
39756
39885
|
*
|
|
39757
|
-
*
|
|
39886
|
+
* Deletes a {@link Amity.Comment}
|
|
39758
39887
|
*
|
|
39759
|
-
* @param
|
|
39760
|
-
* @return A {@link Amity.
|
|
39888
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39889
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39761
39890
|
*
|
|
39762
|
-
* @category
|
|
39891
|
+
* @category Comment API
|
|
39763
39892
|
* @async
|
|
39764
39893
|
*/
|
|
39765
|
-
const
|
|
39894
|
+
const hardDeleteComment = async (commentId) => {
|
|
39766
39895
|
const client = getActiveClient();
|
|
39767
|
-
client.log('
|
|
39768
|
-
const
|
|
39769
|
-
|
|
39770
|
-
if (payload.posts[0].targetType === 'community') {
|
|
39771
|
-
fireEvent('community.updated', payload);
|
|
39772
|
-
}
|
|
39773
|
-
fireEvent('post.declined', payload);
|
|
39774
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39775
|
-
const cachedAt = client.cache && Date.now();
|
|
39776
|
-
if (client.cache)
|
|
39777
|
-
ingestInCache(data, { cachedAt });
|
|
39778
|
-
return {
|
|
39779
|
-
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
39780
|
-
cachedAt,
|
|
39781
|
-
};
|
|
39896
|
+
client.log('comment/hardDeleteComment', commentId);
|
|
39897
|
+
const hardDeleted = deleteComment(commentId, true);
|
|
39898
|
+
return hardDeleted;
|
|
39782
39899
|
};
|
|
39783
39900
|
/* end_public_function */
|
|
39784
39901
|
|
|
39785
39902
|
/* begin_public_function
|
|
39786
|
-
id:
|
|
39903
|
+
id: comment.flag
|
|
39787
39904
|
*/
|
|
39788
39905
|
/**
|
|
39789
39906
|
* ```js
|
|
39790
|
-
* import {
|
|
39791
|
-
* const flagged = await
|
|
39907
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39908
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
39792
39909
|
* ```
|
|
39793
39910
|
*
|
|
39794
|
-
* @param
|
|
39795
|
-
* @param reason the reason to flag the
|
|
39796
|
-
* @returns
|
|
39911
|
+
* @param commentId The ID of the comment to flag
|
|
39912
|
+
* @param reason the reason to flag the comment
|
|
39913
|
+
* @returns the created report result
|
|
39797
39914
|
*
|
|
39798
|
-
* @category
|
|
39915
|
+
* @category Comment API
|
|
39799
39916
|
* @async
|
|
39800
39917
|
* */
|
|
39801
|
-
const
|
|
39918
|
+
const flagComment = async (commentId, reason) => {
|
|
39802
39919
|
const client = getActiveClient();
|
|
39803
|
-
client.log('
|
|
39920
|
+
client.log('comment/flagComment', commentId);
|
|
39804
39921
|
const isPredefinedReason = reason &&
|
|
39805
39922
|
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
39806
39923
|
const body = {
|
|
39807
39924
|
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
39808
39925
|
detail: reason && !isPredefinedReason ? reason : '',
|
|
39809
39926
|
};
|
|
39810
|
-
const { data: payload } = await client.http.post(`/api/v3/
|
|
39927
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
39811
39928
|
if (client.cache) {
|
|
39812
|
-
ingestInCache(
|
|
39929
|
+
ingestInCache(payload);
|
|
39813
39930
|
}
|
|
39814
|
-
fireEvent('
|
|
39931
|
+
fireEvent('comment.flagged', payload);
|
|
39815
39932
|
return !!payload;
|
|
39816
39933
|
};
|
|
39817
39934
|
/* end_public_function */
|
|
39818
39935
|
|
|
39819
39936
|
/* begin_public_function
|
|
39820
|
-
id:
|
|
39937
|
+
id: comment.unflag
|
|
39821
39938
|
*/
|
|
39822
39939
|
/**
|
|
39823
39940
|
* ```js
|
|
39824
|
-
* import {
|
|
39825
|
-
* const unflagged = await
|
|
39941
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39942
|
+
* const unflagged = await CommentRepository.unflagComment('commentId')
|
|
39826
39943
|
* ```
|
|
39827
39944
|
*
|
|
39828
|
-
* @param
|
|
39829
|
-
* @returns the
|
|
39945
|
+
* @param commentId The ID of comment to unflag
|
|
39946
|
+
* @returns the unflagged result
|
|
39830
39947
|
*
|
|
39831
|
-
* @category
|
|
39948
|
+
* @category Comment API
|
|
39832
39949
|
* @async
|
|
39833
39950
|
* */
|
|
39834
|
-
const
|
|
39951
|
+
const unflagComment = async (commentId) => {
|
|
39835
39952
|
const client = getActiveClient();
|
|
39836
|
-
client.log('
|
|
39837
|
-
const { data: payload } = await client.http.delete(`/api/v3/
|
|
39953
|
+
client.log('comment/unflagComment', commentId);
|
|
39954
|
+
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
39838
39955
|
if (client.cache) {
|
|
39839
|
-
ingestInCache(
|
|
39956
|
+
ingestInCache(payload);
|
|
39840
39957
|
}
|
|
39841
|
-
fireEvent('
|
|
39958
|
+
fireEvent('comment.unflagged', payload);
|
|
39842
39959
|
return !!payload;
|
|
39843
39960
|
};
|
|
39844
39961
|
/* end_public_function */
|
|
39845
39962
|
|
|
39846
39963
|
/* begin_public_function
|
|
39847
|
-
id:
|
|
39964
|
+
id: comment.check_flag_by_me
|
|
39848
39965
|
*/
|
|
39849
39966
|
/**
|
|
39850
39967
|
* ```js
|
|
39851
|
-
* import {
|
|
39852
|
-
* const isReported = await
|
|
39968
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39969
|
+
* const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
|
|
39853
39970
|
* ```
|
|
39854
39971
|
*
|
|
39855
|
-
* @param
|
|
39856
|
-
* @returns `true` if the
|
|
39972
|
+
* @param commentId The ID of the comment to check if flagged by current user
|
|
39973
|
+
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
39857
39974
|
*
|
|
39858
|
-
* @category
|
|
39975
|
+
* @category Comment API
|
|
39859
39976
|
* @async
|
|
39860
39977
|
* */
|
|
39861
|
-
const
|
|
39978
|
+
const isCommentFlaggedByMe = async (commentId) => {
|
|
39862
39979
|
const client = getActiveClient();
|
|
39863
|
-
client.log('
|
|
39864
|
-
const { data: { result }, } = await client.http.get(`/api/v3/
|
|
39980
|
+
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
39981
|
+
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
39865
39982
|
return result;
|
|
39866
39983
|
};
|
|
39867
39984
|
/* end_public_function */
|
|
39868
39985
|
|
|
39869
|
-
|
|
39870
|
-
id: post.create.clip_post
|
|
39871
|
-
*/
|
|
39872
|
-
/**
|
|
39873
|
-
* ```js
|
|
39874
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
39875
|
-
* const created = await PostRepository.createClipPost({
|
|
39876
|
-
* targetType: 'user',
|
|
39877
|
-
* targetId: 'foobar',
|
|
39878
|
-
* dataType: 'clip',
|
|
39879
|
-
* data: { text: 'hello world' },
|
|
39880
|
-
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
39881
|
-
* }))
|
|
39882
|
-
* ```
|
|
39883
|
-
*
|
|
39884
|
-
* Creates an {@link Amity.Post}
|
|
39885
|
-
*
|
|
39886
|
-
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
39887
|
-
* @returns The newly created {@link Amity.Post}
|
|
39888
|
-
*
|
|
39889
|
-
* @category Post API
|
|
39890
|
-
* @async
|
|
39891
|
-
*/
|
|
39892
|
-
const createClipPost = async (bundle) => {
|
|
39893
|
-
const client = getActiveClient();
|
|
39894
|
-
client.log('post/createPost', bundle);
|
|
39895
|
-
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
39896
|
-
fireEvent('post.created', payload);
|
|
39897
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39898
|
-
const cachedAt = client.cache && Date.now();
|
|
39899
|
-
if (client.cache)
|
|
39900
|
-
ingestInCache(data, { cachedAt });
|
|
39901
|
-
const { posts } = data;
|
|
39902
|
-
return {
|
|
39903
|
-
data: LinkedObject.post(posts[0]),
|
|
39904
|
-
cachedAt,
|
|
39905
|
-
};
|
|
39906
|
-
};
|
|
39907
|
-
/* end_public_function */
|
|
39908
|
-
|
|
39909
|
-
/* begin_public_function
|
|
39910
|
-
id: comment.get_by_ids
|
|
39911
|
-
*/
|
|
39912
|
-
/**
|
|
39913
|
-
* ```js
|
|
39914
|
-
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
39915
|
-
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
39916
|
-
* ```
|
|
39917
|
-
*
|
|
39918
|
-
* Fetches a collection of {@link Amity.Comment} objects
|
|
39919
|
-
*
|
|
39920
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39921
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39922
|
-
*
|
|
39923
|
-
* @category Comment API
|
|
39924
|
-
* @async
|
|
39925
|
-
*/
|
|
39926
|
-
const getCommentByIds = async (commentIds) => {
|
|
39986
|
+
const getComment$1 = async (commentId) => {
|
|
39927
39987
|
const client = getActiveClient();
|
|
39928
|
-
client.log('comment/
|
|
39929
|
-
|
|
39988
|
+
client.log('comment/getComment', commentId);
|
|
39989
|
+
isInTombstone('comment', commentId);
|
|
39930
39990
|
let data;
|
|
39931
39991
|
try {
|
|
39932
39992
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
39933
|
-
const response = await client.http.get(`/api/v3/comments
|
|
39934
|
-
params: { commentIds: encodedCommentIds },
|
|
39935
|
-
});
|
|
39993
|
+
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
39936
39994
|
data = response.data;
|
|
39937
39995
|
}
|
|
39938
39996
|
catch (error) {
|
|
39939
|
-
|
|
39940
|
-
|
|
39941
|
-
|
|
39942
|
-
}
|
|
39943
|
-
});
|
|
39997
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39998
|
+
pushToTombstone('comment', commentId);
|
|
39999
|
+
}
|
|
39944
40000
|
throw error;
|
|
39945
40001
|
}
|
|
39946
40002
|
const cachedAt = client.cache && Date.now();
|
|
39947
40003
|
if (client.cache)
|
|
39948
40004
|
ingestInCache(data, { cachedAt });
|
|
40005
|
+
const { comments } = data;
|
|
39949
40006
|
return {
|
|
39950
|
-
data:
|
|
40007
|
+
data: comments.find(comment => comment.commentId === commentId),
|
|
39951
40008
|
cachedAt,
|
|
39952
40009
|
};
|
|
39953
40010
|
};
|
|
39954
|
-
|
|
39955
|
-
/**
|
|
39956
|
-
* ```js
|
|
39957
|
-
* import { getCommentByIds } from '@amityco/ts-sdk-react-native'
|
|
39958
|
-
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
39959
|
-
* ```
|
|
39960
|
-
*
|
|
39961
|
-
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
39962
|
-
*
|
|
39963
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39964
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39965
|
-
*
|
|
39966
|
-
* @category Comment API
|
|
39967
|
-
*/
|
|
39968
|
-
getCommentByIds.locally = (commentIds) => {
|
|
39969
|
-
var _a;
|
|
40011
|
+
getComment$1.locally = (commentId) => {
|
|
39970
40012
|
const client = getActiveClient();
|
|
39971
|
-
client.log('comment/
|
|
40013
|
+
client.log('comment/getComment.locally', commentId);
|
|
39972
40014
|
if (!client.cache)
|
|
39973
40015
|
return;
|
|
39974
|
-
const cached =
|
|
39975
|
-
|
|
39976
|
-
.filter(Boolean);
|
|
39977
|
-
const comments = cached.map(({ data }) => data);
|
|
39978
|
-
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
39979
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
40016
|
+
const cached = pullFromCache(['comment', 'get', commentId]);
|
|
40017
|
+
if (!cached)
|
|
39980
40018
|
return;
|
|
39981
40019
|
return {
|
|
39982
|
-
data:
|
|
39983
|
-
cachedAt:
|
|
40020
|
+
data: cached.data,
|
|
40021
|
+
cachedAt: cached.cachedAt,
|
|
39984
40022
|
};
|
|
39985
40023
|
};
|
|
39986
40024
|
|
|
39987
|
-
/* begin_public_function
|
|
39988
|
-
id: comment.create
|
|
39989
|
-
*/
|
|
39990
40025
|
/**
|
|
39991
40026
|
* ```js
|
|
39992
|
-
* import {
|
|
39993
|
-
* const
|
|
40027
|
+
* import { onCommentDeleteLocal } from '@amityco/ts-sdk-react-native'
|
|
40028
|
+
* const dispose = onCommentDeleteLocal(comment => {
|
|
40029
|
+
* // ...
|
|
40030
|
+
* })
|
|
39994
40031
|
* ```
|
|
39995
40032
|
*
|
|
39996
|
-
*
|
|
40033
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
39997
40034
|
*
|
|
39998
|
-
* @param
|
|
39999
|
-
* @returns
|
|
40035
|
+
* @param callback The function to call when the event was fired
|
|
40036
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40000
40037
|
*
|
|
40001
|
-
* @category Comment
|
|
40002
|
-
* @async
|
|
40038
|
+
* @category Comment Events
|
|
40003
40039
|
*/
|
|
40004
|
-
const
|
|
40005
|
-
|
|
40040
|
+
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
40041
|
+
|
|
40042
|
+
/**
|
|
40043
|
+
* ```js
|
|
40044
|
+
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk-react-native'
|
|
40045
|
+
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
40046
|
+
* // ...
|
|
40047
|
+
* })
|
|
40048
|
+
* ```
|
|
40049
|
+
*
|
|
40050
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
40051
|
+
*
|
|
40052
|
+
* @param callback The function to call when the event was fired
|
|
40053
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40054
|
+
*
|
|
40055
|
+
* @category Comment Events
|
|
40056
|
+
*/
|
|
40057
|
+
const onLocalCommentReactionAdded = (callback) => {
|
|
40006
40058
|
const client = getActiveClient();
|
|
40007
|
-
|
|
40008
|
-
|
|
40009
|
-
|
|
40010
|
-
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
40011
|
-
if (comments.length === 0)
|
|
40012
|
-
throw new Error('Comment not created');
|
|
40013
|
-
const cachedAt = client.cache && Date.now();
|
|
40014
|
-
if (client.cache)
|
|
40015
|
-
ingestInCache(data, { cachedAt });
|
|
40016
|
-
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
40017
|
-
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40018
|
-
if (post) {
|
|
40019
|
-
post.commentsCount += 1;
|
|
40020
|
-
fireEvent('local.post.updated', {
|
|
40021
|
-
posts: [post],
|
|
40022
|
-
categories: [],
|
|
40023
|
-
comments: [],
|
|
40024
|
-
communities: [],
|
|
40025
|
-
communityUsers: data.communityUsers,
|
|
40026
|
-
feeds: [],
|
|
40027
|
-
files: data.files,
|
|
40028
|
-
postChildren: [],
|
|
40029
|
-
users: data.users,
|
|
40030
|
-
videoStreamings: [],
|
|
40031
|
-
});
|
|
40059
|
+
const filter = ({ comment }) => {
|
|
40060
|
+
if (!client.cache) {
|
|
40061
|
+
callback(comment);
|
|
40032
40062
|
}
|
|
40033
|
-
|
|
40034
|
-
|
|
40035
|
-
|
|
40036
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
40037
|
-
bundle.referenceId,
|
|
40038
|
-
]);
|
|
40039
|
-
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
40040
|
-
const cacheStory = pullFromCache([
|
|
40041
|
-
"story" /* STORY_KEY_CACHE.STORY */,
|
|
40042
|
-
'get',
|
|
40043
|
-
storyIndex.data,
|
|
40044
|
-
]);
|
|
40045
|
-
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
40046
|
-
fireEvent('story.updated', {
|
|
40047
|
-
stories: [
|
|
40048
|
-
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
40049
|
-
],
|
|
40050
|
-
categories: [],
|
|
40051
|
-
comments,
|
|
40052
|
-
communities: [],
|
|
40053
|
-
communityUsers: data.communityUsers,
|
|
40054
|
-
files: data.files,
|
|
40055
|
-
users: data.users,
|
|
40056
|
-
});
|
|
40057
|
-
}
|
|
40063
|
+
else {
|
|
40064
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
40065
|
+
callback(commentLinkedObject(comment));
|
|
40058
40066
|
}
|
|
40059
|
-
}
|
|
40060
|
-
fireEvent('local.comment.created', data);
|
|
40061
|
-
return {
|
|
40062
|
-
data: LinkedObject.comment(comments[0]),
|
|
40063
|
-
cachedAt,
|
|
40064
40067
|
};
|
|
40068
|
+
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
40065
40069
|
};
|
|
40066
|
-
/* end_public_function */
|
|
40067
40070
|
|
|
40068
|
-
/* begin_public_function
|
|
40069
|
-
id: comment.update_comment
|
|
40070
|
-
*/
|
|
40071
40071
|
/**
|
|
40072
40072
|
* ```js
|
|
40073
|
-
* import {
|
|
40074
|
-
* const
|
|
40075
|
-
*
|
|
40073
|
+
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk-react-native'
|
|
40074
|
+
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
40075
|
+
* // ...
|
|
40076
40076
|
* })
|
|
40077
40077
|
* ```
|
|
40078
40078
|
*
|
|
40079
|
-
*
|
|
40079
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
40080
40080
|
*
|
|
40081
|
-
* @param
|
|
40082
|
-
* @
|
|
40083
|
-
* @returns the updated {@link Amity.Comment} object
|
|
40081
|
+
* @param callback The function to call when the event was fired
|
|
40082
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40084
40083
|
*
|
|
40085
|
-
* @category Comment
|
|
40086
|
-
* @async
|
|
40084
|
+
* @category Comment Events
|
|
40087
40085
|
*/
|
|
40088
|
-
const
|
|
40089
|
-
const client = getActiveClient();
|
|
40090
|
-
client.log('user/updateComment', patch);
|
|
40091
|
-
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
40092
|
-
const cachedAt = client.cache && Date.now();
|
|
40093
|
-
if (client.cache)
|
|
40094
|
-
ingestInCache(data, { cachedAt });
|
|
40095
|
-
fireEvent('comment.updated', data);
|
|
40096
|
-
const { comments } = data;
|
|
40097
|
-
return {
|
|
40098
|
-
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
40099
|
-
cachedAt,
|
|
40100
|
-
};
|
|
40101
|
-
};
|
|
40102
|
-
/* end_public_function */
|
|
40103
|
-
|
|
40104
|
-
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
40105
|
-
const applyMissingField = (rawData, isCreated = false) => {
|
|
40106
|
-
const { storyId, referenceId } = rawData;
|
|
40107
|
-
if (!isCreated) {
|
|
40108
|
-
if (referenceId)
|
|
40109
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
40110
|
-
}
|
|
40111
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
40112
|
-
};
|
|
40113
|
-
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
40114
|
-
const { stories } = data;
|
|
40115
|
-
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
40116
|
-
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
40117
|
-
};
|
|
40118
|
-
|
|
40119
|
-
const getStoryByStoryId$1 = async (storyId) => {
|
|
40086
|
+
const onLocalCommentReactionRemoved = (callback) => {
|
|
40120
40087
|
const client = getActiveClient();
|
|
40121
|
-
|
|
40122
|
-
|
|
40123
|
-
|
|
40124
|
-
|
|
40125
|
-
|
|
40126
|
-
|
|
40127
|
-
|
|
40128
|
-
const { data: referenceId } = cacheReferenceId;
|
|
40129
|
-
isInTombstone('story', referenceId);
|
|
40130
|
-
}
|
|
40131
|
-
let data;
|
|
40132
|
-
try {
|
|
40133
|
-
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
40134
|
-
data = convertRawStoryToInternal(response.data);
|
|
40135
|
-
}
|
|
40136
|
-
catch (error) {
|
|
40137
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40138
|
-
pushToTombstone('story', storyId);
|
|
40088
|
+
const filter = ({ comment }) => {
|
|
40089
|
+
if (!client.cache) {
|
|
40090
|
+
callback(comment);
|
|
40091
|
+
}
|
|
40092
|
+
else {
|
|
40093
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
40094
|
+
callback(commentLinkedObject(comment));
|
|
40139
40095
|
}
|
|
40140
|
-
throw error;
|
|
40141
|
-
}
|
|
40142
|
-
const cachedAt = client.cache && Date.now();
|
|
40143
|
-
if (client.cache) {
|
|
40144
|
-
ingestInCache(data, { cachedAt });
|
|
40145
|
-
}
|
|
40146
|
-
return {
|
|
40147
|
-
data: data.stories[0],
|
|
40148
|
-
cachedAt,
|
|
40149
|
-
};
|
|
40150
|
-
};
|
|
40151
|
-
getStoryByStoryId$1.locally = (storyId) => {
|
|
40152
|
-
const client = getActiveClient();
|
|
40153
|
-
client.log('story/getStorybyStoryId', storyId);
|
|
40154
|
-
// Get story referenceId from cache
|
|
40155
|
-
const cacheReferenceId = pullFromCache([
|
|
40156
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
40157
|
-
storyId,
|
|
40158
|
-
]);
|
|
40159
|
-
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
40160
|
-
const { data: referenceId } = cacheReferenceId;
|
|
40161
|
-
isInTombstone('story', referenceId);
|
|
40162
|
-
}
|
|
40163
|
-
const cachedAt = client.cache && Date.now();
|
|
40164
|
-
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
40165
|
-
if (!storyCache)
|
|
40166
|
-
return;
|
|
40167
|
-
return {
|
|
40168
|
-
data: storyCache.data,
|
|
40169
|
-
cachedAt,
|
|
40170
40096
|
};
|
|
40097
|
+
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
40171
40098
|
};
|
|
40172
40099
|
|
|
40173
40100
|
/* begin_public_function
|
|
40174
|
-
id: comment.
|
|
40101
|
+
id: comment.get
|
|
40175
40102
|
*/
|
|
40176
40103
|
/**
|
|
40177
40104
|
* ```js
|
|
40178
|
-
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
40179
|
-
* const success = await CommentRepository.deleteComment('foobar')
|
|
40180
|
-
* ```
|
|
40105
|
+
* import { CommentRepository } from '@amityco/ts-sdk-react-native';
|
|
40181
40106
|
*
|
|
40182
|
-
*
|
|
40107
|
+
* let comment;
|
|
40183
40108
|
*
|
|
40184
|
-
*
|
|
40185
|
-
*
|
|
40109
|
+
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
40110
|
+
* comment = response.data;
|
|
40111
|
+
* });
|
|
40112
|
+
* ```
|
|
40186
40113
|
*
|
|
40187
|
-
* @
|
|
40188
|
-
*
|
|
40114
|
+
* Observe all mutation on a given {@link Amity.Comment}
|
|
40115
|
+
*
|
|
40116
|
+
* @param commentId the ID of the comment to observe
|
|
40117
|
+
* @param callback the function to call when new data are available
|
|
40118
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
40119
|
+
*
|
|
40120
|
+
* @category Comment Live Object
|
|
40189
40121
|
*/
|
|
40190
|
-
const
|
|
40191
|
-
|
|
40192
|
-
|
|
40193
|
-
|
|
40194
|
-
|
|
40195
|
-
|
|
40196
|
-
|
|
40197
|
-
|
|
40198
|
-
|
|
40199
|
-
|
|
40200
|
-
|
|
40201
|
-
|
|
40202
|
-
|
|
40203
|
-
|
|
40204
|
-
|
|
40205
|
-
|
|
40206
|
-
|
|
40207
|
-
|
|
40208
|
-
|
|
40209
|
-
|
|
40210
|
-
|
|
40211
|
-
|
|
40212
|
-
|
|
40122
|
+
const getComment = (commentId, callback) => {
|
|
40123
|
+
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
40124
|
+
onCommentDeleteLocal,
|
|
40125
|
+
onCommentDeleted,
|
|
40126
|
+
onCommentFlagged,
|
|
40127
|
+
onCommentReactionAdded,
|
|
40128
|
+
onCommentReactionRemoved,
|
|
40129
|
+
onCommentUnflagged,
|
|
40130
|
+
onCommentUpdated,
|
|
40131
|
+
onLocalCommentReactionAdded,
|
|
40132
|
+
onLocalCommentReactionRemoved,
|
|
40133
|
+
]);
|
|
40134
|
+
};
|
|
40135
|
+
/* end_public_function */
|
|
40136
|
+
|
|
40137
|
+
class CommentPaginationController extends PaginationController {
|
|
40138
|
+
async getRequest(queryParams, token) {
|
|
40139
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
40140
|
+
const baseOptions = {
|
|
40141
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
40142
|
+
};
|
|
40143
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
40144
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
|
|
40145
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
40213
40146
|
});
|
|
40147
|
+
return queryResponse;
|
|
40214
40148
|
}
|
|
40215
|
-
|
|
40216
|
-
|
|
40217
|
-
|
|
40218
|
-
|
|
40219
|
-
|
|
40220
|
-
|
|
40221
|
-
|
|
40222
|
-
|
|
40223
|
-
|
|
40224
|
-
|
|
40225
|
-
|
|
40226
|
-
|
|
40227
|
-
|
|
40228
|
-
|
|
40229
|
-
|
|
40230
|
-
|
|
40231
|
-
|
|
40232
|
-
|
|
40233
|
-
|
|
40234
|
-
|
|
40235
|
-
|
|
40236
|
-
|
|
40149
|
+
}
|
|
40150
|
+
|
|
40151
|
+
var EnumCommentActions;
|
|
40152
|
+
(function (EnumCommentActions) {
|
|
40153
|
+
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
40154
|
+
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
40155
|
+
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
40156
|
+
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
40157
|
+
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
40158
|
+
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
40159
|
+
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
40160
|
+
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
40161
|
+
|
|
40162
|
+
class CommentQueryStreamController extends QueryStreamController {
|
|
40163
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40164
|
+
super(query, cacheKey);
|
|
40165
|
+
this.notifyChange = notifyChange;
|
|
40166
|
+
this.preparePayload = preparePayload;
|
|
40167
|
+
}
|
|
40168
|
+
async saveToMainDB(response) {
|
|
40169
|
+
const processedPayload = await this.preparePayload(response);
|
|
40170
|
+
const client = getActiveClient();
|
|
40171
|
+
const cachedAt = client.cache && Date.now();
|
|
40172
|
+
if (client.cache) {
|
|
40173
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
40174
|
+
}
|
|
40175
|
+
}
|
|
40176
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
40177
|
+
var _a, _b;
|
|
40178
|
+
if (refresh) {
|
|
40179
|
+
pushToCache(this.cacheKey, {
|
|
40180
|
+
data: response.comments.map(getResolver('comment')),
|
|
40237
40181
|
});
|
|
40238
40182
|
}
|
|
40183
|
+
else {
|
|
40184
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40185
|
+
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
40186
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
|
|
40187
|
+
}
|
|
40239
40188
|
}
|
|
40240
|
-
|
|
40241
|
-
|
|
40242
|
-
|
|
40243
|
-
|
|
40244
|
-
|
|
40245
|
-
|
|
40246
|
-
|
|
40247
|
-
|
|
40248
|
-
|
|
40189
|
+
reactor(action) {
|
|
40190
|
+
return (comment) => {
|
|
40191
|
+
var _a;
|
|
40192
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40193
|
+
if (this.query.referenceId !== comment.referenceId ||
|
|
40194
|
+
this.query.referenceType !== comment.referenceType ||
|
|
40195
|
+
!collection) {
|
|
40196
|
+
return;
|
|
40197
|
+
}
|
|
40198
|
+
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
40199
|
+
return;
|
|
40200
|
+
}
|
|
40201
|
+
if (!this.query.parentId && comment.parentId) {
|
|
40202
|
+
return;
|
|
40203
|
+
}
|
|
40204
|
+
if (action === EnumCommentActions.OnCommentCreated) {
|
|
40205
|
+
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
40206
|
+
}
|
|
40207
|
+
pushToCache(this.cacheKey, collection);
|
|
40208
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40209
|
+
};
|
|
40249
40210
|
}
|
|
40250
|
-
|
|
40251
|
-
|
|
40211
|
+
subscribeRTE(createSubscriber) {
|
|
40212
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40252
40213
|
}
|
|
40253
|
-
|
|
40254
|
-
};
|
|
40255
|
-
/* end_public_function */
|
|
40256
|
-
|
|
40257
|
-
/* begin_public_function
|
|
40258
|
-
id: comment.soft_delete
|
|
40259
|
-
*/
|
|
40260
|
-
/**
|
|
40261
|
-
* ```js
|
|
40262
|
-
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
40263
|
-
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
40264
|
-
* ```
|
|
40265
|
-
*
|
|
40266
|
-
* Deletes a {@link Amity.Comment}
|
|
40267
|
-
*
|
|
40268
|
-
* @param commentId The {@link Amity.Comment} ID to delete
|
|
40269
|
-
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
40270
|
-
*
|
|
40271
|
-
* @category Comment API
|
|
40272
|
-
* @async
|
|
40273
|
-
*/
|
|
40274
|
-
const softDeleteComment = async (commentId) => {
|
|
40275
|
-
const client = getActiveClient();
|
|
40276
|
-
client.log('comment/softDeleteComment', commentId);
|
|
40277
|
-
const softDeleted = deleteComment(commentId);
|
|
40278
|
-
return softDeleted;
|
|
40279
|
-
};
|
|
40280
|
-
/* end_public_function */
|
|
40214
|
+
}
|
|
40281
40215
|
|
|
40282
|
-
/* begin_public_function
|
|
40283
|
-
id: comment.hard_delete
|
|
40284
|
-
*/
|
|
40285
40216
|
/**
|
|
40286
40217
|
* ```js
|
|
40287
|
-
* import {
|
|
40288
|
-
* const
|
|
40218
|
+
* import { onCommentCreated } from '@amityco/ts-sdk-react-native'
|
|
40219
|
+
* const dispose = onCommentCreated(comment => {
|
|
40220
|
+
* // ...
|
|
40221
|
+
* })
|
|
40289
40222
|
* ```
|
|
40290
40223
|
*
|
|
40291
|
-
*
|
|
40224
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
40292
40225
|
*
|
|
40293
|
-
* @param
|
|
40294
|
-
* @
|
|
40226
|
+
* @param callback The function to call when the event was fired
|
|
40227
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40295
40228
|
*
|
|
40296
|
-
* @category Comment
|
|
40297
|
-
* @async
|
|
40229
|
+
* @category Comment Events
|
|
40298
40230
|
*/
|
|
40299
|
-
const
|
|
40300
|
-
|
|
40301
|
-
client.log('comment/hardDeleteComment', commentId);
|
|
40302
|
-
const hardDeleted = deleteComment(commentId, true);
|
|
40303
|
-
return hardDeleted;
|
|
40231
|
+
const onCommentCreatedLocal = (callback) => {
|
|
40232
|
+
return createLocalCommentEventSubscriber('local.comment.created', callback);
|
|
40304
40233
|
};
|
|
40305
|
-
/* end_public_function */
|
|
40306
40234
|
|
|
40307
|
-
|
|
40308
|
-
|
|
40309
|
-
|
|
40310
|
-
|
|
40311
|
-
|
|
40312
|
-
|
|
40313
|
-
|
|
40314
|
-
|
|
40315
|
-
|
|
40316
|
-
|
|
40317
|
-
* @param reason the reason to flag the comment
|
|
40318
|
-
* @returns the created report result
|
|
40319
|
-
*
|
|
40320
|
-
* @category Comment API
|
|
40321
|
-
* @async
|
|
40322
|
-
* */
|
|
40323
|
-
const flagComment = async (commentId, reason) => {
|
|
40324
|
-
const client = getActiveClient();
|
|
40325
|
-
client.log('comment/flagComment', commentId);
|
|
40326
|
-
const isPredefinedReason = reason &&
|
|
40327
|
-
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
40328
|
-
const body = {
|
|
40329
|
-
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
40330
|
-
detail: reason && !isPredefinedReason ? reason : '',
|
|
40331
|
-
};
|
|
40332
|
-
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
40333
|
-
if (client.cache) {
|
|
40334
|
-
ingestInCache(payload);
|
|
40235
|
+
class CommentLiveCollectionController extends LiveCollectionController {
|
|
40236
|
+
constructor(query, callback) {
|
|
40237
|
+
const queryStreamId = hash(query);
|
|
40238
|
+
const cacheKey = ['comments', 'collection', queryStreamId];
|
|
40239
|
+
const paginationController = new CommentPaginationController(query);
|
|
40240
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40241
|
+
this.query = query;
|
|
40242
|
+
this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
|
|
40243
|
+
this.callback = callback.bind(this);
|
|
40244
|
+
this.loadPage({ initial: true });
|
|
40335
40245
|
}
|
|
40336
|
-
|
|
40337
|
-
|
|
40338
|
-
|
|
40339
|
-
|
|
40246
|
+
setup() {
|
|
40247
|
+
var _a;
|
|
40248
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40249
|
+
if (!collection) {
|
|
40250
|
+
pushToCache(this.cacheKey, {
|
|
40251
|
+
data: [],
|
|
40252
|
+
params: {},
|
|
40253
|
+
});
|
|
40254
|
+
}
|
|
40255
|
+
}
|
|
40256
|
+
async persistModel(queryPayload) {
|
|
40257
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40258
|
+
}
|
|
40259
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40260
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40261
|
+
}
|
|
40262
|
+
startSubscription() {
|
|
40263
|
+
return this.queryStreamController.subscribeRTE([
|
|
40264
|
+
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
40265
|
+
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
40266
|
+
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
40267
|
+
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
40268
|
+
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
40269
|
+
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
40270
|
+
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
40271
|
+
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40272
|
+
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40273
|
+
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40274
|
+
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40275
|
+
]);
|
|
40276
|
+
}
|
|
40277
|
+
notifyChange({ origin, loading, error }) {
|
|
40278
|
+
var _a, _b;
|
|
40279
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40280
|
+
if (!collection)
|
|
40281
|
+
return;
|
|
40282
|
+
const data = this.applyFilter((_b = collection.data
|
|
40283
|
+
.map(id => pullFromCache(['comment', 'get', id]))
|
|
40284
|
+
.filter(isNonNullable)
|
|
40285
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
40286
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40287
|
+
return;
|
|
40288
|
+
this.callback({
|
|
40289
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40290
|
+
data,
|
|
40291
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40292
|
+
loading,
|
|
40293
|
+
error,
|
|
40294
|
+
});
|
|
40295
|
+
}
|
|
40296
|
+
applyFilter(data) {
|
|
40297
|
+
let comments = data;
|
|
40298
|
+
if (!this.query.includeDeleted) {
|
|
40299
|
+
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
40300
|
+
}
|
|
40301
|
+
if (this.query.parentId) {
|
|
40302
|
+
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
40303
|
+
}
|
|
40304
|
+
if (typeof this.query.hasFlag === 'boolean') {
|
|
40305
|
+
if (this.query.hasFlag) {
|
|
40306
|
+
comments = comments.filter(comment => comment.hashFlag != null);
|
|
40307
|
+
}
|
|
40308
|
+
else {
|
|
40309
|
+
comments = comments.filter(comment => comment.hashFlag == null);
|
|
40310
|
+
}
|
|
40311
|
+
}
|
|
40312
|
+
if (this.query.dataTypes) {
|
|
40313
|
+
if (this.query.dataTypes.matchType === 'exact') {
|
|
40314
|
+
comments = comments.filter(comment => {
|
|
40315
|
+
var _a, _b;
|
|
40316
|
+
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
40317
|
+
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
40318
|
+
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
40319
|
+
return false;
|
|
40320
|
+
}
|
|
40321
|
+
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
40322
|
+
});
|
|
40323
|
+
}
|
|
40324
|
+
if (this.query.dataTypes.matchType === 'any') {
|
|
40325
|
+
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); }); });
|
|
40326
|
+
}
|
|
40327
|
+
}
|
|
40328
|
+
switch (this.query.sortBy) {
|
|
40329
|
+
case 'firstCreated':
|
|
40330
|
+
comments = comments.sort(sortByFirstCreated);
|
|
40331
|
+
break;
|
|
40332
|
+
case 'lastCreated':
|
|
40333
|
+
default:
|
|
40334
|
+
comments = comments.sort(sortByLastCreated);
|
|
40335
|
+
break;
|
|
40336
|
+
}
|
|
40337
|
+
return comments;
|
|
40338
|
+
}
|
|
40339
|
+
}
|
|
40340
40340
|
|
|
40341
40341
|
/* begin_public_function
|
|
40342
|
-
id: comment.
|
|
40342
|
+
id: comment.query
|
|
40343
40343
|
*/
|
|
40344
40344
|
/**
|
|
40345
40345
|
* ```js
|
|
40346
|
-
* import {
|
|
40347
|
-
*
|
|
40346
|
+
* import { getComments } from '@amityco/ts-sdk-react-native'
|
|
40347
|
+
*
|
|
40348
|
+
* let comments = []
|
|
40349
|
+
* const unsub = getComments({
|
|
40350
|
+
* referenceType: Amity.InternalComment['referenceType'];
|
|
40351
|
+
* referenceId: Amity.InternalComment['referenceId'];
|
|
40352
|
+
* }, response => merge(comments, response.data))
|
|
40348
40353
|
* ```
|
|
40349
40354
|
*
|
|
40350
|
-
*
|
|
40351
|
-
* @returns the unflagged result
|
|
40355
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
|
|
40352
40356
|
*
|
|
40353
|
-
* @
|
|
40354
|
-
* @
|
|
40355
|
-
*
|
|
40356
|
-
|
|
40357
|
-
|
|
40358
|
-
|
|
40359
|
-
|
|
40360
|
-
|
|
40361
|
-
|
|
40357
|
+
* @param referenceType the type of the target
|
|
40358
|
+
* @param referenceId the ID of the target
|
|
40359
|
+
* @param callback the function to call when new data are available
|
|
40360
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40361
|
+
*
|
|
40362
|
+
* @category Comments Live Collection
|
|
40363
|
+
*/
|
|
40364
|
+
const getComments = (params, callback, config) => {
|
|
40365
|
+
const { log, cache } = getActiveClient();
|
|
40366
|
+
if (!cache) {
|
|
40367
|
+
console.log('For using Live Collection feature you need to enable Cache!');
|
|
40362
40368
|
}
|
|
40363
|
-
|
|
40364
|
-
|
|
40369
|
+
const timestamp = Date.now();
|
|
40370
|
+
log(`getComments(tmpid: ${timestamp}) > listen`);
|
|
40371
|
+
const commentsLiveCollection = new CommentLiveCollectionController(params, callback);
|
|
40372
|
+
const disposers = commentsLiveCollection.startSubscription();
|
|
40373
|
+
const cacheKey = commentsLiveCollection.getCacheKey();
|
|
40374
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40375
|
+
return () => {
|
|
40376
|
+
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
40377
|
+
disposers.forEach(fn => fn());
|
|
40378
|
+
};
|
|
40365
40379
|
};
|
|
40366
40380
|
/* end_public_function */
|
|
40367
40381
|
|
|
40368
|
-
|
|
40369
|
-
|
|
40370
|
-
|
|
40371
|
-
|
|
40372
|
-
|
|
40373
|
-
|
|
40374
|
-
|
|
40375
|
-
|
|
40376
|
-
|
|
40377
|
-
|
|
40378
|
-
|
|
40379
|
-
|
|
40380
|
-
|
|
40381
|
-
|
|
40382
|
-
|
|
40383
|
-
|
|
40384
|
-
|
|
40385
|
-
|
|
40386
|
-
|
|
40387
|
-
|
|
40388
|
-
};
|
|
40389
|
-
/* end_public_function */
|
|
40382
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
40383
|
+
__proto__: null,
|
|
40384
|
+
getCommentByIds: getCommentByIds,
|
|
40385
|
+
createComment: createComment,
|
|
40386
|
+
updateComment: updateComment,
|
|
40387
|
+
deleteComment: deleteComment,
|
|
40388
|
+
softDeleteComment: softDeleteComment,
|
|
40389
|
+
hardDeleteComment: hardDeleteComment,
|
|
40390
|
+
flagComment: flagComment,
|
|
40391
|
+
unflagComment: unflagComment,
|
|
40392
|
+
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
40393
|
+
onCommentCreated: onCommentCreated,
|
|
40394
|
+
onCommentUpdated: onCommentUpdated,
|
|
40395
|
+
onCommentDeleted: onCommentDeleted,
|
|
40396
|
+
onCommentFlagged: onCommentFlagged,
|
|
40397
|
+
onCommentUnflagged: onCommentUnflagged,
|
|
40398
|
+
onCommentReactionAdded: onCommentReactionAdded,
|
|
40399
|
+
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
40400
|
+
getComment: getComment,
|
|
40401
|
+
getComments: getComments
|
|
40402
|
+
});
|
|
40390
40403
|
|
|
40391
|
-
const
|
|
40404
|
+
const getPost$1 = async (postId) => {
|
|
40392
40405
|
const client = getActiveClient();
|
|
40393
|
-
client.log('
|
|
40394
|
-
isInTombstone('
|
|
40395
|
-
let
|
|
40406
|
+
client.log('post/getPost', postId);
|
|
40407
|
+
isInTombstone('post', postId);
|
|
40408
|
+
let payload;
|
|
40396
40409
|
try {
|
|
40397
40410
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
40398
|
-
const response = await client.http.get(`/api/v3/
|
|
40399
|
-
|
|
40411
|
+
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
40412
|
+
payload = response.data;
|
|
40400
40413
|
}
|
|
40401
40414
|
catch (error) {
|
|
40402
40415
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40403
|
-
pushToTombstone('
|
|
40416
|
+
pushToTombstone('post', postId);
|
|
40404
40417
|
}
|
|
40405
40418
|
throw error;
|
|
40406
40419
|
}
|
|
40420
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40407
40421
|
const cachedAt = client.cache && Date.now();
|
|
40408
40422
|
if (client.cache)
|
|
40409
40423
|
ingestInCache(data, { cachedAt });
|
|
40410
|
-
const {
|
|
40424
|
+
const { posts } = data;
|
|
40425
|
+
const result = posts.find(post => post.postId === postId);
|
|
40411
40426
|
return {
|
|
40412
|
-
data:
|
|
40427
|
+
data: result,
|
|
40413
40428
|
cachedAt,
|
|
40414
40429
|
};
|
|
40415
40430
|
};
|
|
40416
|
-
|
|
40431
|
+
getPost$1.locally = (postId) => {
|
|
40417
40432
|
const client = getActiveClient();
|
|
40418
|
-
client.log('
|
|
40433
|
+
client.log('post/getPost.locally', postId);
|
|
40419
40434
|
if (!client.cache)
|
|
40420
40435
|
return;
|
|
40421
|
-
const cached = pullFromCache(['
|
|
40436
|
+
const cached = pullFromCache(['post', 'get', postId]);
|
|
40422
40437
|
if (!cached)
|
|
40423
40438
|
return;
|
|
40424
40439
|
return {
|
|
@@ -40429,142 +40444,245 @@ getComment$1.locally = (commentId) => {
|
|
|
40429
40444
|
|
|
40430
40445
|
/**
|
|
40431
40446
|
* ```js
|
|
40432
|
-
* import {
|
|
40433
|
-
* const dispose =
|
|
40447
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk-react-native'
|
|
40448
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
40434
40449
|
* // ...
|
|
40435
40450
|
* })
|
|
40436
40451
|
* ```
|
|
40437
40452
|
*
|
|
40438
|
-
* Fired when a {@link Amity.
|
|
40453
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
40439
40454
|
*
|
|
40440
40455
|
* @param callback The function to call when the event was fired
|
|
40441
40456
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40442
40457
|
*
|
|
40443
|
-
* @category
|
|
40458
|
+
* @category Post Events
|
|
40444
40459
|
*/
|
|
40445
|
-
const
|
|
40460
|
+
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
40446
40461
|
|
|
40447
40462
|
/**
|
|
40448
40463
|
* ```js
|
|
40449
|
-
* import {
|
|
40450
|
-
* const dispose =
|
|
40464
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk-react-native'
|
|
40465
|
+
* const dispose = onPostReactionAdded(post => {
|
|
40451
40466
|
* // ...
|
|
40452
40467
|
* })
|
|
40453
40468
|
* ```
|
|
40454
40469
|
*
|
|
40455
|
-
* Fired when a {@link Amity.
|
|
40470
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
40456
40471
|
*
|
|
40457
40472
|
* @param callback The function to call when the event was fired
|
|
40458
40473
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40459
40474
|
*
|
|
40460
|
-
* @category
|
|
40475
|
+
* @category Post Events
|
|
40461
40476
|
*/
|
|
40462
|
-
const
|
|
40477
|
+
const onLocalPostReactionAdded = (callback) => {
|
|
40463
40478
|
const client = getActiveClient();
|
|
40464
|
-
const filter = ({
|
|
40479
|
+
const filter = ({ post }) => {
|
|
40465
40480
|
if (!client.cache) {
|
|
40466
|
-
callback(
|
|
40481
|
+
callback(post);
|
|
40467
40482
|
}
|
|
40468
40483
|
else {
|
|
40469
|
-
upsertInCache(['
|
|
40470
|
-
callback(
|
|
40484
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
40485
|
+
callback(post);
|
|
40471
40486
|
}
|
|
40472
40487
|
};
|
|
40473
|
-
return createEventSubscriber(client, 'local.
|
|
40488
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
40474
40489
|
};
|
|
40475
40490
|
|
|
40476
40491
|
/**
|
|
40477
40492
|
* ```js
|
|
40478
|
-
* import {
|
|
40479
|
-
* const dispose =
|
|
40493
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk-react-native'
|
|
40494
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
40480
40495
|
* // ...
|
|
40481
40496
|
* })
|
|
40482
40497
|
* ```
|
|
40483
40498
|
*
|
|
40484
|
-
* Fired when a {@link Amity.
|
|
40499
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
40485
40500
|
*
|
|
40486
40501
|
* @param callback The function to call when the event was fired
|
|
40487
40502
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40488
40503
|
*
|
|
40489
|
-
* @category
|
|
40504
|
+
* @category Post Events
|
|
40490
40505
|
*/
|
|
40491
|
-
const
|
|
40506
|
+
const onLocalPostReactionRemoved = (callback) => {
|
|
40492
40507
|
const client = getActiveClient();
|
|
40493
|
-
const filter = ({
|
|
40508
|
+
const filter = ({ post }) => {
|
|
40494
40509
|
if (!client.cache) {
|
|
40495
|
-
callback(
|
|
40510
|
+
callback(post);
|
|
40496
40511
|
}
|
|
40497
40512
|
else {
|
|
40498
|
-
upsertInCache(['
|
|
40499
|
-
callback(
|
|
40513
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
40514
|
+
callback(post);
|
|
40500
40515
|
}
|
|
40501
40516
|
};
|
|
40502
|
-
return createEventSubscriber(client, 'local.
|
|
40517
|
+
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
40503
40518
|
};
|
|
40504
40519
|
|
|
40505
|
-
/* begin_public_function
|
|
40506
|
-
id: comment.get
|
|
40507
|
-
*/
|
|
40508
40520
|
/**
|
|
40509
40521
|
* ```js
|
|
40510
|
-
* import {
|
|
40511
|
-
*
|
|
40512
|
-
*
|
|
40513
|
-
*
|
|
40514
|
-
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
40515
|
-
* comment = response.data;
|
|
40516
|
-
* });
|
|
40522
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk-react-native'
|
|
40523
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
40524
|
+
* // ...
|
|
40525
|
+
* })
|
|
40517
40526
|
* ```
|
|
40518
40527
|
*
|
|
40519
|
-
*
|
|
40528
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
40520
40529
|
*
|
|
40521
|
-
* @param
|
|
40522
|
-
* @
|
|
40523
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
40530
|
+
* @param callback The function to call when the event was fired
|
|
40531
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40524
40532
|
*
|
|
40525
|
-
* @category
|
|
40533
|
+
* @category Post Events
|
|
40526
40534
|
*/
|
|
40527
|
-
const
|
|
40528
|
-
|
|
40529
|
-
|
|
40535
|
+
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
40536
|
+
|
|
40537
|
+
const commentEventHandler$1 = (callback, eventHandler, cacheKey) => {
|
|
40538
|
+
return eventHandler(async (comment) => {
|
|
40539
|
+
var _a;
|
|
40540
|
+
const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40541
|
+
if (!currentCollection || !currentCollection.data.includes(comment.referenceId))
|
|
40542
|
+
return;
|
|
40543
|
+
await getPost$1(comment.referenceId);
|
|
40544
|
+
callback(comment);
|
|
40545
|
+
});
|
|
40546
|
+
};
|
|
40547
|
+
const generateCommentSubscriptions$1 = (cacheKey) => {
|
|
40548
|
+
const eventHandlers = [
|
|
40549
|
+
onCommentCreated,
|
|
40530
40550
|
onCommentDeleted,
|
|
40531
|
-
onCommentFlagged,
|
|
40532
40551
|
onCommentReactionAdded,
|
|
40533
40552
|
onCommentReactionRemoved,
|
|
40534
|
-
|
|
40535
|
-
|
|
40553
|
+
onCommentCreatedLocal,
|
|
40554
|
+
onCommentDeleteLocal,
|
|
40536
40555
|
onLocalCommentReactionAdded,
|
|
40537
40556
|
onLocalCommentReactionRemoved,
|
|
40538
|
-
]
|
|
40557
|
+
];
|
|
40558
|
+
return eventHandlers.map(handler => ({
|
|
40559
|
+
fn: convertEventPayload((callback) => commentEventHandler$1(callback, handler, cacheKey), 'referenceId', 'post'),
|
|
40560
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40561
|
+
}));
|
|
40562
|
+
};
|
|
40563
|
+
const getGlobalFeedSubscriptions = (cacheKey) => {
|
|
40564
|
+
return [
|
|
40565
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
40566
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
40567
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
40568
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40569
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
40570
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
40571
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
40572
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
40573
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40574
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40575
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40576
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40577
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40578
|
+
...generateCommentSubscriptions$1(cacheKey),
|
|
40579
|
+
];
|
|
40580
|
+
};
|
|
40581
|
+
|
|
40582
|
+
class CustomRankingGlobalFeedLiveCollectionController extends LiveCollectionController {
|
|
40583
|
+
constructor(query, callback) {
|
|
40584
|
+
const queryStreamId = hash(query);
|
|
40585
|
+
const cacheKey = ['customRankingGlobalFeed', 'collection', queryStreamId];
|
|
40586
|
+
const paginationController = new CustomRankingGlobalFeedPaginationController(query);
|
|
40587
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40588
|
+
this.query = query;
|
|
40589
|
+
this.queryStreamController = new CustomRankingGlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
40590
|
+
this.callback = callback.bind(this);
|
|
40591
|
+
this.loadPage({ initial: true });
|
|
40592
|
+
}
|
|
40593
|
+
setup() {
|
|
40594
|
+
var _a;
|
|
40595
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40596
|
+
if (!collection) {
|
|
40597
|
+
pushToCache(this.cacheKey, {
|
|
40598
|
+
data: [],
|
|
40599
|
+
params: {},
|
|
40600
|
+
});
|
|
40601
|
+
}
|
|
40602
|
+
}
|
|
40603
|
+
async persistModel(queryPayload) {
|
|
40604
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40605
|
+
}
|
|
40606
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40607
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40608
|
+
}
|
|
40609
|
+
startSubscription() {
|
|
40610
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
40611
|
+
}
|
|
40612
|
+
notifyChange({ origin, loading, error }) {
|
|
40613
|
+
var _a, _b;
|
|
40614
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40615
|
+
if (!collection)
|
|
40616
|
+
return;
|
|
40617
|
+
const data = ((_b = collection.data
|
|
40618
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
40619
|
+
.filter(isNonNullable)
|
|
40620
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
40621
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40622
|
+
return;
|
|
40623
|
+
this.callback({
|
|
40624
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40625
|
+
data,
|
|
40626
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40627
|
+
loading,
|
|
40628
|
+
error,
|
|
40629
|
+
});
|
|
40630
|
+
}
|
|
40631
|
+
}
|
|
40632
|
+
|
|
40633
|
+
/* begin_public_function
|
|
40634
|
+
id: feed.query.custom_ranking_feed
|
|
40635
|
+
*/
|
|
40636
|
+
/**
|
|
40637
|
+
* ```js
|
|
40638
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
40639
|
+
*
|
|
40640
|
+
* let posts = []
|
|
40641
|
+
* const unsub = FeedRepository.getGlobalFeed({
|
|
40642
|
+
* dataTypes: ['video','image'],
|
|
40643
|
+
* resolveParent: true,
|
|
40644
|
+
* }, response => processResponse(response))
|
|
40645
|
+
* ```
|
|
40646
|
+
*
|
|
40647
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
40648
|
+
*
|
|
40649
|
+
* @param params.dataTypes array of data types for the posts
|
|
40650
|
+
* @param callback the function to call when new data are available
|
|
40651
|
+
* @param config
|
|
40652
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40653
|
+
*
|
|
40654
|
+
* @category Posts Live Collection
|
|
40655
|
+
*/
|
|
40656
|
+
const getCustomRankingGlobalFeed = (params, callback, config) => {
|
|
40657
|
+
const { log, cache } = getActiveClient();
|
|
40658
|
+
if (!cache) {
|
|
40659
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
40660
|
+
}
|
|
40661
|
+
const timestamp = Date.now();
|
|
40662
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > listen`);
|
|
40663
|
+
const liveCollection = new CustomRankingGlobalFeedLiveCollectionController(params, callback);
|
|
40664
|
+
const disposers = liveCollection.startSubscription();
|
|
40665
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
40666
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40667
|
+
return () => {
|
|
40668
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > dispose`);
|
|
40669
|
+
disposers.forEach(fn => fn());
|
|
40670
|
+
};
|
|
40539
40671
|
};
|
|
40540
40672
|
/* end_public_function */
|
|
40541
40673
|
|
|
40542
|
-
class
|
|
40674
|
+
class GlobalFeedPaginationController extends PaginationController {
|
|
40543
40675
|
async getRequest(queryParams, token) {
|
|
40544
|
-
const { limit
|
|
40545
|
-
const
|
|
40546
|
-
|
|
40547
|
-
|
|
40548
|
-
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
40549
|
-
const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
|
|
40550
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
40676
|
+
const { limit, resolveParent } = queryParams, params = __rest(queryParams, ["limit", "resolveParent"]);
|
|
40677
|
+
const options = token ? { token } : { limit };
|
|
40678
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/global-feeds`, {
|
|
40679
|
+
params: Object.assign(Object.assign({}, params), { resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
|
|
40551
40680
|
});
|
|
40552
40681
|
return queryResponse;
|
|
40553
40682
|
}
|
|
40554
40683
|
}
|
|
40555
40684
|
|
|
40556
|
-
|
|
40557
|
-
(function (EnumCommentActions) {
|
|
40558
|
-
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
40559
|
-
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
40560
|
-
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
40561
|
-
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
40562
|
-
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
40563
|
-
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
40564
|
-
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
40565
|
-
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
40566
|
-
|
|
40567
|
-
class CommentQueryStreamController extends QueryStreamController {
|
|
40685
|
+
class GlobalFeedQueryStreamController extends QueryStreamController {
|
|
40568
40686
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40569
40687
|
super(query, cacheKey);
|
|
40570
40688
|
this.notifyChange = notifyChange;
|
|
@@ -40582,321 +40700,848 @@ class CommentQueryStreamController extends QueryStreamController {
|
|
|
40582
40700
|
var _a, _b;
|
|
40583
40701
|
if (refresh) {
|
|
40584
40702
|
pushToCache(this.cacheKey, {
|
|
40585
|
-
data: response.
|
|
40703
|
+
data: response.posts.map(getResolver('post')),
|
|
40586
40704
|
});
|
|
40587
40705
|
}
|
|
40588
40706
|
else {
|
|
40589
40707
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40590
|
-
const
|
|
40591
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...
|
|
40708
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
40709
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
40592
40710
|
}
|
|
40593
40711
|
}
|
|
40594
40712
|
reactor(action) {
|
|
40595
|
-
return (
|
|
40713
|
+
return (post) => {
|
|
40596
40714
|
var _a;
|
|
40597
40715
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40598
|
-
if (
|
|
40599
|
-
this.query.referenceType !== comment.referenceType ||
|
|
40600
|
-
!collection) {
|
|
40716
|
+
if (!collection)
|
|
40601
40717
|
return;
|
|
40602
|
-
|
|
40603
|
-
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
40718
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
40604
40719
|
return;
|
|
40720
|
+
// Delete Action
|
|
40721
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
40722
|
+
// Parent Post - Remove from collection
|
|
40723
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40605
40724
|
}
|
|
40606
|
-
if (
|
|
40725
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
40726
|
+
// If the query has dataTypes array with value, check if post.dataType is include in the array
|
|
40727
|
+
if (this.query.dataTypes && this.query.dataTypes.length > 0) {
|
|
40728
|
+
if (!this.query.dataTypes.includes(post.dataType))
|
|
40729
|
+
return;
|
|
40730
|
+
}
|
|
40731
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
40732
|
+
}
|
|
40733
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
40734
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40735
|
+
}
|
|
40736
|
+
pushToCache(this.cacheKey, collection);
|
|
40737
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40738
|
+
};
|
|
40739
|
+
}
|
|
40740
|
+
subscribeRTE(createSubscriber) {
|
|
40741
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40742
|
+
}
|
|
40743
|
+
}
|
|
40744
|
+
|
|
40745
|
+
class GlobalFeedLiveCollectionController extends LiveCollectionController {
|
|
40746
|
+
constructor(query, callback) {
|
|
40747
|
+
const queryStreamId = hash(query);
|
|
40748
|
+
const cacheKey = ['globalFeed', 'collection', queryStreamId];
|
|
40749
|
+
const paginationController = new GlobalFeedPaginationController(query);
|
|
40750
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40751
|
+
this.query = query;
|
|
40752
|
+
this.queryStreamController = new GlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
40753
|
+
this.callback = callback.bind(this);
|
|
40754
|
+
this.loadPage({ initial: true });
|
|
40755
|
+
}
|
|
40756
|
+
setup() {
|
|
40757
|
+
var _a;
|
|
40758
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40759
|
+
if (!collection) {
|
|
40760
|
+
pushToCache(this.cacheKey, {
|
|
40761
|
+
data: [],
|
|
40762
|
+
params: {},
|
|
40763
|
+
});
|
|
40764
|
+
}
|
|
40765
|
+
}
|
|
40766
|
+
async persistModel(queryPayload) {
|
|
40767
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40768
|
+
}
|
|
40769
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40770
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40771
|
+
}
|
|
40772
|
+
startSubscription() {
|
|
40773
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
40774
|
+
}
|
|
40775
|
+
notifyChange({ origin, loading, error }) {
|
|
40776
|
+
var _a, _b;
|
|
40777
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40778
|
+
if (!collection)
|
|
40779
|
+
return;
|
|
40780
|
+
const data = ((_b = collection.data
|
|
40781
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
40782
|
+
.filter(isNonNullable)
|
|
40783
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
40784
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40785
|
+
return;
|
|
40786
|
+
this.callback({
|
|
40787
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40788
|
+
data,
|
|
40789
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40790
|
+
loading,
|
|
40791
|
+
error,
|
|
40792
|
+
});
|
|
40793
|
+
}
|
|
40794
|
+
}
|
|
40795
|
+
|
|
40796
|
+
/* begin_public_function
|
|
40797
|
+
id: feed.query.global_feed
|
|
40798
|
+
*/
|
|
40799
|
+
/**
|
|
40800
|
+
* ```js
|
|
40801
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
40802
|
+
*
|
|
40803
|
+
* let posts = []
|
|
40804
|
+
* const unsub = FeedRepository.getGlobalFeed({
|
|
40805
|
+
* dataTypes: ['video','image'],
|
|
40806
|
+
* resolveParent: true,
|
|
40807
|
+
* }, response => processResponse(response))
|
|
40808
|
+
* ```
|
|
40809
|
+
*
|
|
40810
|
+
* Observe all mutations on a list of {@link Amity.Post} for global feed
|
|
40811
|
+
* @param params.dataTypes array of data types for the posts
|
|
40812
|
+
* @param params.resolveParent
|
|
40813
|
+
* @param callback the function to call when new data are available
|
|
40814
|
+
* @param config
|
|
40815
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40816
|
+
*
|
|
40817
|
+
* @category Posts Live Collection
|
|
40818
|
+
*/
|
|
40819
|
+
const getGlobalFeed = (params, callback, config) => {
|
|
40820
|
+
const { log, cache } = getActiveClient();
|
|
40821
|
+
if (!cache) {
|
|
40822
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
40823
|
+
}
|
|
40824
|
+
const timestamp = Date.now();
|
|
40825
|
+
log(`getGlobalFeed(tmpid: ${timestamp}) > listen`);
|
|
40826
|
+
const liveCollection = new GlobalFeedLiveCollectionController(params, callback);
|
|
40827
|
+
const disposers = liveCollection.startSubscription();
|
|
40828
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
40829
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40830
|
+
return () => {
|
|
40831
|
+
log(`getGlobalFeed(tmpid: ${timestamp}) > dispose`);
|
|
40832
|
+
disposers.forEach(fn => fn());
|
|
40833
|
+
};
|
|
40834
|
+
};
|
|
40835
|
+
/* end_public_function */
|
|
40836
|
+
|
|
40837
|
+
class UserFeedPaginationController extends PaginationController {
|
|
40838
|
+
async getRequest(queryParams, token) {
|
|
40839
|
+
const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["userId", "feedSources", "dataTypes", "includeDeleted", "matchingOnlyParentPost", "limit"]);
|
|
40840
|
+
const options = token ? { token } : { limit };
|
|
40841
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/user-feeds/${userId}`, {
|
|
40842
|
+
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) }),
|
|
40843
|
+
});
|
|
40844
|
+
return queryResponse;
|
|
40845
|
+
}
|
|
40846
|
+
}
|
|
40847
|
+
|
|
40848
|
+
class UserFeedQueryStreamController extends QueryStreamController {
|
|
40849
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40850
|
+
super(query, cacheKey);
|
|
40851
|
+
this.notifyChange = notifyChange;
|
|
40852
|
+
this.preparePayload = preparePayload;
|
|
40853
|
+
}
|
|
40854
|
+
async saveToMainDB(response) {
|
|
40855
|
+
const processedPayload = await this.preparePayload(response);
|
|
40856
|
+
const client = getActiveClient();
|
|
40857
|
+
const cachedAt = client.cache && Date.now();
|
|
40858
|
+
if (client.cache) {
|
|
40859
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
40860
|
+
}
|
|
40861
|
+
}
|
|
40862
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
40863
|
+
var _a, _b;
|
|
40864
|
+
if (refresh) {
|
|
40865
|
+
pushToCache(this.cacheKey, {
|
|
40866
|
+
data: response.posts.map(getResolver('post')),
|
|
40867
|
+
});
|
|
40868
|
+
}
|
|
40869
|
+
else {
|
|
40870
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40871
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
40872
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
40873
|
+
}
|
|
40874
|
+
}
|
|
40875
|
+
reactor(action) {
|
|
40876
|
+
return (post) => {
|
|
40877
|
+
var _a, _b;
|
|
40878
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40879
|
+
if (!collection)
|
|
40880
|
+
return;
|
|
40881
|
+
// if the collection is parent post collection and
|
|
40882
|
+
// post is not included in the collection or post is child post
|
|
40883
|
+
if ((!this.query.dataTypes || this.query.dataTypes.length === 0) &&
|
|
40884
|
+
!collection.data.includes(post.parentPostId ? post.parentPostId : post.postId))
|
|
40607
40885
|
return;
|
|
40886
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
40887
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40608
40888
|
}
|
|
40609
|
-
if (
|
|
40610
|
-
|
|
40889
|
+
if (post.parentPostId && post.isDeleted) {
|
|
40890
|
+
const parentPost = (_b = pullFromCache([
|
|
40891
|
+
'post',
|
|
40892
|
+
'get',
|
|
40893
|
+
post.parentPostId,
|
|
40894
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
40895
|
+
if (!parentPost)
|
|
40896
|
+
return;
|
|
40897
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
40898
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
40899
|
+
}
|
|
40900
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
40901
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40902
|
+
}
|
|
40903
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
40904
|
+
if (this.query.dataTypes &&
|
|
40905
|
+
this.query.dataTypes.length > 0 &&
|
|
40906
|
+
!this.query.dataTypes.includes(post.dataType)) {
|
|
40907
|
+
return;
|
|
40908
|
+
}
|
|
40909
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
40611
40910
|
}
|
|
40612
40911
|
pushToCache(this.cacheKey, collection);
|
|
40613
40912
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40614
40913
|
};
|
|
40615
40914
|
}
|
|
40616
|
-
subscribeRTE(createSubscriber) {
|
|
40617
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40915
|
+
subscribeRTE(createSubscriber) {
|
|
40916
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40917
|
+
}
|
|
40918
|
+
}
|
|
40919
|
+
|
|
40920
|
+
class UserFeedLiveCollectionController extends LiveCollectionController {
|
|
40921
|
+
constructor(query, callback) {
|
|
40922
|
+
const queryStreamId = hash(query);
|
|
40923
|
+
const cacheKey = ['userFeed', 'collection', queryStreamId];
|
|
40924
|
+
const paginationController = new UserFeedPaginationController(query);
|
|
40925
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40926
|
+
this.query = query;
|
|
40927
|
+
this.queryStreamController = new UserFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
40928
|
+
this.callback = callback.bind(this);
|
|
40929
|
+
this.loadPage({ initial: true });
|
|
40930
|
+
}
|
|
40931
|
+
setup() {
|
|
40932
|
+
var _a;
|
|
40933
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40934
|
+
if (!collection) {
|
|
40935
|
+
pushToCache(this.cacheKey, {
|
|
40936
|
+
data: [],
|
|
40937
|
+
params: {},
|
|
40938
|
+
});
|
|
40939
|
+
}
|
|
40940
|
+
}
|
|
40941
|
+
async persistModel(queryPayload) {
|
|
40942
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40943
|
+
}
|
|
40944
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40945
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40946
|
+
}
|
|
40947
|
+
startSubscription() {
|
|
40948
|
+
return this.queryStreamController.subscribeRTE([
|
|
40949
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
40950
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
40951
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
40952
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40953
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
40954
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
40955
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
40956
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
40957
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40958
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40959
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40960
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40961
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40962
|
+
{
|
|
40963
|
+
fn: convertEventPayload((callback) => {
|
|
40964
|
+
return onCommentCreated(async (comment) => {
|
|
40965
|
+
var _a;
|
|
40966
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40967
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
40968
|
+
return;
|
|
40969
|
+
await getPost$1(comment.referenceId);
|
|
40970
|
+
callback(comment);
|
|
40971
|
+
});
|
|
40972
|
+
}, 'referenceId', 'post'),
|
|
40973
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40974
|
+
},
|
|
40975
|
+
{
|
|
40976
|
+
fn: convertEventPayload((callback) => {
|
|
40977
|
+
return onCommentDeleted(async (comment) => {
|
|
40978
|
+
var _a;
|
|
40979
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40980
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
40981
|
+
return;
|
|
40982
|
+
await getPost$1(comment.referenceId);
|
|
40983
|
+
callback(comment);
|
|
40984
|
+
});
|
|
40985
|
+
}, 'referenceId', 'post'),
|
|
40986
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40987
|
+
},
|
|
40988
|
+
]);
|
|
40989
|
+
}
|
|
40990
|
+
notifyChange({ origin, loading, error }) {
|
|
40991
|
+
var _a, _b;
|
|
40992
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40993
|
+
if (!collection)
|
|
40994
|
+
return;
|
|
40995
|
+
const data = ((_b = collection.data
|
|
40996
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
40997
|
+
.filter(isNonNullable)
|
|
40998
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
40999
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
41000
|
+
return;
|
|
41001
|
+
this.callback({
|
|
41002
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
41003
|
+
data,
|
|
41004
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
41005
|
+
loading,
|
|
41006
|
+
error,
|
|
41007
|
+
});
|
|
41008
|
+
}
|
|
41009
|
+
}
|
|
41010
|
+
|
|
41011
|
+
/* begin_public_function
|
|
41012
|
+
id: feed.query.user_feed
|
|
41013
|
+
*/
|
|
41014
|
+
/**
|
|
41015
|
+
* ```js
|
|
41016
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
41017
|
+
*
|
|
41018
|
+
* let posts = []
|
|
41019
|
+
* const unsubscribe = FeedRepository.getUserFeed({
|
|
41020
|
+
* userId: string,
|
|
41021
|
+
* feedSources: ['user', 'community'],
|
|
41022
|
+
* }, response => response => processResponse(response))
|
|
41023
|
+
* ```
|
|
41024
|
+
*
|
|
41025
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given user and feedSources
|
|
41026
|
+
*
|
|
41027
|
+
* @param params.userId the ID of the user
|
|
41028
|
+
* @param params.feedSources the sources of the feed
|
|
41029
|
+
* @param callback the function to call when new data are available
|
|
41030
|
+
* @param config
|
|
41031
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
41032
|
+
*
|
|
41033
|
+
* @category Posts Live Collection
|
|
41034
|
+
*/
|
|
41035
|
+
const getUserFeed = (params, callback, config) => {
|
|
41036
|
+
const { log, cache } = getActiveClient();
|
|
41037
|
+
if (!cache) {
|
|
41038
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
41039
|
+
}
|
|
41040
|
+
const timestamp = Date.now();
|
|
41041
|
+
log(`getUserFeed(tmpid: ${timestamp}) > listen`);
|
|
41042
|
+
const userFeedLiveCollection = new UserFeedLiveCollectionController(params, callback);
|
|
41043
|
+
const disposers = userFeedLiveCollection.startSubscription();
|
|
41044
|
+
const cacheKey = userFeedLiveCollection.getCacheKey();
|
|
41045
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
41046
|
+
return () => {
|
|
41047
|
+
log(`getUserFeed(tmpid: ${timestamp}) > dispose`);
|
|
41048
|
+
disposers.forEach(fn => fn());
|
|
41049
|
+
};
|
|
41050
|
+
};
|
|
41051
|
+
/* end_public_function */
|
|
41052
|
+
|
|
41053
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
41054
|
+
__proto__: null,
|
|
41055
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
41056
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
41057
|
+
getGlobalFeed: getGlobalFeed,
|
|
41058
|
+
getUserFeed: getUserFeed
|
|
41059
|
+
});
|
|
41060
|
+
|
|
41061
|
+
/* begin_public_function
|
|
41062
|
+
id: post.get_by_ids
|
|
41063
|
+
*/
|
|
41064
|
+
/**
|
|
41065
|
+
* ```js
|
|
41066
|
+
* import { getPostByIds } from '@amityco/ts-sdk-react-native'
|
|
41067
|
+
* const { data: posts } = await getPostByIds(['foo', 'bar'])
|
|
41068
|
+
* ```
|
|
41069
|
+
*
|
|
41070
|
+
* Fetches a collection of {@link Amity.Post} objects
|
|
41071
|
+
*
|
|
41072
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
41073
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
41074
|
+
*
|
|
41075
|
+
* @category Post API
|
|
41076
|
+
* @async
|
|
41077
|
+
*/
|
|
41078
|
+
const getPostByIds = async (postIds) => {
|
|
41079
|
+
const client = getActiveClient();
|
|
41080
|
+
client.log('post/getPostByIds', postIds);
|
|
41081
|
+
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
41082
|
+
let payload;
|
|
41083
|
+
try {
|
|
41084
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
41085
|
+
const response = await client.http.get(`/api/v3/posts/list`, {
|
|
41086
|
+
params: { postIds: encodedPostIds },
|
|
41087
|
+
});
|
|
41088
|
+
payload = response.data;
|
|
41089
|
+
}
|
|
41090
|
+
catch (error) {
|
|
41091
|
+
postIds.forEach(postId => {
|
|
41092
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
41093
|
+
pushToTombstone('post', postId);
|
|
41094
|
+
}
|
|
41095
|
+
});
|
|
41096
|
+
throw error;
|
|
41097
|
+
}
|
|
41098
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41099
|
+
const cachedAt = client.cache && Date.now();
|
|
41100
|
+
if (client.cache)
|
|
41101
|
+
ingestInCache(data, { cachedAt });
|
|
41102
|
+
return {
|
|
41103
|
+
data: data.posts.map(LinkedObject.post),
|
|
41104
|
+
cachedAt,
|
|
41105
|
+
};
|
|
41106
|
+
};
|
|
41107
|
+
/* end_public_function */
|
|
41108
|
+
/**
|
|
41109
|
+
* ```js
|
|
41110
|
+
* import { getPostByIds } from '@amityco/ts-sdk-react-native'
|
|
41111
|
+
* const { data: posts } = getPostByIds.locally(['foo', 'bar'])
|
|
41112
|
+
* ```
|
|
41113
|
+
*
|
|
41114
|
+
* Fetches a collection of {@link Amity.Post} objects from cache
|
|
41115
|
+
*
|
|
41116
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
41117
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
41118
|
+
*
|
|
41119
|
+
* @category Post API
|
|
41120
|
+
*/
|
|
41121
|
+
getPostByIds.locally = (postIds) => {
|
|
41122
|
+
var _a;
|
|
41123
|
+
const client = getActiveClient();
|
|
41124
|
+
client.log('post/getPostByIds.locally', postIds);
|
|
41125
|
+
if (!client.cache)
|
|
41126
|
+
return;
|
|
41127
|
+
const cached = postIds
|
|
41128
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
41129
|
+
.filter(Boolean);
|
|
41130
|
+
const posts = cached.map(({ data }) => data);
|
|
41131
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
41132
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
41133
|
+
return;
|
|
41134
|
+
return {
|
|
41135
|
+
data: posts.map(LinkedObject.post),
|
|
41136
|
+
cachedAt: oldest.cachedAt,
|
|
41137
|
+
};
|
|
41138
|
+
};
|
|
41139
|
+
|
|
41140
|
+
/* begin_public_function
|
|
41141
|
+
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
|
|
41142
|
+
*/
|
|
41143
|
+
/**
|
|
41144
|
+
* ```js
|
|
41145
|
+
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
41146
|
+
* const created = await PostRepository.createPost({
|
|
41147
|
+
* targetType: 'user',
|
|
41148
|
+
* targetId: 'foobar',
|
|
41149
|
+
* data: { text: 'hello world' }
|
|
41150
|
+
* }))
|
|
41151
|
+
* ```
|
|
41152
|
+
*
|
|
41153
|
+
* Creates an {@link Amity.Post}
|
|
41154
|
+
*
|
|
41155
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
41156
|
+
* @returns The newly created {@link Amity.Post}
|
|
41157
|
+
*
|
|
41158
|
+
* @category Post API
|
|
41159
|
+
* @async
|
|
41160
|
+
*/
|
|
41161
|
+
const createPost = async (bundle) => {
|
|
41162
|
+
const client = getActiveClient();
|
|
41163
|
+
client.log('post/createPost', bundle);
|
|
41164
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
41165
|
+
// eslint-disable-next-line no-param-reassign
|
|
41166
|
+
delete bundle.dataType;
|
|
41167
|
+
}
|
|
41168
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
41169
|
+
fireEvent('post.created', payload);
|
|
41170
|
+
const data = preparePostPayload(payload);
|
|
41171
|
+
const cachedAt = client.cache && Date.now();
|
|
41172
|
+
if (client.cache)
|
|
41173
|
+
ingestInCache(data, { cachedAt });
|
|
41174
|
+
const { posts } = data;
|
|
41175
|
+
return {
|
|
41176
|
+
data: LinkedObject.post(posts[0]),
|
|
41177
|
+
cachedAt,
|
|
41178
|
+
};
|
|
41179
|
+
};
|
|
41180
|
+
/* end_public_function */
|
|
41181
|
+
|
|
41182
|
+
/* begin_public_function
|
|
41183
|
+
id: post.edit, post.edit.custom_post
|
|
41184
|
+
*/
|
|
41185
|
+
/**
|
|
41186
|
+
* ```js
|
|
41187
|
+
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
41188
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
41189
|
+
* data: { text: 'hello world' }
|
|
41190
|
+
* })
|
|
41191
|
+
* ```
|
|
41192
|
+
*
|
|
41193
|
+
* Updates an {@link Amity.Post}
|
|
41194
|
+
*
|
|
41195
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
41196
|
+
* @param patch The patch data to apply
|
|
41197
|
+
* @returns the updated {@link Amity.Post} object
|
|
41198
|
+
*
|
|
41199
|
+
* @category Post API
|
|
41200
|
+
* @async
|
|
41201
|
+
*/
|
|
41202
|
+
const editPost = async (postId, patch) => {
|
|
41203
|
+
const client = getActiveClient();
|
|
41204
|
+
client.log('user/editPost', patch);
|
|
41205
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
41206
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41207
|
+
const cachedAt = client.cache && Date.now();
|
|
41208
|
+
if (client.cache)
|
|
41209
|
+
ingestInCache(data, { cachedAt });
|
|
41210
|
+
fireEvent('local.post.updated', data);
|
|
41211
|
+
const { posts } = data;
|
|
41212
|
+
return {
|
|
41213
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
41214
|
+
cachedAt,
|
|
41215
|
+
};
|
|
41216
|
+
};
|
|
41217
|
+
/* end_public_function */
|
|
41218
|
+
|
|
41219
|
+
/**
|
|
41220
|
+
* ```js
|
|
41221
|
+
* import { deletePost } from '@amityco/ts-sdk-react-native'
|
|
41222
|
+
* const success = await deletePost('foobar')
|
|
41223
|
+
* ```
|
|
41224
|
+
*
|
|
41225
|
+
* Deletes a {@link Amity.Post}
|
|
41226
|
+
*
|
|
41227
|
+
* @param postId The {@link Amity.Post} ID to delete
|
|
41228
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
41229
|
+
*
|
|
41230
|
+
* @private
|
|
41231
|
+
* @async
|
|
41232
|
+
*/
|
|
41233
|
+
const deletePost = async (postId, permanent = false) => {
|
|
41234
|
+
var _a;
|
|
41235
|
+
const client = getActiveClient();
|
|
41236
|
+
const post = await getPost$2(postId);
|
|
41237
|
+
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
41238
|
+
params: {
|
|
41239
|
+
postId,
|
|
41240
|
+
permanent,
|
|
41241
|
+
},
|
|
41242
|
+
});
|
|
41243
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
41244
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
41245
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
41246
|
+
// later when realtime events covers that for us.
|
|
41247
|
+
if (post.data.targetType === 'community') {
|
|
41248
|
+
const community = await getCommunity$1(post.data.targetId);
|
|
41249
|
+
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
41250
|
+
const communityUsers = communityUsersCache
|
|
41251
|
+
.filter(({ key }) => {
|
|
41252
|
+
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
41253
|
+
if (key[0] !== 'communityUsers')
|
|
41254
|
+
return false;
|
|
41255
|
+
if (key[1] !== 'get')
|
|
41256
|
+
return false;
|
|
41257
|
+
if (typeof key[2] === 'string')
|
|
41258
|
+
return key[2].includes(community.data.communityId);
|
|
41259
|
+
return false;
|
|
41260
|
+
})
|
|
41261
|
+
.map(({ data }) => data);
|
|
41262
|
+
fireEvent('community.updated', {
|
|
41263
|
+
communities: [community.data],
|
|
41264
|
+
categories: [],
|
|
41265
|
+
communityUsers,
|
|
41266
|
+
feeds: [],
|
|
41267
|
+
files: [],
|
|
41268
|
+
users: [],
|
|
41269
|
+
});
|
|
41270
|
+
}
|
|
41271
|
+
// to support hard deletion
|
|
41272
|
+
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
41273
|
+
if (permanent) {
|
|
41274
|
+
setTimeout(() => {
|
|
41275
|
+
pushToTombstone('post', postId);
|
|
41276
|
+
}, 0);
|
|
40618
41277
|
}
|
|
40619
|
-
|
|
41278
|
+
else {
|
|
41279
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
41280
|
+
}
|
|
41281
|
+
fireEvent('local.post.deleted', {
|
|
41282
|
+
posts: [deleted],
|
|
41283
|
+
categories: [],
|
|
41284
|
+
comments: [],
|
|
41285
|
+
communities: [],
|
|
41286
|
+
communityUsers: [],
|
|
41287
|
+
feeds: [],
|
|
41288
|
+
files: [],
|
|
41289
|
+
postChildren: [],
|
|
41290
|
+
users: [],
|
|
41291
|
+
videoStreamings: [],
|
|
41292
|
+
});
|
|
41293
|
+
return LinkedObject.post(deleted);
|
|
41294
|
+
};
|
|
40620
41295
|
|
|
41296
|
+
/* begin_public_function
|
|
41297
|
+
id: post.soft_delete
|
|
41298
|
+
*/
|
|
40621
41299
|
/**
|
|
40622
41300
|
* ```js
|
|
40623
|
-
* import {
|
|
40624
|
-
* const
|
|
40625
|
-
* // ...
|
|
40626
|
-
* })
|
|
41301
|
+
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
41302
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
40627
41303
|
* ```
|
|
40628
41304
|
*
|
|
40629
|
-
*
|
|
41305
|
+
* Soft deletes a {@link Amity.Post}
|
|
40630
41306
|
*
|
|
40631
|
-
* @param
|
|
40632
|
-
* @
|
|
41307
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
41308
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
40633
41309
|
*
|
|
40634
|
-
* @category
|
|
41310
|
+
* @category Post API
|
|
41311
|
+
* @async
|
|
40635
41312
|
*/
|
|
40636
|
-
const
|
|
40637
|
-
|
|
41313
|
+
const softDeletePost = async (postId) => {
|
|
41314
|
+
const client = getActiveClient();
|
|
41315
|
+
client.log('post/softDeletePost', postId);
|
|
41316
|
+
const softDeleted = await deletePost(postId, false);
|
|
41317
|
+
return LinkedObject.post(softDeleted);
|
|
40638
41318
|
};
|
|
41319
|
+
/* end_public_function */
|
|
40639
41320
|
|
|
40640
|
-
|
|
40641
|
-
|
|
40642
|
-
|
|
40643
|
-
|
|
40644
|
-
|
|
40645
|
-
|
|
40646
|
-
|
|
40647
|
-
|
|
40648
|
-
|
|
40649
|
-
|
|
40650
|
-
|
|
40651
|
-
|
|
40652
|
-
|
|
40653
|
-
|
|
40654
|
-
|
|
40655
|
-
|
|
40656
|
-
|
|
40657
|
-
|
|
40658
|
-
|
|
40659
|
-
|
|
40660
|
-
|
|
40661
|
-
|
|
40662
|
-
|
|
40663
|
-
|
|
40664
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
40665
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40666
|
-
}
|
|
40667
|
-
startSubscription() {
|
|
40668
|
-
return this.queryStreamController.subscribeRTE([
|
|
40669
|
-
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
40670
|
-
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
40671
|
-
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
40672
|
-
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
40673
|
-
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
40674
|
-
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
40675
|
-
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
40676
|
-
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40677
|
-
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40678
|
-
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40679
|
-
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40680
|
-
]);
|
|
40681
|
-
}
|
|
40682
|
-
notifyChange({ origin, loading, error }) {
|
|
40683
|
-
var _a, _b;
|
|
40684
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40685
|
-
if (!collection)
|
|
40686
|
-
return;
|
|
40687
|
-
const data = this.applyFilter((_b = collection.data
|
|
40688
|
-
.map(id => pullFromCache(['comment', 'get', id]))
|
|
40689
|
-
.filter(isNonNullable)
|
|
40690
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
40691
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
40692
|
-
return;
|
|
40693
|
-
this.callback({
|
|
40694
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40695
|
-
data,
|
|
40696
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40697
|
-
loading,
|
|
40698
|
-
error,
|
|
40699
|
-
});
|
|
40700
|
-
}
|
|
40701
|
-
applyFilter(data) {
|
|
40702
|
-
let comments = data;
|
|
40703
|
-
if (!this.query.includeDeleted) {
|
|
40704
|
-
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
40705
|
-
}
|
|
40706
|
-
if (this.query.parentId) {
|
|
40707
|
-
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
40708
|
-
}
|
|
40709
|
-
if (typeof this.query.hasFlag === 'boolean') {
|
|
40710
|
-
if (this.query.hasFlag) {
|
|
40711
|
-
comments = comments.filter(comment => comment.hashFlag != null);
|
|
40712
|
-
}
|
|
40713
|
-
else {
|
|
40714
|
-
comments = comments.filter(comment => comment.hashFlag == null);
|
|
40715
|
-
}
|
|
40716
|
-
}
|
|
40717
|
-
if (this.query.dataTypes) {
|
|
40718
|
-
if (this.query.dataTypes.matchType === 'exact') {
|
|
40719
|
-
comments = comments.filter(comment => {
|
|
40720
|
-
var _a, _b;
|
|
40721
|
-
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
40722
|
-
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
40723
|
-
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
40724
|
-
return false;
|
|
40725
|
-
}
|
|
40726
|
-
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
40727
|
-
});
|
|
40728
|
-
}
|
|
40729
|
-
if (this.query.dataTypes.matchType === 'any') {
|
|
40730
|
-
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); }); });
|
|
40731
|
-
}
|
|
40732
|
-
}
|
|
40733
|
-
switch (this.query.sortBy) {
|
|
40734
|
-
case 'firstCreated':
|
|
40735
|
-
comments = comments.sort(sortByFirstCreated);
|
|
40736
|
-
break;
|
|
40737
|
-
case 'lastCreated':
|
|
40738
|
-
default:
|
|
40739
|
-
comments = comments.sort(sortByLastCreated);
|
|
40740
|
-
break;
|
|
40741
|
-
}
|
|
40742
|
-
return comments;
|
|
40743
|
-
}
|
|
40744
|
-
}
|
|
41321
|
+
/* begin_public_function
|
|
41322
|
+
id: post.hard_delete
|
|
41323
|
+
*/
|
|
41324
|
+
/**
|
|
41325
|
+
* ```js
|
|
41326
|
+
* import { hardDeletePost } from '@amityco/ts-sdk-react-native'
|
|
41327
|
+
* const success = await hardDeletePost('foobar')
|
|
41328
|
+
* ```
|
|
41329
|
+
*
|
|
41330
|
+
* Hard deletes a {@link Amity.Post}
|
|
41331
|
+
*
|
|
41332
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
41333
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
41334
|
+
*
|
|
41335
|
+
* @category Post API
|
|
41336
|
+
* @async
|
|
41337
|
+
*/
|
|
41338
|
+
const hardDeletePost = async (postId) => {
|
|
41339
|
+
const client = getActiveClient();
|
|
41340
|
+
client.log('post/hardDeletePost', postId);
|
|
41341
|
+
const hardDeleted = await deletePost(postId, true);
|
|
41342
|
+
return LinkedObject.post(hardDeleted);
|
|
41343
|
+
};
|
|
41344
|
+
/* end_public_function */
|
|
40745
41345
|
|
|
40746
41346
|
/* begin_public_function
|
|
40747
|
-
id:
|
|
41347
|
+
id: post.approve
|
|
40748
41348
|
*/
|
|
40749
41349
|
/**
|
|
40750
41350
|
* ```js
|
|
40751
|
-
* import {
|
|
41351
|
+
* import { approvePost } from '@amityco/ts-sdk-react-native'
|
|
40752
41352
|
*
|
|
40753
|
-
*
|
|
40754
|
-
* const unsub = getComments({
|
|
40755
|
-
* referenceType: Amity.InternalComment['referenceType'];
|
|
40756
|
-
* referenceId: Amity.InternalComment['referenceId'];
|
|
40757
|
-
* }, response => merge(comments, response.data))
|
|
41353
|
+
* const { data: post } = await approvePost('postId')
|
|
40758
41354
|
* ```
|
|
40759
41355
|
*
|
|
40760
|
-
*
|
|
41356
|
+
* Approves a {@link Amity.Post}
|
|
40761
41357
|
*
|
|
40762
|
-
* @param
|
|
40763
|
-
* @
|
|
40764
|
-
* @param callback the function to call when new data are available
|
|
40765
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
41358
|
+
* @param postId The {@link Amity.Post} ID to be approved
|
|
41359
|
+
* @return A {@link Amity.Post} that was approved
|
|
40766
41360
|
*
|
|
40767
|
-
* @category
|
|
41361
|
+
* @category Post API
|
|
41362
|
+
* @async
|
|
40768
41363
|
*/
|
|
40769
|
-
const
|
|
40770
|
-
const
|
|
40771
|
-
|
|
40772
|
-
|
|
41364
|
+
const approvePost = async (postId) => {
|
|
41365
|
+
const client = getActiveClient();
|
|
41366
|
+
client.log('post/approvePost', postId);
|
|
41367
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
41368
|
+
fireEvent('post.approved', payload);
|
|
41369
|
+
// fire virtual event for community update
|
|
41370
|
+
if (payload.posts[0].targetType === 'community') {
|
|
41371
|
+
fireEvent('community.updated', payload);
|
|
40773
41372
|
}
|
|
40774
|
-
const
|
|
40775
|
-
|
|
40776
|
-
|
|
40777
|
-
|
|
40778
|
-
|
|
40779
|
-
|
|
40780
|
-
|
|
40781
|
-
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
40782
|
-
disposers.forEach(fn => fn());
|
|
41373
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41374
|
+
const cachedAt = client.cache && Date.now();
|
|
41375
|
+
if (client.cache)
|
|
41376
|
+
ingestInCache(data, { cachedAt });
|
|
41377
|
+
return {
|
|
41378
|
+
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
41379
|
+
cachedAt,
|
|
40783
41380
|
};
|
|
40784
41381
|
};
|
|
40785
41382
|
/* end_public_function */
|
|
40786
41383
|
|
|
40787
|
-
|
|
40788
|
-
|
|
40789
|
-
|
|
40790
|
-
createComment: createComment,
|
|
40791
|
-
updateComment: updateComment,
|
|
40792
|
-
deleteComment: deleteComment,
|
|
40793
|
-
softDeleteComment: softDeleteComment,
|
|
40794
|
-
hardDeleteComment: hardDeleteComment,
|
|
40795
|
-
flagComment: flagComment,
|
|
40796
|
-
unflagComment: unflagComment,
|
|
40797
|
-
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
40798
|
-
onCommentCreated: onCommentCreated,
|
|
40799
|
-
onCommentUpdated: onCommentUpdated,
|
|
40800
|
-
onCommentDeleted: onCommentDeleted,
|
|
40801
|
-
onCommentFlagged: onCommentFlagged,
|
|
40802
|
-
onCommentUnflagged: onCommentUnflagged,
|
|
40803
|
-
onCommentReactionAdded: onCommentReactionAdded,
|
|
40804
|
-
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
40805
|
-
getComment: getComment,
|
|
40806
|
-
getComments: getComments
|
|
40807
|
-
});
|
|
40808
|
-
|
|
41384
|
+
/* begin_public_function
|
|
41385
|
+
id: post.decline
|
|
41386
|
+
*/
|
|
40809
41387
|
/**
|
|
40810
41388
|
* ```js
|
|
40811
|
-
* import {
|
|
40812
|
-
*
|
|
40813
|
-
*
|
|
40814
|
-
* })
|
|
41389
|
+
* import { declinePost } from '@amityco/ts-sdk-react-native'
|
|
41390
|
+
*
|
|
41391
|
+
* const {data: post} = await declinePost('postId')
|
|
40815
41392
|
* ```
|
|
40816
41393
|
*
|
|
40817
|
-
*
|
|
41394
|
+
* Declines a {@link Amity.Post}
|
|
40818
41395
|
*
|
|
40819
|
-
* @param
|
|
40820
|
-
* @
|
|
41396
|
+
* @param postId The {@link Amity.Post} ID to be declined
|
|
41397
|
+
* @return A {@link Amity.Post} that was declined
|
|
40821
41398
|
*
|
|
40822
|
-
* @category Post
|
|
41399
|
+
* @category Post API
|
|
41400
|
+
* @async
|
|
40823
41401
|
*/
|
|
40824
|
-
const
|
|
41402
|
+
const declinePost = async (postId) => {
|
|
41403
|
+
const client = getActiveClient();
|
|
41404
|
+
client.log('post/declinePost', postId);
|
|
41405
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
41406
|
+
// fire virtual event
|
|
41407
|
+
if (payload.posts[0].targetType === 'community') {
|
|
41408
|
+
fireEvent('community.updated', payload);
|
|
41409
|
+
}
|
|
41410
|
+
fireEvent('post.declined', payload);
|
|
41411
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41412
|
+
const cachedAt = client.cache && Date.now();
|
|
41413
|
+
if (client.cache)
|
|
41414
|
+
ingestInCache(data, { cachedAt });
|
|
41415
|
+
return {
|
|
41416
|
+
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
41417
|
+
cachedAt,
|
|
41418
|
+
};
|
|
41419
|
+
};
|
|
41420
|
+
/* end_public_function */
|
|
40825
41421
|
|
|
41422
|
+
/* begin_public_function
|
|
41423
|
+
id: post.flag
|
|
41424
|
+
*/
|
|
40826
41425
|
/**
|
|
40827
41426
|
* ```js
|
|
40828
|
-
* import {
|
|
40829
|
-
* const
|
|
40830
|
-
* // ...
|
|
40831
|
-
* })
|
|
41427
|
+
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
41428
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
40832
41429
|
* ```
|
|
40833
41430
|
*
|
|
40834
|
-
*
|
|
40835
|
-
*
|
|
40836
|
-
* @
|
|
40837
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
41431
|
+
* @param postId of the post to flag
|
|
41432
|
+
* @param reason the reason to flag the post
|
|
41433
|
+
* @returns a boolean
|
|
40838
41434
|
*
|
|
40839
|
-
* @category Post
|
|
40840
|
-
|
|
40841
|
-
|
|
41435
|
+
* @category Post API
|
|
41436
|
+
* @async
|
|
41437
|
+
* */
|
|
41438
|
+
const flagPost = async (postId, reason) => {
|
|
40842
41439
|
const client = getActiveClient();
|
|
40843
|
-
|
|
40844
|
-
|
|
40845
|
-
|
|
40846
|
-
|
|
40847
|
-
|
|
40848
|
-
|
|
40849
|
-
callback(post);
|
|
40850
|
-
}
|
|
41440
|
+
client.log('post/flagPost', postId);
|
|
41441
|
+
const isPredefinedReason = reason &&
|
|
41442
|
+
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
41443
|
+
const body = {
|
|
41444
|
+
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
41445
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
40851
41446
|
};
|
|
40852
|
-
|
|
41447
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
41448
|
+
if (client.cache) {
|
|
41449
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
41450
|
+
}
|
|
41451
|
+
fireEvent('post.flagged', payload);
|
|
41452
|
+
return !!payload;
|
|
40853
41453
|
};
|
|
41454
|
+
/* end_public_function */
|
|
40854
41455
|
|
|
41456
|
+
/* begin_public_function
|
|
41457
|
+
id: post.unflag
|
|
41458
|
+
*/
|
|
40855
41459
|
/**
|
|
40856
41460
|
* ```js
|
|
40857
|
-
* import {
|
|
40858
|
-
* const
|
|
40859
|
-
* // ...
|
|
40860
|
-
* })
|
|
41461
|
+
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
41462
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
40861
41463
|
* ```
|
|
40862
41464
|
*
|
|
40863
|
-
*
|
|
41465
|
+
* @param postId of the post to unflag
|
|
41466
|
+
* @returns the unflag post result
|
|
40864
41467
|
*
|
|
40865
|
-
* @
|
|
40866
|
-
* @
|
|
41468
|
+
* @category Post API
|
|
41469
|
+
* @async
|
|
41470
|
+
* */
|
|
41471
|
+
const unflagPost = async (postId) => {
|
|
41472
|
+
const client = getActiveClient();
|
|
41473
|
+
client.log('post/unflagPost', postId);
|
|
41474
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
41475
|
+
if (client.cache) {
|
|
41476
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
41477
|
+
}
|
|
41478
|
+
fireEvent('post.unflagged', payload);
|
|
41479
|
+
return !!payload;
|
|
41480
|
+
};
|
|
41481
|
+
/* end_public_function */
|
|
41482
|
+
|
|
41483
|
+
/* begin_public_function
|
|
41484
|
+
id: post.check_flag_by_me
|
|
41485
|
+
*/
|
|
41486
|
+
/**
|
|
41487
|
+
* ```js
|
|
41488
|
+
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
41489
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
41490
|
+
* ```
|
|
40867
41491
|
*
|
|
40868
|
-
* @
|
|
40869
|
-
|
|
40870
|
-
|
|
41492
|
+
* @param postId of the post to check if flagged by current user
|
|
41493
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
41494
|
+
*
|
|
41495
|
+
* @category Post API
|
|
41496
|
+
* @async
|
|
41497
|
+
* */
|
|
41498
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
40871
41499
|
const client = getActiveClient();
|
|
40872
|
-
|
|
40873
|
-
|
|
40874
|
-
|
|
40875
|
-
}
|
|
40876
|
-
else {
|
|
40877
|
-
upsertInCache(['post', 'get', post.postId], post);
|
|
40878
|
-
callback(post);
|
|
40879
|
-
}
|
|
40880
|
-
};
|
|
40881
|
-
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
41500
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
41501
|
+
const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
|
|
41502
|
+
return result;
|
|
40882
41503
|
};
|
|
41504
|
+
/* end_public_function */
|
|
40883
41505
|
|
|
41506
|
+
/* begin_public_function
|
|
41507
|
+
id: post.create.clip_post
|
|
41508
|
+
*/
|
|
40884
41509
|
/**
|
|
40885
41510
|
* ```js
|
|
40886
|
-
* import {
|
|
40887
|
-
* const
|
|
40888
|
-
*
|
|
40889
|
-
*
|
|
41511
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41512
|
+
* const created = await PostRepository.createClipPost({
|
|
41513
|
+
* targetType: 'user',
|
|
41514
|
+
* targetId: 'foobar',
|
|
41515
|
+
* dataType: 'clip',
|
|
41516
|
+
* data: { text: 'hello world' },
|
|
41517
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
41518
|
+
* }))
|
|
40890
41519
|
* ```
|
|
40891
41520
|
*
|
|
40892
|
-
*
|
|
41521
|
+
* Creates an {@link Amity.Post}
|
|
40893
41522
|
*
|
|
40894
|
-
* @param
|
|
40895
|
-
* @returns
|
|
41523
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
41524
|
+
* @returns The newly created {@link Amity.Post}
|
|
40896
41525
|
*
|
|
40897
|
-
* @category Post
|
|
41526
|
+
* @category Post API
|
|
41527
|
+
* @async
|
|
40898
41528
|
*/
|
|
40899
|
-
const
|
|
41529
|
+
const createClipPost = async (bundle) => {
|
|
41530
|
+
const client = getActiveClient();
|
|
41531
|
+
client.log('post/createPost', bundle);
|
|
41532
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
41533
|
+
fireEvent('post.created', payload);
|
|
41534
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41535
|
+
const cachedAt = client.cache && Date.now();
|
|
41536
|
+
if (client.cache)
|
|
41537
|
+
ingestInCache(data, { cachedAt });
|
|
41538
|
+
const { posts } = data;
|
|
41539
|
+
return {
|
|
41540
|
+
data: LinkedObject.post(posts[0]),
|
|
41541
|
+
cachedAt,
|
|
41542
|
+
};
|
|
41543
|
+
};
|
|
41544
|
+
/* end_public_function */
|
|
40900
41545
|
|
|
40901
41546
|
/* begin_public_function
|
|
40902
41547
|
id: post.get
|
|
@@ -40920,7 +41565,7 @@ const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.p
|
|
|
40920
41565
|
*
|
|
40921
41566
|
* @category Post Live Object
|
|
40922
41567
|
*/
|
|
40923
|
-
const getPost
|
|
41568
|
+
const getPost = (postId, callback) => {
|
|
40924
41569
|
const responder = (snapshot) => {
|
|
40925
41570
|
const { data } = snapshot;
|
|
40926
41571
|
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
@@ -41009,19 +41654,6 @@ class PostPaginationController extends PaginationController {
|
|
|
41009
41654
|
}
|
|
41010
41655
|
}
|
|
41011
41656
|
|
|
41012
|
-
var EnumPostActions;
|
|
41013
|
-
(function (EnumPostActions) {
|
|
41014
|
-
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
41015
|
-
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
41016
|
-
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
41017
|
-
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
41018
|
-
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
41019
|
-
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
41020
|
-
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
41021
|
-
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
41022
|
-
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
41023
|
-
})(EnumPostActions || (EnumPostActions = {}));
|
|
41024
|
-
|
|
41025
41657
|
class PostQueryStreamController extends QueryStreamController {
|
|
41026
41658
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
41027
41659
|
super(query, cacheKey);
|
|
@@ -41087,45 +41719,50 @@ class PostQueryStreamController extends QueryStreamController {
|
|
|
41087
41719
|
}
|
|
41088
41720
|
}
|
|
41089
41721
|
|
|
41090
|
-
const
|
|
41091
|
-
|
|
41092
|
-
|
|
41093
|
-
|
|
41094
|
-
|
|
41095
|
-
|
|
41096
|
-
|
|
41097
|
-
|
|
41098
|
-
|
|
41099
|
-
}
|
|
41100
|
-
catch (error) {
|
|
41101
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
41102
|
-
pushToTombstone('post', postId);
|
|
41103
|
-
}
|
|
41104
|
-
throw error;
|
|
41105
|
-
}
|
|
41106
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41107
|
-
const cachedAt = client.cache && Date.now();
|
|
41108
|
-
if (client.cache)
|
|
41109
|
-
ingestInCache(data, { cachedAt });
|
|
41110
|
-
const { posts } = data;
|
|
41111
|
-
const result = posts.find(post => post.postId === postId);
|
|
41112
|
-
return {
|
|
41113
|
-
data: result,
|
|
41114
|
-
cachedAt,
|
|
41115
|
-
};
|
|
41722
|
+
const commentEventHandler = (callback, eventHandler, cacheKey, resolveId) => {
|
|
41723
|
+
return eventHandler(async (comment) => {
|
|
41724
|
+
var _a;
|
|
41725
|
+
const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41726
|
+
if (!currentCollection ||
|
|
41727
|
+
!currentCollection.data.includes(resolveId ? resolveId(comment.referenceId) : comment.referenceId))
|
|
41728
|
+
return;
|
|
41729
|
+
await getPost$1(comment.referenceId);
|
|
41730
|
+
callback(comment);
|
|
41731
|
+
});
|
|
41116
41732
|
};
|
|
41117
|
-
|
|
41118
|
-
const
|
|
41119
|
-
|
|
41120
|
-
|
|
41121
|
-
|
|
41122
|
-
|
|
41123
|
-
|
|
41124
|
-
|
|
41125
|
-
|
|
41126
|
-
|
|
41127
|
-
|
|
41128
|
-
|
|
41733
|
+
const generateCommentSubscriptions = ({ cacheKey, resolveId, }) => {
|
|
41734
|
+
const eventHandlers = [
|
|
41735
|
+
onCommentCreated,
|
|
41736
|
+
onCommentDeleted,
|
|
41737
|
+
onCommentReactionAdded,
|
|
41738
|
+
onCommentReactionRemoved,
|
|
41739
|
+
onCommentCreatedLocal,
|
|
41740
|
+
onCommentDeleteLocal,
|
|
41741
|
+
onLocalCommentReactionAdded,
|
|
41742
|
+
onLocalCommentReactionRemoved,
|
|
41743
|
+
];
|
|
41744
|
+
return eventHandlers.map(handler => ({
|
|
41745
|
+
fn: convertEventPayload((callback) => commentEventHandler(callback, handler, cacheKey, resolveId), 'referenceId', 'post'),
|
|
41746
|
+
action: EnumPostActions.OnPostUpdated,
|
|
41747
|
+
}));
|
|
41748
|
+
};
|
|
41749
|
+
const getPostSubscription = (cacheKey) => {
|
|
41750
|
+
return [
|
|
41751
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
41752
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
41753
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
41754
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41755
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
41756
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
41757
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
41758
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
41759
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41760
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41761
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41762
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41763
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41764
|
+
...generateCommentSubscriptions({ cacheKey }),
|
|
41765
|
+
];
|
|
41129
41766
|
};
|
|
41130
41767
|
|
|
41131
41768
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
@@ -41156,47 +41793,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
41156
41793
|
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
41157
41794
|
}
|
|
41158
41795
|
startSubscription() {
|
|
41159
|
-
return this.queryStreamController.subscribeRTE(
|
|
41160
|
-
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
41161
|
-
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
41162
|
-
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
41163
|
-
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41164
|
-
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
41165
|
-
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
41166
|
-
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
41167
|
-
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
41168
|
-
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41169
|
-
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41170
|
-
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41171
|
-
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41172
|
-
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41173
|
-
{
|
|
41174
|
-
fn: convertEventPayload((callback) => {
|
|
41175
|
-
return onCommentCreated(async (comment) => {
|
|
41176
|
-
var _a;
|
|
41177
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41178
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
41179
|
-
return;
|
|
41180
|
-
await getPost(comment.referenceId);
|
|
41181
|
-
callback(comment);
|
|
41182
|
-
});
|
|
41183
|
-
}, 'referenceId', 'post'),
|
|
41184
|
-
action: EnumPostActions.OnPostUpdated,
|
|
41185
|
-
},
|
|
41186
|
-
{
|
|
41187
|
-
fn: convertEventPayload((callback) => {
|
|
41188
|
-
return onCommentDeleted(async (comment) => {
|
|
41189
|
-
var _a;
|
|
41190
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41191
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
41192
|
-
return;
|
|
41193
|
-
await getPost(comment.referenceId);
|
|
41194
|
-
callback(comment);
|
|
41195
|
-
});
|
|
41196
|
-
}, 'referenceId', 'post'),
|
|
41197
|
-
action: EnumPostActions.OnPostUpdated,
|
|
41198
|
-
},
|
|
41199
|
-
]);
|
|
41796
|
+
return this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
|
|
41200
41797
|
}
|
|
41201
41798
|
notifyChange({ origin, loading, error }) {
|
|
41202
41799
|
var _a, _b;
|
|
@@ -41331,6 +41928,22 @@ class PinnedPostQueryStreamController extends QueryStreamController {
|
|
|
41331
41928
|
});
|
|
41332
41929
|
}
|
|
41333
41930
|
}
|
|
41931
|
+
reactor(action) {
|
|
41932
|
+
return (post) => {
|
|
41933
|
+
var _a;
|
|
41934
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41935
|
+
if (!collection)
|
|
41936
|
+
return;
|
|
41937
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
41938
|
+
collection.data = collection.data.filter(referenceId => referenceId !== `global#${post.postId}`);
|
|
41939
|
+
}
|
|
41940
|
+
pushToCache(this.cacheKey, collection);
|
|
41941
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
41942
|
+
};
|
|
41943
|
+
}
|
|
41944
|
+
subscribeRTE(createSubscriber) {
|
|
41945
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
41946
|
+
}
|
|
41334
41947
|
}
|
|
41335
41948
|
|
|
41336
41949
|
class PinnedPostLiveCollectionController extends LiveCollectionController {
|
|
@@ -41362,7 +41975,10 @@ class PinnedPostLiveCollectionController extends LiveCollectionController {
|
|
|
41362
41975
|
}
|
|
41363
41976
|
// eslint-disable-next-line class-methods-use-this
|
|
41364
41977
|
startSubscription() {
|
|
41365
|
-
return
|
|
41978
|
+
return this.queryStreamController.subscribeRTE(generateCommentSubscriptions({
|
|
41979
|
+
cacheKey: this.cacheKey,
|
|
41980
|
+
resolveId: id => `${this.query.placement}#${id}`,
|
|
41981
|
+
}));
|
|
41366
41982
|
}
|
|
41367
41983
|
notifyChange({ origin, loading, error }) {
|
|
41368
41984
|
var _a, _b;
|
|
@@ -41514,6 +42130,10 @@ class GlobalPinnedPostLiveCollectionController extends LiveCollectionController
|
|
|
41514
42130
|
fn: onPostDeleted,
|
|
41515
42131
|
action: EnumPostActions.OnPostDeleted,
|
|
41516
42132
|
},
|
|
42133
|
+
...generateCommentSubscriptions({
|
|
42134
|
+
cacheKey: this.cacheKey,
|
|
42135
|
+
resolveId: id => `global#${id}`,
|
|
42136
|
+
}),
|
|
41517
42137
|
]);
|
|
41518
42138
|
}
|
|
41519
42139
|
notifyChange({ origin, loading, error }) {
|
|
@@ -41793,6 +42413,238 @@ const semanticSearchPosts = (params, callback, config) => {
|
|
|
41793
42413
|
};
|
|
41794
42414
|
};
|
|
41795
42415
|
|
|
42416
|
+
class SearchPostPaginationController extends PaginationController {
|
|
42417
|
+
async getRequest(queryParams, token) {
|
|
42418
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, matchingOnlyParentPost, hashtags, dataTypes, targetType = 'all' } = queryParams, params = __rest(queryParams, ["limit", "matchingOnlyParentPost", "hashtags", "dataTypes", "targetType"]);
|
|
42419
|
+
const baseOptions = {
|
|
42420
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
42421
|
+
};
|
|
42422
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
42423
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/search/posts`, {
|
|
42424
|
+
params: Object.assign(Object.assign({}, params), { hashtags,
|
|
42425
|
+
dataTypes,
|
|
42426
|
+
targetType,
|
|
42427
|
+
/*
|
|
42428
|
+
* when creating post like image, file, video BE will create 2 posts
|
|
42429
|
+
* 1. parent post to store text with dataType=text
|
|
42430
|
+
* 2. child post to store dataTypes post data
|
|
42431
|
+
*
|
|
42432
|
+
* By default, BE queries only parent post
|
|
42433
|
+
*/
|
|
42434
|
+
matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length), options }),
|
|
42435
|
+
});
|
|
42436
|
+
return queryResponse;
|
|
42437
|
+
}
|
|
42438
|
+
}
|
|
42439
|
+
|
|
42440
|
+
class SearchPostQueryStreamController extends QueryStreamController {
|
|
42441
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
42442
|
+
super(query, cacheKey);
|
|
42443
|
+
this.notifyChange = notifyChange;
|
|
42444
|
+
this.preparePayload = preparePayload;
|
|
42445
|
+
}
|
|
42446
|
+
async saveToMainDB(response) {
|
|
42447
|
+
const processedPayload = await this.preparePayload(response);
|
|
42448
|
+
const client = getActiveClient();
|
|
42449
|
+
const cachedAt = client.cache && Date.now();
|
|
42450
|
+
if (client.cache) {
|
|
42451
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
42452
|
+
}
|
|
42453
|
+
}
|
|
42454
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
42455
|
+
var _a, _b;
|
|
42456
|
+
if (refresh) {
|
|
42457
|
+
pushToCache(this.cacheKey, {
|
|
42458
|
+
data: response.posts.map(getResolver('post')),
|
|
42459
|
+
});
|
|
42460
|
+
}
|
|
42461
|
+
else {
|
|
42462
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42463
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
42464
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
42465
|
+
}
|
|
42466
|
+
}
|
|
42467
|
+
reactor(action) {
|
|
42468
|
+
return (post) => {
|
|
42469
|
+
var _a, _b;
|
|
42470
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42471
|
+
if (!collection)
|
|
42472
|
+
return;
|
|
42473
|
+
if (post.parentPostId && post.isDeleted) {
|
|
42474
|
+
const parentPost = (_b = pullFromCache([
|
|
42475
|
+
'post',
|
|
42476
|
+
'get',
|
|
42477
|
+
post.parentPostId,
|
|
42478
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
42479
|
+
if (!parentPost)
|
|
42480
|
+
return;
|
|
42481
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
42482
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
42483
|
+
}
|
|
42484
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
42485
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
42486
|
+
}
|
|
42487
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
42488
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
42489
|
+
}
|
|
42490
|
+
pushToCache(this.cacheKey, collection);
|
|
42491
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
42492
|
+
};
|
|
42493
|
+
}
|
|
42494
|
+
subscribeRTE(createSubscriber) {
|
|
42495
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
42496
|
+
}
|
|
42497
|
+
}
|
|
42498
|
+
|
|
42499
|
+
class SearchPostLiveCollectionController extends LiveCollectionController {
|
|
42500
|
+
constructor(query, callback) {
|
|
42501
|
+
const queryStreamId = hash(query);
|
|
42502
|
+
const cacheKey = ['posts', 'collection', queryStreamId];
|
|
42503
|
+
const paginationController = new SearchPostPaginationController(query);
|
|
42504
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
42505
|
+
this.query = query;
|
|
42506
|
+
this.queryStreamController = new SearchPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
42507
|
+
this.callback = callback.bind(this);
|
|
42508
|
+
this.loadPage({ initial: true });
|
|
42509
|
+
}
|
|
42510
|
+
setup() {
|
|
42511
|
+
var _a;
|
|
42512
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42513
|
+
if (!collection) {
|
|
42514
|
+
pushToCache(this.cacheKey, {
|
|
42515
|
+
data: [],
|
|
42516
|
+
params: {},
|
|
42517
|
+
});
|
|
42518
|
+
}
|
|
42519
|
+
}
|
|
42520
|
+
async persistModel(queryPayload) {
|
|
42521
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
42522
|
+
}
|
|
42523
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
42524
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
42525
|
+
}
|
|
42526
|
+
startSubscription() {
|
|
42527
|
+
return this.queryStreamController.subscribeRTE([
|
|
42528
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
42529
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
42530
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
42531
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
42532
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
42533
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
42534
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
42535
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
42536
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
42537
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
42538
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
42539
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
42540
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
42541
|
+
{
|
|
42542
|
+
fn: convertEventPayload((callback) => {
|
|
42543
|
+
return onCommentCreated(async (comment) => {
|
|
42544
|
+
var _a;
|
|
42545
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42546
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
42547
|
+
return;
|
|
42548
|
+
await getPost$1(comment.referenceId);
|
|
42549
|
+
callback(comment);
|
|
42550
|
+
});
|
|
42551
|
+
}, 'referenceId', 'post'),
|
|
42552
|
+
action: EnumPostActions.OnPostUpdated,
|
|
42553
|
+
},
|
|
42554
|
+
{
|
|
42555
|
+
fn: convertEventPayload((callback) => {
|
|
42556
|
+
return onCommentDeleted(async (comment) => {
|
|
42557
|
+
var _a;
|
|
42558
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42559
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
42560
|
+
return;
|
|
42561
|
+
await getPost$1(comment.referenceId);
|
|
42562
|
+
callback(comment);
|
|
42563
|
+
});
|
|
42564
|
+
}, 'referenceId', 'post'),
|
|
42565
|
+
action: EnumPostActions.OnPostUpdated,
|
|
42566
|
+
},
|
|
42567
|
+
]);
|
|
42568
|
+
}
|
|
42569
|
+
notifyChange({ origin, loading, error }) {
|
|
42570
|
+
var _a, _b;
|
|
42571
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42572
|
+
if (!collection)
|
|
42573
|
+
return;
|
|
42574
|
+
const data = this.applyFilter((_b = collection.data
|
|
42575
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
42576
|
+
.filter(isNonNullable)
|
|
42577
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
42578
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
42579
|
+
return;
|
|
42580
|
+
this.callback({
|
|
42581
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
42582
|
+
data,
|
|
42583
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
42584
|
+
loading,
|
|
42585
|
+
error,
|
|
42586
|
+
});
|
|
42587
|
+
}
|
|
42588
|
+
applyFilter(data) {
|
|
42589
|
+
var _a;
|
|
42590
|
+
let posts = data;
|
|
42591
|
+
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
42592
|
+
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
42593
|
+
}
|
|
42594
|
+
switch (this.query.sortBy) {
|
|
42595
|
+
case 'firstCreated':
|
|
42596
|
+
posts = posts.sort(sortByFirstCreated);
|
|
42597
|
+
break;
|
|
42598
|
+
case 'lastCreated':
|
|
42599
|
+
default:
|
|
42600
|
+
posts = posts.sort(sortByLastCreated);
|
|
42601
|
+
break;
|
|
42602
|
+
}
|
|
42603
|
+
return posts;
|
|
42604
|
+
}
|
|
42605
|
+
}
|
|
42606
|
+
|
|
42607
|
+
/* begin_public_function
|
|
42608
|
+
id: post.query
|
|
42609
|
+
*/
|
|
42610
|
+
/**
|
|
42611
|
+
* ```js
|
|
42612
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
42613
|
+
*
|
|
42614
|
+
* let posts = []
|
|
42615
|
+
* const unsub = PostRepository.searchPostsByHashtag({
|
|
42616
|
+
* hashtags: ['amity'],
|
|
42617
|
+
* limit: 10,
|
|
42618
|
+
* }, response => merge(posts, response.data))
|
|
42619
|
+
* ```
|
|
42620
|
+
*
|
|
42621
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
42622
|
+
*
|
|
42623
|
+
* @param params.hashtags the hashtags to search for
|
|
42624
|
+
* @param callback the function to call when new data are available
|
|
42625
|
+
* @param config
|
|
42626
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
42627
|
+
*
|
|
42628
|
+
* @category Posts Live Collection
|
|
42629
|
+
*/
|
|
42630
|
+
const searchPostsByHashtag = (params, callback, config) => {
|
|
42631
|
+
const { log, cache } = getActiveClient();
|
|
42632
|
+
if (!cache) {
|
|
42633
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
42634
|
+
}
|
|
42635
|
+
const timestamp = Date.now();
|
|
42636
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > listen`);
|
|
42637
|
+
const postsLiveCollection = new SearchPostLiveCollectionController(params, callback);
|
|
42638
|
+
const disposers = postsLiveCollection.startSubscription();
|
|
42639
|
+
const cacheKey = postsLiveCollection.getCacheKey();
|
|
42640
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
42641
|
+
return () => {
|
|
42642
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > dispose`);
|
|
42643
|
+
disposers.forEach(fn => fn());
|
|
42644
|
+
};
|
|
42645
|
+
};
|
|
42646
|
+
/* end_public_function */
|
|
42647
|
+
|
|
41796
42648
|
var index$8 = /*#__PURE__*/Object.freeze({
|
|
41797
42649
|
__proto__: null,
|
|
41798
42650
|
getPostByIds: getPostByIds,
|
|
@@ -41816,11 +42668,12 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
41816
42668
|
onPostUnflagged: onPostUnflagged,
|
|
41817
42669
|
onPostReactionAdded: onPostReactionAdded,
|
|
41818
42670
|
onPostReactionRemoved: onPostReactionRemoved,
|
|
41819
|
-
getPost: getPost
|
|
42671
|
+
getPost: getPost,
|
|
41820
42672
|
getPosts: getPosts,
|
|
41821
42673
|
getPinnedPosts: getPinnedPosts,
|
|
41822
42674
|
getGlobalPinnedPosts: getGlobalPinnedPosts,
|
|
41823
|
-
semanticSearchPosts: semanticSearchPosts
|
|
42675
|
+
semanticSearchPosts: semanticSearchPosts,
|
|
42676
|
+
searchPostsByHashtag: searchPostsByHashtag
|
|
41824
42677
|
});
|
|
41825
42678
|
|
|
41826
42679
|
/* begin_public_function
|
|
@@ -42418,8 +43271,8 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
42418
43271
|
* const created = await createPoll({
|
|
42419
43272
|
* question: 'question',
|
|
42420
43273
|
* answers: [
|
|
42421
|
-
* { dataType: 'text', data: 'answer1' },
|
|
42422
|
-
* { dataType: 'text', data: 'answer2' },
|
|
43274
|
+
* { dataType: 'text', data: 'answer1', fileId: 'fileId1' },
|
|
43275
|
+
* { dataType: 'text', data: 'answer2', fileId: 'fileId2' },
|
|
42423
43276
|
* ],
|
|
42424
43277
|
* closedIn: 1649136484
|
|
42425
43278
|
* }))
|
|
@@ -45006,4 +45859,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
45006
45859
|
getReactions: getReactions
|
|
45007
45860
|
});
|
|
45008
45861
|
|
|
45009
|
-
export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$
|
|
45862
|
+
export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$a as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$c as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, FeedDataTypeEnum, index$9 as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$l as FileRepository, FileType, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$j as MessageRepository, index$6 as PollRepository, PostContentType, index$8 as PostRepository, index$k as ReactionRepository, index$4 as StoryRepository, index$7 as StreamRepository, index$i as SubChannelRepository, SubscriptionLevels, index$m as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$2 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|