@amityco/ts-sdk 6.29.3-b60ec74.0 → 6.29.3-bd024fd.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +41 -11
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +1 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +18 -4
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts +4 -4
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts +21 -3
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +3 -3
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +2 -2
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberPaginationController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberPaginationController.d.ts.map +1 -1
- package/dist/channelRepository/events/onUserDeleted.d.ts +2 -0
- package/dist/channelRepository/events/onUserDeleted.d.ts.map +1 -0
- package/dist/commentRepository/api/createComment.d.ts.map +1 -1
- package/dist/commentRepository/api/deleteComment.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentCreatedLocal.d.ts +17 -0
- package/dist/commentRepository/events/onCommentCreatedLocal.d.ts.map +1 -0
- package/dist/commentRepository/events/onCommentDeletedLocal.d.ts +17 -0
- package/dist/commentRepository/events/onCommentDeletedLocal.d.ts.map +1 -0
- package/dist/commentRepository/events/onLocalCommentReactionAdded.d.ts +17 -0
- package/dist/commentRepository/events/onLocalCommentReactionAdded.d.ts.map +1 -0
- package/dist/commentRepository/events/onLocalCommentReactionRemoved.d.ts +17 -0
- package/dist/commentRepository/events/onLocalCommentReactionRemoved.d.ts.map +1 -0
- package/dist/commentRepository/events/utils.d.ts +1 -0
- package/dist/commentRepository/events/utils.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComment.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComments/CommentLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/index.d.ts +2 -0
- package/dist/communityRepository/communityMembership/events/index.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +17 -0
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +17 -0
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +17 -0
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/events/utils.d.ts +1 -0
- package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts +4 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +17 -0
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +17 -0
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -0
- package/dist/communityRepository/utils/payload.d.ts +1 -0
- package/dist/communityRepository/utils/payload.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/index.cjs.js +1622 -925
- package/dist/index.esm.js +1551 -854
- package/dist/index.umd.js +4 -4
- package/dist/postRepository/events/onLocalPostDeleted.d.ts +17 -0
- package/dist/postRepository/events/onLocalPostDeleted.d.ts.map +1 -0
- package/dist/postRepository/events/onLocalPostReactionAdded.d.ts +17 -0
- package/dist/postRepository/events/onLocalPostReactionAdded.d.ts.map +1 -0
- package/dist/postRepository/events/onLocalPostReactionRemoved.d.ts +17 -0
- package/dist/postRepository/events/onLocalPostReactionRemoved.d.ts.map +1 -0
- package/dist/postRepository/events/onPostUpdatedLocal.d.ts +17 -0
- package/dist/postRepository/events/onPostUpdatedLocal.d.ts.map +1 -0
- package/dist/postRepository/events/utils.d.ts +1 -0
- package/dist/postRepository/events/utils.d.ts.map +1 -1
- package/dist/postRepository/internalApi/index.d.ts +1 -12
- package/dist/postRepository/internalApi/index.d.ts.map +1 -1
- package/dist/postRepository/observers/getPost.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/utils/payload.d.ts.map +1 -1
- package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts +14 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserPaginationController.d.ts +5 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserPaginationController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts +15 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/enums.d.ts +11 -0
- package/dist/userRepository/relationship/follow/enums.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/index.d.ts +5 -0
- package/dist/userRepository/relationship/follow/events/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/events/onFollowInfoUpdated.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/events/onFollowerUserDeleted.d.ts +4 -0
- package/dist/userRepository/relationship/follow/events/onFollowerUserDeleted.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onFollowingUserDeleted.d.ts +4 -0
- package/dist/userRepository/relationship/follow/events/onFollowingUserDeleted.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestAccepted.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestAccepted.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestDeclined.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowRequestDeclined.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowerRequested.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalFollowerRequested.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserFollowed.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserFollowed.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserUnfollowed.d.ts +2 -0
- package/dist/userRepository/relationship/follow/events/onLocalUserUnfollowed.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/events/utils.d.ts +2 -1
- package/dist/userRepository/relationship/follow/events/utils.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.d.ts +14 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.d.ts +5 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerQueryStreamController.d.ts +15 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerQueryStreamController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.d.ts +14 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.d.ts +5 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingQueryStreamController.d.ts +15 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingQueryStreamController.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/utils.d.ts +4 -0
- package/dist/userRepository/relationship/follow/utils.d.ts.map +1 -0
- package/dist/userRepository/utils/convertRawUserToInternalUser.d.ts +2 -0
- package/dist/userRepository/utils/convertRawUserToInternalUser.d.ts.map +1 -0
- package/dist/userRepository/utils/prepareBlockedUserPayload.d.ts +2 -0
- package/dist/userRepository/utils/prepareBlockedUserPayload.d.ts.map +1 -0
- package/dist/userRepository/utils/prepareUserPayload.d.ts +2 -0
- package/dist/userRepository/utils/prepareUserPayload.d.ts.map +1 -0
- package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/tests/dummy/block.d.ts +2 -2
- package/dist/utils/tests/dummy/follow.d.ts +2 -2
- package/package.json +1 -1
- package/src/@types/core/events.ts +40 -13
- package/src/@types/core/model.ts +1 -1
- package/src/@types/core/payload.ts +27 -7
- package/src/@types/core/permissions.ts +4 -4
- package/src/@types/domains/follow.ts +26 -12
- package/src/@types/domains/post.ts +3 -3
- package/src/@types/domains/user.ts +2 -2
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +4 -4
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberPaginationController.ts +4 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.ts +6 -0
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberPaginationController.ts +4 -1
- package/src/channelRepository/events/onUserDeleted.ts +46 -0
- package/src/channelRepository/utils/prepareChannelPayload.ts +1 -1
- package/src/commentRepository/api/createComment.ts +16 -12
- package/src/commentRepository/api/deleteComment.ts +23 -13
- package/src/commentRepository/events/onCommentCreatedLocal.ts +22 -0
- package/src/commentRepository/events/onCommentDeletedLocal.ts +20 -0
- package/src/commentRepository/events/onLocalCommentReactionAdded.ts +42 -0
- package/src/commentRepository/events/onLocalCommentReactionRemoved.ts +42 -0
- package/src/commentRepository/events/utils.ts +78 -1
- package/src/commentRepository/observers/getComment.ts +6 -19
- package/src/commentRepository/observers/getComments/CommentLiveCollectionController.ts +8 -0
- package/src/communityRepository/communityMembership/api/addMembers.ts +1 -1
- package/src/communityRepository/communityMembership/api/removeMembers.ts +1 -1
- package/src/communityRepository/communityMembership/events/index.ts +2 -0
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +20 -0
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +20 -0
- package/src/communityRepository/communityMembership/events/onUserDeleted.ts +64 -0
- package/src/communityRepository/communityMembership/events/utils.ts +50 -2
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.ts +24 -5
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersPaginationController.ts +4 -1
- package/src/communityRepository/communityMembership/observers/getMembers/enums.ts +3 -0
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersLiveCollectionController.ts +12 -4
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersPaginationController.ts +4 -1
- package/src/communityRepository/communityModeration/api/addRoles.ts +5 -2
- package/src/communityRepository/communityModeration/api/removeRoles.ts +5 -2
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +38 -0
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +38 -0
- package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +3 -3
- package/src/communityRepository/utils/payload.ts +29 -0
- package/src/core/model/idResolvers.ts +1 -1
- package/src/postRepository/api/deletePost.ts +9 -9
- package/src/postRepository/api/updatePost.ts +1 -1
- package/src/postRepository/events/onLocalPostDeleted.ts +20 -0
- package/src/postRepository/events/onLocalPostReactionAdded.ts +38 -0
- package/src/postRepository/events/onLocalPostReactionRemoved.ts +41 -0
- package/src/postRepository/events/onPostUpdatedLocal.ts +20 -0
- package/src/postRepository/events/utils.ts +41 -6
- package/src/postRepository/internalApi/index.ts +1 -16
- package/src/postRepository/observers/getPost.ts +8 -0
- package/src/postRepository/observers/getPosts/PostLiveCollectionController.ts +8 -0
- package/src/postRepository/utils/payload.ts +10 -2
- package/src/reactionRepository/api/addReaction.ts +27 -2
- package/src/reactionRepository/api/removeReaction.ts +27 -2
- package/src/report/api/createReport.ts +1 -1
- package/src/report/api/deleteReport.ts +1 -1
- package/src/userRepository/api/flagUser.ts +1 -1
- package/src/userRepository/api/getUserByIds.ts +1 -1
- package/src/userRepository/api/queryBlockedUsers.ts +1 -1
- package/src/userRepository/api/unflagUser.ts +1 -1
- package/src/userRepository/api/updateUser.ts +1 -1
- package/src/userRepository/events/utils.ts +1 -1
- package/src/userRepository/internalApi/getUser.ts +1 -1
- package/src/userRepository/internalApi/queryUsers.ts +1 -1
- package/src/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.ts +106 -0
- package/src/userRepository/observers/getBlockedUsers/BlockedUserPaginationController.ts +24 -0
- package/src/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.ts +76 -0
- package/src/userRepository/observers/getBlockedUsers.ts +8 -81
- package/src/userRepository/observers/getUsers/UserLiveCollectionController.ts +4 -4
- package/src/userRepository/observers/searchUserByDisplayName/SearchUserLiveCollectionController.ts +1 -1
- package/src/userRepository/relationship/block/api/blockUser.ts +4 -1
- package/src/userRepository/relationship/block/api/unBlockUser.ts +4 -1
- package/src/userRepository/relationship/follow/api/acceptFollower.ts +4 -1
- package/src/userRepository/relationship/follow/api/acceptMyFollower.ts +4 -1
- package/src/userRepository/relationship/follow/api/declineFollower.ts +5 -2
- package/src/userRepository/relationship/follow/api/declineMyFollower.ts +5 -2
- package/src/userRepository/relationship/follow/api/follow.ts +8 -1
- package/src/userRepository/relationship/follow/api/unfollow.ts +4 -1
- package/src/userRepository/relationship/follow/api/utils.ts +6 -2
- package/src/userRepository/relationship/follow/enums.ts +10 -0
- package/src/userRepository/relationship/follow/events/index.ts +6 -0
- package/src/userRepository/relationship/follow/events/onFollowInfoUpdated.ts +6 -1
- package/src/userRepository/relationship/follow/events/onFollowerUserDeleted.ts +33 -0
- package/src/userRepository/relationship/follow/events/onFollowingUserDeleted.ts +33 -0
- package/src/userRepository/relationship/follow/events/onLocalFollowRequestAccepted.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalFollowRequestDeclined.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalFollowerRequested.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalUserFollowed.ts +5 -0
- package/src/userRepository/relationship/follow/events/onLocalUserUnfollowed.ts +5 -0
- package/src/userRepository/relationship/follow/events/utils.ts +25 -14
- package/src/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.ts +132 -0
- package/src/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.ts +29 -0
- package/src/userRepository/relationship/follow/observers/getFollowers/FollowerQueryStreamController.ts +95 -0
- package/src/userRepository/relationship/follow/observers/getFollowers.ts +8 -106
- package/src/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.ts +136 -0
- package/src/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.ts +29 -0
- package/src/userRepository/relationship/follow/observers/getFollowings/FollowingQueryStreamController.ts +95 -0
- package/src/userRepository/relationship/follow/observers/getFollowings.ts +6 -106
- package/src/userRepository/relationship/follow/observers/observeFollowers.ts +11 -0
- package/src/userRepository/relationship/follow/observers/observeFollowings.ts +11 -0
- package/src/userRepository/relationship/follow/utils.ts +36 -0
- package/src/userRepository/utils/convertRawUserToInternalUser.ts +6 -0
- package/src/userRepository/utils/prepareBlockedUserPayload.ts +19 -0
- package/src/userRepository/utils/{index.ts → prepareUserPayload.ts} +1 -6
- package/src/utils/linkedObject/commentLinkedObject.ts +13 -16
- package/src/utils/linkedObject/postLinkedObject.ts +0 -6
- package/dist/postRepository/internalApi/pinPost.d.ts +0 -6
- package/dist/postRepository/internalApi/pinPost.d.ts.map +0 -1
- package/dist/postRepository/internalApi/unpinPost.d.ts +0 -6
- package/dist/postRepository/internalApi/unpinPost.d.ts.map +0 -1
- package/dist/userRepository/utils/index.d.ts +0 -3
- package/dist/userRepository/utils/index.d.ts.map +0 -1
- package/src/postRepository/internalApi/pinPost.ts +0 -28
- package/src/postRepository/internalApi/unpinPost.ts +0 -28
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ```js
|
|
6
|
+
* import { onLocalCommunityRoleRemoved } from '@amityco/ts-sdk'
|
|
7
|
+
* const dispose = onLocalCommunityRoleRemoved((community, member) => {
|
|
8
|
+
* // ...
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Fired when any {@link Amity.communityUsers} 's role has been added to any {@link Amity.Community}
|
|
13
|
+
*
|
|
14
|
+
* @param callback The function to call when the event was fired
|
|
15
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16
|
+
*
|
|
17
|
+
* @category Community Events
|
|
18
|
+
*/
|
|
19
|
+
export const onLocalCommunityRoleRemoved = (
|
|
20
|
+
callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
|
|
21
|
+
): Amity.Unsubscriber => {
|
|
22
|
+
const client = getActiveClient();
|
|
23
|
+
|
|
24
|
+
const filter = async (payload: Amity.ProcessedCommunityMembershipPayload) => {
|
|
25
|
+
const { communities, communityUsers } = payload;
|
|
26
|
+
callback(
|
|
27
|
+
communities[0],
|
|
28
|
+
communityUsers.filter(communityUser => communityUser.communityMembership === 'member')!,
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return createEventSubscriber(
|
|
33
|
+
client,
|
|
34
|
+
'onLocalCommunityRoleRemoved',
|
|
35
|
+
'local.community.roleRemoved',
|
|
36
|
+
filter,
|
|
37
|
+
);
|
|
38
|
+
};
|
package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts
CHANGED
|
@@ -136,11 +136,11 @@ export class CommunityLiveCollectionController extends LiveCollectionController<
|
|
|
136
136
|
if (!this.query.displayName) {
|
|
137
137
|
const sortFn = (() => {
|
|
138
138
|
switch (this.query.sortBy) {
|
|
139
|
-
case
|
|
139
|
+
case 'firstCreated':
|
|
140
140
|
return sortByFirstCreated;
|
|
141
|
-
case
|
|
141
|
+
case 'lastCreated':
|
|
142
142
|
return sortByLastCreated;
|
|
143
|
-
case
|
|
143
|
+
case 'displayName':
|
|
144
144
|
return sortByDisplayName;
|
|
145
145
|
default:
|
|
146
146
|
return sortByLastCreated;
|
|
@@ -53,6 +53,35 @@ export const prepareCommunityPayload = (
|
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
export const prepareCommunityMembershipPayload = (
|
|
57
|
+
rawPayload: Amity.CommunityMembershipPayload,
|
|
58
|
+
): Amity.ProcessedCommunityMembershipPayload => {
|
|
59
|
+
const communitiesWithPostSetting = addPostSetting({ communities: rawPayload.communities });
|
|
60
|
+
|
|
61
|
+
// map users with community
|
|
62
|
+
const mappedCommunityUsers: Array<Amity.Membership<'community'>> = rawPayload.communityUsers.map(
|
|
63
|
+
communityUser => {
|
|
64
|
+
const user = rawPayload.users.find(user => user.userId === communityUser.userId)!;
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
...communityUser,
|
|
68
|
+
user,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const communityWithMembershipStatus = updateMembershipStatus(
|
|
74
|
+
communitiesWithPostSetting,
|
|
75
|
+
mappedCommunityUsers,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
...rawPayload,
|
|
80
|
+
communities: communityWithMembershipStatus,
|
|
81
|
+
communityUsers: mappedCommunityUsers,
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
56
85
|
export const prepareCommunityRequest = <
|
|
57
86
|
T extends {
|
|
58
87
|
postSetting?: Amity.Community['postSetting'];
|
|
@@ -57,7 +57,7 @@ const idResolvers: Resolvers = {
|
|
|
57
57
|
ad: ({ adId }) => adId,
|
|
58
58
|
advertiser: ({ advertiserId }) => advertiserId,
|
|
59
59
|
|
|
60
|
-
pin: ({ referenceId }) => referenceId
|
|
60
|
+
pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
|
|
61
61
|
pinTarget: ({ targetId }) => targetId,
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -71,7 +71,15 @@ export const deletePost = async (
|
|
|
71
71
|
// to support hard deletion
|
|
72
72
|
const deleted = { ...post.data, isDeleted: true };
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
if (permanent) {
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
pushToTombstone('post', postId);
|
|
77
|
+
}, 0);
|
|
78
|
+
} else {
|
|
79
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
fireEvent('local.post.deleted', {
|
|
75
83
|
posts: [deleted],
|
|
76
84
|
categories: [],
|
|
77
85
|
comments: [],
|
|
@@ -83,13 +91,5 @@ export const deletePost = async (
|
|
|
83
91
|
users: [],
|
|
84
92
|
});
|
|
85
93
|
|
|
86
|
-
if (permanent) {
|
|
87
|
-
setTimeout(() => {
|
|
88
|
-
pushToTombstone('post', postId);
|
|
89
|
-
}, 0);
|
|
90
|
-
} else {
|
|
91
|
-
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
94
|
return LinkedObject.post(deleted);
|
|
95
95
|
};
|
|
@@ -51,7 +51,7 @@ export const updatePost = async <T extends Amity.PostContentType>(
|
|
|
51
51
|
const cachedAt = client.cache && Date.now();
|
|
52
52
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
53
53
|
|
|
54
|
-
fireEvent('local.post.updated',
|
|
54
|
+
fireEvent('local.post.updated', payload);
|
|
55
55
|
|
|
56
56
|
const { posts } = data;
|
|
57
57
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createLocalPostEventSubscriber, createPostEventSubscriber } from './utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ```js
|
|
5
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
6
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
7
|
+
* // ...
|
|
8
|
+
* })
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
12
|
+
*
|
|
13
|
+
* @param callback The function to call when the event was fired
|
|
14
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
|
+
*
|
|
16
|
+
* @category Post Events
|
|
17
|
+
*/
|
|
18
|
+
export const onLocalPostDeleted = (
|
|
19
|
+
callback: Amity.Listener<Amity.InternalPost>,
|
|
20
|
+
): Amity.Unsubscriber => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
import { pullFromCache, upsertInCache } from '~/cache/api';
|
|
3
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
|
+
import { createEventSubscriber } from '~/core/events';
|
|
5
|
+
import { preparePostPayload } from '../utils/payload';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onPostReactionAdded(post => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
16
|
+
*
|
|
17
|
+
* @param callback The function to call when the event was fired
|
|
18
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
|
+
*
|
|
20
|
+
* @category Post Events
|
|
21
|
+
*/
|
|
22
|
+
export const onLocalPostReactionAdded = (
|
|
23
|
+
callback: Amity.Listener<Amity.InternalPost>,
|
|
24
|
+
): Amity.Unsubscriber => {
|
|
25
|
+
const client = getActiveClient();
|
|
26
|
+
|
|
27
|
+
const filter = ({ post }: Amity.Events['local.post.addReaction']) => {
|
|
28
|
+
if (!client.cache) {
|
|
29
|
+
callback(post);
|
|
30
|
+
} else {
|
|
31
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
32
|
+
|
|
33
|
+
callback(post);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
38
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
import { pullFromCache, upsertInCache } from '~/cache/api';
|
|
3
|
+
import { createEventSubscriber } from '~/core/events';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ```js
|
|
7
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
|
|
8
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
9
|
+
* // ...
|
|
10
|
+
* })
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
14
|
+
*
|
|
15
|
+
* @param callback The function to call when the event was fired
|
|
16
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
17
|
+
*
|
|
18
|
+
* @category Post Events
|
|
19
|
+
*/
|
|
20
|
+
export const onLocalPostReactionRemoved = (
|
|
21
|
+
callback: Amity.Listener<Amity.InternalPost>,
|
|
22
|
+
): Amity.Unsubscriber => {
|
|
23
|
+
const client = getActiveClient();
|
|
24
|
+
|
|
25
|
+
const filter = ({ post }: Amity.Events['local.post.removeReaction']) => {
|
|
26
|
+
if (!client.cache) {
|
|
27
|
+
callback(post);
|
|
28
|
+
} else {
|
|
29
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
30
|
+
|
|
31
|
+
callback(post);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return createEventSubscriber(
|
|
36
|
+
client,
|
|
37
|
+
'local.post.removeReaction',
|
|
38
|
+
'local.post.removeReaction',
|
|
39
|
+
filter,
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createLocalPostEventSubscriber } from './utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ```js
|
|
5
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk'
|
|
6
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
7
|
+
* // ...
|
|
8
|
+
* })
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
12
|
+
*
|
|
13
|
+
* @param callback The function to call when the event was fired
|
|
14
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
|
+
*
|
|
16
|
+
* @category Post Events
|
|
17
|
+
*/
|
|
18
|
+
export const onPostUpdatedLocal = (
|
|
19
|
+
callback: Amity.Listener<Amity.InternalPost>,
|
|
20
|
+
): Amity.Unsubscriber => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api';
|
|
2
2
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
3
3
|
import { createEventSubscriber, fireEvent } from '~/core/events';
|
|
4
|
-
import { pullFromCache, queryCache, upsertInCache } from '~/cache/api';
|
|
5
|
-
import { pushToTombstone } from '~/cache/api/pushToTombstone';
|
|
6
|
-
import { prepareMembershipPayload } from '~/group/utils';
|
|
4
|
+
import { dropFromCache, pullFromCache, queryCache, upsertInCache } from '~/cache/api';
|
|
7
5
|
import { isInTombstone } from '~/cache/api/isInTombstone';
|
|
6
|
+
import { preparePostPayload } from '~/postRepository/utils/payload';
|
|
8
7
|
|
|
9
8
|
export const createPostEventSubscriber = (
|
|
10
9
|
event: keyof Amity.MqttPostEvents,
|
|
@@ -16,9 +15,9 @@ export const createPostEventSubscriber = (
|
|
|
16
15
|
if (!client.cache) {
|
|
17
16
|
callback(payload.posts[0]);
|
|
18
17
|
} else {
|
|
19
|
-
const
|
|
18
|
+
const data = preparePostPayload(payload);
|
|
20
19
|
|
|
21
|
-
const
|
|
20
|
+
const { communities } = data;
|
|
22
21
|
|
|
23
22
|
ingestInCache(data);
|
|
24
23
|
|
|
@@ -49,7 +48,7 @@ export const createPostEventSubscriber = (
|
|
|
49
48
|
// But if it is hard delete, it will pushed into tombstone before fire an event to BE. it means it will stay in tombstone already
|
|
50
49
|
// and will got skip to notify in a previous code block
|
|
51
50
|
if (postedUserId !== client.userId) {
|
|
52
|
-
|
|
51
|
+
dropFromCache(['post', 'get', postId]);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
return callback(payload.posts[0]);
|
|
@@ -76,3 +75,39 @@ export const createPostEventSubscriber = (
|
|
|
76
75
|
|
|
77
76
|
return createEventSubscriber(client, event, event, filter);
|
|
78
77
|
};
|
|
78
|
+
|
|
79
|
+
export const createLocalPostEventSubscriber = (
|
|
80
|
+
event: keyof Omit<Amity.LocalPostEvents, 'local.post.addReaction' | 'local.post.removeReaction'>,
|
|
81
|
+
callback: Amity.Listener<Amity.InternalPost>,
|
|
82
|
+
) => {
|
|
83
|
+
const client = getActiveClient();
|
|
84
|
+
|
|
85
|
+
const filter = (payload: Amity.PostPayload) => {
|
|
86
|
+
if (!client.cache) {
|
|
87
|
+
callback(payload.posts[0]);
|
|
88
|
+
} else {
|
|
89
|
+
const data = preparePostPayload(payload);
|
|
90
|
+
|
|
91
|
+
const { communities } = data;
|
|
92
|
+
|
|
93
|
+
ingestInCache(data);
|
|
94
|
+
|
|
95
|
+
if (communities?.[0] && !['local.post.updated'].includes(event)) {
|
|
96
|
+
fireEvent('community.updated', {
|
|
97
|
+
communities,
|
|
98
|
+
categories: [],
|
|
99
|
+
communityUsers: data.communityUsers,
|
|
100
|
+
feeds: [],
|
|
101
|
+
files: [],
|
|
102
|
+
users: [],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const post = pullFromCache<Amity.InternalPost>(['post', 'get', payload.posts[0].postId])!;
|
|
107
|
+
|
|
108
|
+
callback(post.data);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return createEventSubscriber(client, event, event, filter);
|
|
113
|
+
};
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
|
|
3
|
-
export * from './createPost';
|
|
4
|
-
export * from './updatePost';
|
|
5
|
-
export * from './editPost';
|
|
6
|
-
|
|
7
|
-
export * from './deletePost';
|
|
8
|
-
export * from './softDeletePost';
|
|
9
|
-
export * from './hardDeletePost';
|
|
10
|
-
|
|
11
|
-
export * from './approvePost';
|
|
12
|
-
export * from './declinePost';
|
|
13
|
-
|
|
14
|
-
export * from './flagPost';
|
|
15
|
-
export * from './unflagPost';
|
|
16
|
-
export * from './isPostFlaggedByMe';
|
|
1
|
+
export * from './getPost';
|
|
@@ -15,6 +15,10 @@ import { pullFromCache, pushToCache } from '~/cache/api';
|
|
|
15
15
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
16
16
|
import { onCommentCreated, onCommentDeleted } from '~/commentRepository';
|
|
17
17
|
import { convertEventPayload } from '~/utils/event';
|
|
18
|
+
import { onPostUpdatedLocal } from '~/postRepository/events/onPostUpdatedLocal';
|
|
19
|
+
import { onLocalPostReactionAdded } from '~/postRepository/events/onLocalPostReactionAdded';
|
|
20
|
+
import { onLocalPostReactionRemoved } from '~/postRepository/events/onLocalPostReactionRemoved';
|
|
21
|
+
import { onLocalPostDeleted } from '~/postRepository/events/onLocalPostDeleted';
|
|
18
22
|
|
|
19
23
|
/* begin_public_function
|
|
20
24
|
id: post.get
|
|
@@ -52,6 +56,8 @@ export const getPost = (
|
|
|
52
56
|
return liveObject(postId, responder, 'postId', _getPost, [
|
|
53
57
|
onPostApproved,
|
|
54
58
|
onPostDeclined,
|
|
59
|
+
onLocalPostReactionAdded,
|
|
60
|
+
onLocalPostReactionRemoved,
|
|
55
61
|
(callback: Amity.Listener<Amity.InternalPost>) => {
|
|
56
62
|
return onPostDeleted((post: Amity.InternalPost) => {
|
|
57
63
|
let targetPost = post;
|
|
@@ -89,6 +95,8 @@ export const getPost = (
|
|
|
89
95
|
},
|
|
90
96
|
onPostUnflagged,
|
|
91
97
|
onPostUpdated,
|
|
98
|
+
onPostUpdatedLocal,
|
|
99
|
+
onLocalPostDeleted,
|
|
92
100
|
convertEventPayload(
|
|
93
101
|
(callback: Amity.Listener<Amity.InternalComment>) => {
|
|
94
102
|
return onCommentCreated(async (comment: Amity.InternalComment) => {
|
|
@@ -28,6 +28,10 @@ import { preparePostPayload } from '~/postRepository/utils/payload';
|
|
|
28
28
|
import { convertEventPayload } from '~/utils/event';
|
|
29
29
|
import { onCommentCreated, onCommentDeleted } from '~/commentRepository';
|
|
30
30
|
import { getPost } from '~/postRepository/internalApi/getPost';
|
|
31
|
+
import { onPostUpdatedLocal } from '~/postRepository/events/onPostUpdatedLocal';
|
|
32
|
+
import { onLocalPostReactionAdded } from '~/postRepository/events/onLocalPostReactionAdded';
|
|
33
|
+
import { onLocalPostReactionRemoved } from '~/postRepository/events/onLocalPostReactionRemoved';
|
|
34
|
+
import { onLocalPostDeleted } from '~/postRepository/events/onLocalPostDeleted';
|
|
31
35
|
|
|
32
36
|
export class PostLiveCollectionController extends LiveCollectionController<
|
|
33
37
|
'post',
|
|
@@ -84,6 +88,7 @@ export class PostLiveCollectionController extends LiveCollectionController<
|
|
|
84
88
|
return this.queryStreamController.subscribeRTE([
|
|
85
89
|
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
86
90
|
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
91
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
87
92
|
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
88
93
|
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
89
94
|
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
@@ -91,6 +96,9 @@ export class PostLiveCollectionController extends LiveCollectionController<
|
|
|
91
96
|
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
92
97
|
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
93
98
|
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
99
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
100
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
101
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
94
102
|
{
|
|
95
103
|
fn: convertEventPayload(
|
|
96
104
|
(callback: Amity.Listener<Amity.InternalComment>) => {
|
|
@@ -2,8 +2,6 @@ import { addPostSetting } from '~/communityRepository/utils';
|
|
|
2
2
|
import { updateMembershipStatus } from '~/communityRepository/utils/communityWithMembership';
|
|
3
3
|
|
|
4
4
|
export const preparePostPayload = (postPayload: Amity.PostPayload): Amity.ProcessedPostPayload => {
|
|
5
|
-
const { posts } = postPayload;
|
|
6
|
-
|
|
7
5
|
// Unpack community payload by mapping payload field to postSetting value.
|
|
8
6
|
const communitiesWithPostSetting = addPostSetting({ communities: postPayload.communities });
|
|
9
7
|
|
|
@@ -24,6 +22,16 @@ export const preparePostPayload = (postPayload: Amity.PostPayload): Amity.Proces
|
|
|
24
22
|
mappedCommunityUsers,
|
|
25
23
|
);
|
|
26
24
|
|
|
25
|
+
// feed type
|
|
26
|
+
const posts = postPayload.posts.map(post => {
|
|
27
|
+
const feedType = postPayload.feeds.find(feed => feed.feedId === post.feedId)?.feedType;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
...post,
|
|
31
|
+
feedType,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
27
35
|
return {
|
|
28
36
|
...postPayload,
|
|
29
37
|
posts,
|
|
@@ -4,6 +4,7 @@ import { upsertInCache, pullFromCache, pushToCache } from '~/cache/api';
|
|
|
4
4
|
|
|
5
5
|
import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
|
|
6
6
|
import { dispatchReactable } from '../utils';
|
|
7
|
+
import { fireEvent } from '~/core/events';
|
|
7
8
|
|
|
8
9
|
/* begin_public_function
|
|
9
10
|
id: reaction.add
|
|
@@ -50,8 +51,32 @@ export const addReaction = async (
|
|
|
50
51
|
referenceId,
|
|
51
52
|
]);
|
|
52
53
|
|
|
53
|
-
model
|
|
54
|
-
|
|
54
|
+
if (!model) return true;
|
|
55
|
+
|
|
56
|
+
const updatedModel = {
|
|
57
|
+
...model.data,
|
|
58
|
+
reactionsCount: model.data.reactionsCount + 1,
|
|
59
|
+
myReactions: [...(model.data.myReactions ?? []), reactionName],
|
|
60
|
+
reactions: {
|
|
61
|
+
...model.data.reactions,
|
|
62
|
+
[reactionName]: (model.data.reactions[reactionName] ?? 0) + 1,
|
|
63
|
+
},
|
|
64
|
+
} as Amity.Models[Amity.ReactableType];
|
|
65
|
+
|
|
66
|
+
if (referenceType === 'comment') {
|
|
67
|
+
fireEvent('local.comment.addReaction', {
|
|
68
|
+
comment: updatedModel as Amity.InternalComment,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (referenceType === 'post') {
|
|
74
|
+
fireEvent('local.post.addReaction', {
|
|
75
|
+
post: updatedModel as Amity.InternalPost,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
55
80
|
}
|
|
56
81
|
|
|
57
82
|
return true;
|
|
@@ -5,6 +5,7 @@ import { upsertInCache, pullFromCache, pushToCache } from '~/cache/api';
|
|
|
5
5
|
import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
|
|
6
6
|
|
|
7
7
|
import { dispatchReactable } from '../utils';
|
|
8
|
+
import { fireEvent } from '~/core/events';
|
|
8
9
|
|
|
9
10
|
/* begin_public_function
|
|
10
11
|
id: reaction.remove
|
|
@@ -53,8 +54,32 @@ export const removeReaction = async (
|
|
|
53
54
|
referenceId,
|
|
54
55
|
]);
|
|
55
56
|
|
|
56
|
-
model
|
|
57
|
-
|
|
57
|
+
if (!model) return true;
|
|
58
|
+
|
|
59
|
+
const updatedModel = {
|
|
60
|
+
...model.data,
|
|
61
|
+
reactionsCount: Math.max(0, model.data.reactionsCount - 1),
|
|
62
|
+
myReactions: (model.data.myReactions ?? []).filter(item => item !== reactionName),
|
|
63
|
+
reactions: {
|
|
64
|
+
...model.data.reactions,
|
|
65
|
+
[reactionName]: Math.max(0, (model.data.reactions[reactionName] ?? 0) - 1),
|
|
66
|
+
},
|
|
67
|
+
} as Amity.Models[Amity.ReactableType];
|
|
68
|
+
|
|
69
|
+
if (referenceType === 'comment') {
|
|
70
|
+
fireEvent('local.comment.removeReaction', {
|
|
71
|
+
comment: updatedModel as Amity.InternalComment,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (referenceType === 'post') {
|
|
77
|
+
fireEvent('local.post.removeReaction', {
|
|
78
|
+
post: updatedModel as Amity.InternalPost,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
58
83
|
}
|
|
59
84
|
|
|
60
85
|
return true;
|
|
@@ -4,7 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
5
|
import { prepareMessagePayload } from '~/messageRepository/utils';
|
|
6
6
|
import { preparePostPayload } from '~/postRepository/utils/payload';
|
|
7
|
-
import { prepareUserPayload } from '~/userRepository/utils';
|
|
7
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
8
8
|
import { prepareCommentPayload } from '~/commentRepository/utils/payload';
|
|
9
9
|
|
|
10
10
|
const createMessageReport = async ({
|
|
@@ -5,7 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
import { fireEvent } from '~/core/events';
|
|
6
6
|
import { prepareMessagePayload } from '~/messageRepository/utils';
|
|
7
7
|
import { preparePostPayload } from '~/postRepository/utils/payload';
|
|
8
|
-
import { prepareUserPayload } from '~/userRepository/utils';
|
|
8
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
9
9
|
import { prepareCommentPayload } from '~/commentRepository/utils/payload';
|
|
10
10
|
|
|
11
11
|
const deleteMessageReport = async ({
|
|
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
|
-
import { prepareUserPayload } from '
|
|
5
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
6
6
|
|
|
7
7
|
/* begin_public_function
|
|
8
8
|
id: user.flag
|
|
@@ -4,7 +4,7 @@ import { pullFromCache } from '~/cache/api';
|
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
import { fireEvent } from '~/core/events';
|
|
6
6
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
7
|
-
import { prepareUserPayload } from '
|
|
7
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
8
8
|
|
|
9
9
|
/* begin_public_function
|
|
10
10
|
id: user.get_by_ids
|
|
@@ -3,7 +3,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
3
3
|
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
4
4
|
import { getResolver } from '~/core/model';
|
|
5
5
|
import { toPageRaw } from '~/core/query';
|
|
6
|
-
import { prepareUserPayload } from '
|
|
6
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* ```js
|
|
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
|
-
import { prepareUserPayload } from '
|
|
5
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
6
6
|
|
|
7
7
|
/* begin_public_function
|
|
8
8
|
id: user.unflag
|
|
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
|
|
3
3
|
import { fireEvent } from '~/core/events';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
-
import { prepareUserPayload } from '
|
|
5
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
6
6
|
|
|
7
7
|
/* begin_public_function
|
|
8
8
|
id: client.update_user
|
|
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
2
2
|
import { createEventSubscriber } from '~/core/events';
|
|
3
3
|
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
-
import { prepareUserPayload } from '../utils';
|
|
5
|
+
import { prepareUserPayload } from '../utils/prepareUserPayload';
|
|
6
6
|
|
|
7
7
|
export const createUserEventSubscriber = (
|
|
8
8
|
event: keyof Amity.MqttUserEvents,
|
|
@@ -7,7 +7,7 @@ import { fireEvent } from '~/core/events';
|
|
|
7
7
|
import { isInTombstone } from '~/cache/api/isInTombstone';
|
|
8
8
|
import { checkIfShouldGoesToTombstone } from '~/cache/utils';
|
|
9
9
|
import { pushToTombstone } from '~/cache/api/pushToTombstone';
|
|
10
|
-
import { prepareUserPayload } from '
|
|
10
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* ```js
|
|
@@ -4,7 +4,7 @@ import { pullFromCache, pushToCache } from '~/cache/api';
|
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
import { getResolver } from '~/core/model';
|
|
6
6
|
import { fireEvent } from '~/core/events';
|
|
7
|
-
import { prepareUserPayload } from '
|
|
7
|
+
import { prepareUserPayload } from '~/userRepository/utils/prepareUserPayload';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* ```js
|