@amityco/ts-sdk 6.12.2-d74459e.0 → 6.12.2-e855934.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -9
- package/dist/@types/core/marker.d.ts +4 -4
- package/dist/@types/core/marker.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -4
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +17 -17
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/block.d.ts +1 -1
- package/dist/@types/domains/block.d.ts.map +1 -1
- package/dist/@types/domains/category.d.ts +5 -2
- package/dist/@types/domains/category.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +3 -3
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +1 -1
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +4 -4
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts +4 -4
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -2
- package/dist/@types/domains/group.d.ts.map +1 -1
- package/dist/@types/domains/messagePreview.d.ts +2 -2
- package/dist/@types/domains/messagePreview.d.ts.map +1 -1
- package/dist/@types/domains/poll.d.ts +1 -1
- package/dist/@types/domains/poll.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +1 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/reaction.d.ts +1 -1
- package/dist/@types/domains/reaction.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +2 -2
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +7 -3
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/cache/api/pushToCache.d.ts +1 -1
- package/dist/cache/api/upsertInCache.d.ts +1 -1
- package/dist/categoryRepository/api/getCategory.d.ts.map +1 -1
- package/dist/categoryRepository/api/queryCategories.d.ts.map +1 -1
- package/dist/categoryRepository/observers/getCategories.d.ts.map +1 -1
- package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts +4 -4
- package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts +4 -4
- package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/addRole.d.ts +4 -4
- package/dist/channelRepsitory/channelModeration/api/addRole.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts +2 -2
- package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts +4 -4
- package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts +2 -2
- package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/events/onChannelMemberAdded.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberBanned.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberRemoved.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberUnbanned.d.ts +1 -1
- package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts +2 -0
- package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts.map +1 -0
- package/dist/client/api/getToken.d.ts +3 -3
- package/dist/client/api/getToken.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts +1 -1
- package/dist/communityRepository/communityMembership/api/addMembers.d.ts +4 -4
- package/dist/communityRepository/communityMembership/api/addMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/removeMembers.d.ts +4 -4
- package/dist/communityRepository/communityMembership/api/removeMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts +4 -4
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts +2 -2
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts +4 -4
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts +2 -2
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/core/device.d.ts +1 -1
- package/dist/core/device.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +2 -2
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/external/api/createUserToken.d.ts +2 -2
- package/dist/external/api/createUserToken.d.ts.map +1 -1
- package/dist/group/utils/withUser.d.ts +3 -3
- package/dist/group/utils/withUser.d.ts.map +1 -1
- package/dist/index.cjs.js +206 -126
- package/dist/index.esm.js +206 -126
- package/dist/index.umd.js +4 -4
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messageRepository/api/getDeliveredUsers.d.ts +6 -6
- package/dist/messageRepository/api/getDeliveredUsers.d.ts.map +1 -1
- package/dist/messageRepository/api/getReadUsers.d.ts +6 -6
- package/dist/messageRepository/api/getReadUsers.d.ts.map +1 -1
- package/dist/streamRepository/api/getStreams.d.ts +1 -1
- package/dist/streamRepository/api/getStreams.d.ts.map +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts +1 -1
- package/dist/userRepository/api/flagUser.d.ts.map +1 -1
- package/dist/userRepository/api/getUser.d.ts.map +1 -1
- package/dist/userRepository/api/getUserByIds.d.ts +1 -1
- package/dist/userRepository/api/getUserByIds.d.ts.map +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -1
- package/dist/userRepository/api/queryBlockedUsers.d.ts +5 -5
- package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/api/queryUsers.d.ts +6 -6
- package/dist/userRepository/api/queryUsers.d.ts.map +1 -1
- package/dist/userRepository/api/unflagUser.d.ts +1 -1
- package/dist/userRepository/api/unflagUser.d.ts.map +1 -1
- package/dist/userRepository/api/updateUser.d.ts +4 -4
- package/dist/userRepository/api/updateUser.d.ts.map +1 -1
- package/dist/userRepository/events/onUserDeleted.d.ts +2 -2
- package/dist/userRepository/events/onUserDeleted.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFetched.d.ts +2 -2
- package/dist/userRepository/events/onUserFetched.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFlagCleared.d.ts +2 -2
- package/dist/userRepository/events/onUserFlagCleared.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFlagged.d.ts +2 -2
- package/dist/userRepository/events/onUserFlagged.d.ts.map +1 -1
- package/dist/userRepository/events/onUserUnflagged.d.ts +2 -2
- package/dist/userRepository/events/onUserUnflagged.d.ts.map +1 -1
- package/dist/userRepository/events/onUserUpdated.d.ts +2 -2
- package/dist/userRepository/events/onUserUpdated.d.ts.map +1 -1
- package/dist/userRepository/events/utils.d.ts +1 -1
- package/dist/userRepository/events/utils.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/getUser.d.ts +2 -2
- package/dist/userRepository/observers/getUser.d.ts.map +1 -1
- package/dist/userRepository/observers/getUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/observeUser.d.ts +2 -2
- package/dist/userRepository/observers/observeUser.d.ts.map +1 -1
- package/dist/userRepository/observers/searchUserByDisplayName.d.ts +2 -2
- package/dist/userRepository/observers/searchUserByDisplayName.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/blockUser.d.ts +4 -4
- package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts +4 -4
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/follow.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts +4 -4
- package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts +3 -3
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts +2 -2
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts +2 -2
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts.map +1 -1
- package/dist/utils/linkedObject/categoryLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/categoryLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +2 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/userLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/userLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/client.d.ts.map +1 -1
- package/dist/utils/tests/dummy/block.d.ts +4 -4
- package/dist/utils/tests/dummy/block.d.ts.map +1 -1
- package/dist/utils/tests/dummy/category.d.ts +7 -0
- package/dist/utils/tests/dummy/category.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +11 -1
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +6 -6
- package/dist/utils/tests/dummy/follow.d.ts +1 -1
- package/dist/utils/tests/dummy/follow.d.ts.map +1 -1
- package/dist/utils/tests/dummy/user.d.ts +5 -1
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/marker.ts +4 -4
- package/src/@types/core/model.ts +4 -4
- package/src/@types/core/payload.ts +17 -17
- package/src/@types/domains/block.ts +1 -1
- package/src/@types/domains/category.ts +6 -2
- package/src/@types/domains/client.ts +3 -3
- package/src/@types/domains/comment.ts +1 -1
- package/src/@types/domains/community.ts +4 -4
- package/src/@types/domains/follow.ts +4 -4
- package/src/@types/domains/group.ts +2 -2
- package/src/@types/domains/messagePreview.ts +2 -2
- package/src/@types/domains/poll.ts +1 -1
- package/src/@types/domains/post.ts +1 -1
- package/src/@types/domains/reaction.ts +1 -1
- package/src/@types/domains/stream.ts +2 -2
- package/src/@types/domains/user.ts +8 -3
- package/src/cache/api/pushToCache.ts +1 -1
- package/src/cache/api/upsertInCache.ts +1 -1
- package/src/categoryRepository/api/getCategory.ts +3 -2
- package/src/categoryRepository/api/queryCategories.ts +7 -1
- package/src/categoryRepository/observers/getCategories.ts +3 -2
- package/src/categoryRepository/observers/tests/getCategories.test.ts +2 -1
- package/src/channelRepsitory/api/createChannel.ts +1 -1
- package/src/channelRepsitory/channelMembership/api/addMembers.ts +4 -4
- package/src/channelRepsitory/channelMembership/api/removeMembers.ts +4 -4
- package/src/channelRepsitory/channelMembership/observers/tests/getMembers.test.ts +1 -1
- package/src/channelRepsitory/channelMembership/observers/tests/searchMembers.test.ts +1 -3
- package/src/channelRepsitory/channelModeration/api/addRole.ts +4 -4
- package/src/channelRepsitory/channelModeration/api/banMembers.ts +2 -2
- package/src/channelRepsitory/channelModeration/api/removeRole.ts +4 -4
- package/src/channelRepsitory/channelModeration/api/unbanMembers.ts +2 -2
- package/src/channelRepsitory/events/onChannelMemberAdded.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberBanned.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberRemoved.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberUnbanned.ts +1 -1
- package/src/channelRepsitory/observers/tests/getChannel.test.ts +73 -0
- package/src/channelRepsitory/observers/tests/getChannels.test.ts +462 -50
- package/src/client/api/getToken.ts +3 -3
- package/src/client/api/login.ts +1 -1
- package/src/communityRepository/communityMembership/api/addMembers.ts +4 -4
- package/src/communityRepository/communityMembership/api/removeMembers.ts +4 -4
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/communityRepository/communityMembership/observers/tests/getMembers.test.ts +1 -1
- package/src/communityRepository/communityModeration/api/addRoles.ts +4 -4
- package/src/communityRepository/communityModeration/api/banMembers.ts +2 -2
- package/src/communityRepository/communityModeration/api/removeRoles.ts +4 -4
- package/src/communityRepository/communityModeration/api/unbanMembers.ts +2 -2
- package/src/core/device.ts +1 -1
- package/src/core/query/filtering.ts +3 -1
- package/src/core/query/tests/filtering.test.ts +2 -2
- package/src/external/api/createUserToken.ts +2 -2
- package/src/group/utils/withUser.ts +8 -4
- package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +1 -1
- package/src/messagePreview/utils/getSubChannelMessagePreviewWithUser.ts +1 -1
- package/src/messageRepository/api/getDeliveredUsers.ts +11 -9
- package/src/messageRepository/api/getReadUsers.ts +11 -9
- package/src/messageRepository/observers/tests/getMessages.test.ts +766 -0
- package/src/streamRepository/api/getStreams.ts +1 -1
- package/src/streamRepository/api/queryStreams.ts +1 -1
- package/src/subChannelRepository/observers/tests/getSubChannels.test.ts +308 -15
- package/src/userRepository/api/flagUser.ts +1 -1
- package/src/userRepository/api/getUser.ts +2 -1
- package/src/userRepository/api/getUserByIds.ts +4 -3
- package/src/userRepository/api/isUserFlaggedByMe.ts +1 -1
- package/src/userRepository/api/queryBlockedUsers.ts +10 -8
- package/src/userRepository/api/queryUsers.ts +12 -10
- package/src/userRepository/api/unflagUser.ts +1 -1
- package/src/userRepository/api/updateUser.ts +6 -6
- package/src/userRepository/events/onUserDeleted.ts +2 -2
- package/src/userRepository/events/onUserFetched.ts +2 -2
- package/src/userRepository/events/onUserFlagCleared.ts +2 -2
- package/src/userRepository/events/onUserFlagged.ts +2 -2
- package/src/userRepository/events/onUserUnflagged.ts +2 -2
- package/src/userRepository/events/onUserUpdated.ts +2 -2
- package/src/userRepository/events/utils.ts +1 -1
- package/src/userRepository/observers/getBlockedUsers.ts +8 -7
- package/src/userRepository/observers/getUser.ts +3 -3
- package/src/userRepository/observers/getUsers.ts +2 -2
- package/src/userRepository/observers/observeUser.ts +9 -6
- package/src/userRepository/observers/searchUserByDisplayName.ts +2 -2
- package/src/userRepository/observers/tests/getUser.test.ts +1 -1
- package/src/userRepository/observers/tests/getUsers.test.ts +12 -11
- package/src/userRepository/observers/tests/searchUserByDisplayName.test.ts +1 -1
- package/src/userRepository/relationship/block/api/blockUser.ts +6 -4
- package/src/userRepository/relationship/block/api/unBlockUser.ts +6 -4
- package/src/userRepository/relationship/block/observers/getBlockedUsers.ts +1 -1
- package/src/userRepository/relationship/follow/api/acceptFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/acceptMyFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/declineFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/declineMyFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/follow.ts +2 -2
- package/src/userRepository/relationship/follow/api/getFollowInfo.ts +4 -4
- package/src/userRepository/relationship/follow/api/unfollow.ts +3 -3
- package/src/userRepository/relationship/follow/api/utils.ts +1 -1
- package/src/userRepository/relationship/follow/observers/getFollowers.ts +1 -1
- package/src/userRepository/relationship/follow/observers/getFollowings.ts +1 -1
- package/src/userRepository/relationship/follow/observers/observeFollowInfo.ts +1 -1
- package/src/userRepository/relationship/follow/observers/observeFollowers.ts +2 -2
- package/src/userRepository/relationship/follow/observers/observeFollowings.ts +2 -2
- package/src/utils/linkedObject/categoryLinkedObject.ts +40 -0
- package/src/utils/linkedObject/index.ts +4 -0
- package/src/utils/linkedObject/userLinkedObject.ts +36 -0
- package/src/utils/tests/client.ts +1 -0
- package/src/utils/tests/dummy/block.ts +3 -3
- package/src/utils/tests/dummy/category.ts +5 -0
- package/src/utils/tests/dummy/channel.ts +58 -1
- package/src/utils/tests/dummy/community.ts +1 -1
- package/src/utils/tests/dummy/follow.ts +1 -1
- package/src/utils/tests/dummy/user.ts +3 -1
- package/tsconfig.json +18 -23
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a flag has been removed from a {@link Amity.
|
|
11
|
+
* Fired when a flag has been removed from a {@link Amity.InternalUser}
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserUnflagged = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserUnflagged = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.unflagged', callback);
|
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalUser} has been updated
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserUpdated = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserUpdated = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.updated', callback);
|
|
@@ -5,7 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
export const createUserEventSubscriber = (
|
|
7
7
|
event: keyof Amity.MqttUserEvents,
|
|
8
|
-
callback: Amity.Listener<Amity.
|
|
8
|
+
callback: Amity.Listener<Amity.InternalUser>,
|
|
9
9
|
) => {
|
|
10
10
|
const client = getActiveClient();
|
|
11
11
|
|
|
@@ -10,6 +10,7 @@ import { createQuery, queryOptions, runQuery, toToken } from '~/core/query';
|
|
|
10
10
|
import { CACHE_SHORTEN_LIFESPAN } from '~/cache/utils';
|
|
11
11
|
import { getResolver } from '~/core/model';
|
|
12
12
|
import { queryBlockedUsers } from '../api/queryBlockedUsers';
|
|
13
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
13
14
|
|
|
14
15
|
/* begin_public_function
|
|
15
16
|
id: user.get_blocked_users
|
|
@@ -20,10 +21,10 @@ import { queryBlockedUsers } from '../api/queryBlockedUsers';
|
|
|
20
21
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
21
22
|
* ```
|
|
22
23
|
*
|
|
23
|
-
* Blocks a {@link Amity.
|
|
24
|
+
* Blocks a {@link Amity.InternalUser}
|
|
24
25
|
*
|
|
25
|
-
* @param params The params to get blocked {@link Amity.
|
|
26
|
-
* @param callback to recieve updates on unblocked {@link Amity.
|
|
26
|
+
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
27
|
+
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
27
28
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
28
29
|
*
|
|
29
30
|
* @category Post API
|
|
@@ -31,7 +32,7 @@ import { queryBlockedUsers } from '../api/queryBlockedUsers';
|
|
|
31
32
|
*/
|
|
32
33
|
export const getBlockedUsers = (
|
|
33
34
|
params: Amity.BlockedUsersLiveCollection,
|
|
34
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
35
|
+
callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
|
|
35
36
|
config?: Amity.LiveCollectionConfig,
|
|
36
37
|
): Amity.Unsubscriber => {
|
|
37
38
|
const { log, cache } = getActiveClient();
|
|
@@ -52,11 +53,11 @@ export const getBlockedUsers = (
|
|
|
52
53
|
const cacheKey = ['blockedUsers', 'collection', {}];
|
|
53
54
|
|
|
54
55
|
const responder = (data: Amity.BlockedUserLiveCollectionCache) => {
|
|
55
|
-
const users: Amity.
|
|
56
|
+
const users: Amity.InternalUser[] =
|
|
56
57
|
data.data
|
|
57
|
-
.map(userId => pullFromCache<Amity.
|
|
58
|
+
.map(userId => pullFromCache<Amity.InternalUser>(['user', 'get', userId])!)
|
|
58
59
|
.filter(Boolean)
|
|
59
|
-
.map(({ data }) => data) ?? [];
|
|
60
|
+
.map(({ data }) => LinkedObject.user(data)) ?? [];
|
|
60
61
|
|
|
61
62
|
callback({
|
|
62
63
|
onNextPage: onFetch,
|
|
@@ -23,7 +23,7 @@ import { getUser as _getUser } from '../api/getUser';
|
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
* Observe all mutation on a given {@link Amity.
|
|
26
|
+
* Observe all mutation on a given {@link Amity.InternalUser}
|
|
27
27
|
*
|
|
28
28
|
* @param userId the ID of the user to observe
|
|
29
29
|
* @param callback the function to call when new data are available
|
|
@@ -32,8 +32,8 @@ import { getUser as _getUser } from '../api/getUser';
|
|
|
32
32
|
* @category Message Live Object
|
|
33
33
|
*/
|
|
34
34
|
export const getUser = (
|
|
35
|
-
userId: Amity.
|
|
36
|
-
callback: Amity.LiveObjectCallback<Amity.
|
|
35
|
+
userId: Amity.InternalUser['userId'],
|
|
36
|
+
callback: Amity.LiveObjectCallback<Amity.InternalUser>,
|
|
37
37
|
): Amity.Unsubscriber => {
|
|
38
38
|
return liveObject(userId, callback, 'userId', _getUser, [
|
|
39
39
|
onUserFetched,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
onUserUnflagged,
|
|
29
29
|
onUserUpdated,
|
|
30
30
|
} from '../events';
|
|
31
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
31
32
|
|
|
32
33
|
/*
|
|
33
34
|
* Exported for testing
|
|
@@ -106,7 +107,7 @@ export const getUsers = (
|
|
|
106
107
|
data.data
|
|
107
108
|
.map(userId => pullFromCache<Amity.User>(['user', 'get', userId])!)
|
|
108
109
|
.filter(Boolean)
|
|
109
|
-
.map(({ data }) => data) ?? [];
|
|
110
|
+
.map(({ data }) => LinkedObject.user(data)) ?? [];
|
|
110
111
|
|
|
111
112
|
callback({
|
|
112
113
|
onNextPage: onFetch,
|
|
@@ -125,7 +126,6 @@ export const getUsers = (
|
|
|
125
126
|
if (!collection) return;
|
|
126
127
|
|
|
127
128
|
collection.data = [...new Set([user.userId, ...collection.data])];
|
|
128
|
-
|
|
129
129
|
pushToCache(cacheKey, collection);
|
|
130
130
|
responder(collection, true);
|
|
131
131
|
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
onUserUnflagged,
|
|
11
11
|
onUserFlagCleared,
|
|
12
12
|
} from '../events';
|
|
13
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* ```js
|
|
@@ -23,14 +24,14 @@ import {
|
|
|
23
24
|
* @param callback the function to call when new data are available
|
|
24
25
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the user
|
|
25
26
|
*
|
|
26
|
-
* Observe all mutation on a given {@link Amity.
|
|
27
|
+
* Observe all mutation on a given {@link Amity.InternalUser}
|
|
27
28
|
* @category User Observer
|
|
28
29
|
*/
|
|
29
30
|
export const observeUser = <
|
|
30
31
|
Events extends ['onFetch', 'onUpdate', 'onDelete', 'onFlagged', 'onUnflagged', 'onFlagCleared'],
|
|
31
32
|
>(
|
|
32
33
|
userId: string,
|
|
33
|
-
callback: Amity.ObjectListener<Amity.Snapshot<Amity.
|
|
34
|
+
callback: Amity.ObjectListener<Amity.Snapshot<Amity.InternalUser>, Events>,
|
|
34
35
|
): Amity.Unsubscriber => {
|
|
35
36
|
const { log } = getActiveClient();
|
|
36
37
|
|
|
@@ -38,15 +39,17 @@ export const observeUser = <
|
|
|
38
39
|
log(`observeUser(tmpid: ${timestamp}) > listen`);
|
|
39
40
|
|
|
40
41
|
// wrapper function to make sure
|
|
41
|
-
const router = (result: Amity.Snapshot<Amity.
|
|
42
|
+
const router = (result: Amity.Snapshot<Amity.InternalUser>, action: Events[number]) => {
|
|
42
43
|
// filter function
|
|
43
44
|
if (result.data?.userId !== userId) return;
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
const newResult = { ...result, data: LinkedObject.user(result.data) };
|
|
46
47
|
|
|
47
|
-
if (
|
|
48
|
+
if (callback instanceof Function) return callback(newResult);
|
|
48
49
|
|
|
49
|
-
callback
|
|
50
|
+
if (action !== 'onFetch') callback.onEvent?.(action, newResult);
|
|
51
|
+
|
|
52
|
+
callback[action]?.(newResult);
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
const disposers: Amity.Unsubscriber[] = [];
|
|
@@ -11,7 +11,7 @@ import { getUsers } from './getUsers';
|
|
|
11
11
|
* const unsub = UserRepository.searchUserByDisplayName({}, response => merge(users, response.data))
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
|
-
* Observe all mutations on a list of {@link Amity.
|
|
14
|
+
* Observe all mutations on a list of {@link Amity.InternalUser}s
|
|
15
15
|
*
|
|
16
16
|
* @param params for searching users
|
|
17
17
|
* @param callback the function to call when new data are available
|
|
@@ -22,7 +22,7 @@ import { getUsers } from './getUsers';
|
|
|
22
22
|
*/
|
|
23
23
|
export const searchUserByDisplayName = (
|
|
24
24
|
params: Amity.UserSearchLiveCollection,
|
|
25
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
25
|
+
callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
|
|
26
26
|
config?: Amity.LiveCollectionConfig,
|
|
27
27
|
) => {
|
|
28
28
|
return getUsers({ ...params, filter: 'all' }, callback, config);
|
|
@@ -18,7 +18,7 @@ const { getUsers, applyFilter } = getUsersModule;
|
|
|
18
18
|
|
|
19
19
|
const getSnapshot = (params?: Record<string, any>) => {
|
|
20
20
|
return {
|
|
21
|
-
data: [] as Amity.
|
|
21
|
+
data: [] as Amity.InternalUser[],
|
|
22
22
|
loading: true,
|
|
23
23
|
error: undefined as any,
|
|
24
24
|
...params,
|
|
@@ -127,7 +127,7 @@ describe('getUsers', () => {
|
|
|
127
127
|
const unflaggedUser = { ...user11, flagCount: 1 };
|
|
128
128
|
const flagClearedUser = { ...user11, flagCount: 0 };
|
|
129
129
|
|
|
130
|
-
const cases: [string, keyof Amity.Events, Amity.UserPayload, Amity.
|
|
130
|
+
const cases: [string, keyof Amity.Events, Amity.UserPayload, Amity.InternalUser[]][] = [
|
|
131
131
|
[
|
|
132
132
|
'it should update user in collection onUpdate',
|
|
133
133
|
'user.updated',
|
|
@@ -198,20 +198,21 @@ describe('getUsers > applyFilter', () => {
|
|
|
198
198
|
userId: 'test',
|
|
199
199
|
displayName: 'a',
|
|
200
200
|
createdAt: new Date().toISOString(),
|
|
201
|
-
} as Amity.
|
|
201
|
+
} as Amity.InternalUser;
|
|
202
202
|
|
|
203
203
|
const u2 = {
|
|
204
204
|
userId: 'searchable',
|
|
205
205
|
displayName: 'b',
|
|
206
206
|
createdAt: getPastDate(),
|
|
207
|
-
} as Amity.
|
|
208
|
-
|
|
209
|
-
const filters: [string, Amity.UserLiveCollection, Amity.
|
|
210
|
-
[
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
207
|
+
} as Amity.InternalUser;
|
|
208
|
+
|
|
209
|
+
const filters: [string, Amity.UserLiveCollection, Amity.InternalUser[], Amity.InternalUser[]][] =
|
|
210
|
+
[
|
|
211
|
+
['it should filter by display name', { displayName: 'a' }, [u1, u2], [u1]],
|
|
212
|
+
['it should sort by dispaly name', {}, [u1, u2], [u1, u2]],
|
|
213
|
+
['it should sort by last created', { sortBy: 'lastCreated' }, [u1, u2], [u1, u2]],
|
|
214
|
+
['it should sort by first created', { sortBy: 'firstCreated' }, [u1, u2], [u2, u1]],
|
|
215
|
+
];
|
|
215
216
|
|
|
216
217
|
test.each(filters)('%s', (test, param, input, expected) => {
|
|
217
218
|
expect(applyFilter(input, param)).toStrictEqual(expected);
|
|
@@ -13,7 +13,7 @@ import { searchUserByDisplayName } from '../searchUserByDisplayName';
|
|
|
13
13
|
|
|
14
14
|
const getSnapshot = (params?: Record<string, any>) => {
|
|
15
15
|
return {
|
|
16
|
-
data: [] as Amity.
|
|
16
|
+
data: [] as Amity.InternalUser[],
|
|
17
17
|
loading: true,
|
|
18
18
|
error: undefined as any,
|
|
19
19
|
...params,
|
|
@@ -12,15 +12,17 @@ import { upsertInCache } from '~/cache/api';
|
|
|
12
12
|
* const blockedUser = await UserRepository.blockUser('userId')
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Blocks a {@link Amity.
|
|
15
|
+
* Blocks a {@link Amity.InternalUser}
|
|
16
16
|
*
|
|
17
|
-
* @param userId The ID of the {@link Amity.
|
|
18
|
-
* @returns the blocked {@link Amity.
|
|
17
|
+
* @param userId The ID of the {@link Amity.InternalUser} to block
|
|
18
|
+
* @returns the blocked {@link Amity.InternalUser} object
|
|
19
19
|
*
|
|
20
20
|
* @category Post API
|
|
21
21
|
* @async
|
|
22
22
|
*/
|
|
23
|
-
export const blockUser = async (
|
|
23
|
+
export const blockUser = async (
|
|
24
|
+
userId: Amity.InternalUser['userId'],
|
|
25
|
+
): Promise<Amity.BlockedPayload> => {
|
|
24
26
|
const client = getActiveClient();
|
|
25
27
|
|
|
26
28
|
client.log('user/blockUser', userId);
|
|
@@ -12,15 +12,17 @@ import { upsertInCache } from '~/cache/api';
|
|
|
12
12
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Blocks a {@link Amity.
|
|
15
|
+
* Blocks a {@link Amity.InternalUser}
|
|
16
16
|
*
|
|
17
|
-
* @param userId The ID of the {@link Amity.
|
|
18
|
-
* @returns the unblocked {@link Amity.
|
|
17
|
+
* @param userId The ID of the {@link Amity.InternalUser} to unblock
|
|
18
|
+
* @returns the unblocked {@link Amity.InternalUser} object
|
|
19
19
|
*
|
|
20
20
|
* @category Post API
|
|
21
21
|
* @async
|
|
22
22
|
*/
|
|
23
|
-
export const unBlockUser = async (
|
|
23
|
+
export const unBlockUser = async (
|
|
24
|
+
userId: Amity.InternalUser['userId'],
|
|
25
|
+
): Promise<Amity.BlockedPayload> => {
|
|
24
26
|
const client = getActiveClient();
|
|
25
27
|
|
|
26
28
|
client.log('user/unBlockUser', userId);
|
|
@@ -3,7 +3,7 @@ import { getBlockedUsers as _getBlockedUsers } from '../../../observers/getBlock
|
|
|
3
3
|
|
|
4
4
|
export const getBlockedUsers = (
|
|
5
5
|
params: Amity.BlockedUsersLiveCollection,
|
|
6
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
6
|
+
callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
|
|
7
7
|
config?: Amity.LiveCollectionConfig,
|
|
8
8
|
) => {
|
|
9
9
|
console.log(
|
|
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
|
|
|
13
13
|
*
|
|
14
14
|
* Accept the follow request
|
|
15
15
|
*
|
|
16
|
-
* @param userId the ID of the {@link Amity.
|
|
16
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
17
17
|
* @returns A success boolean if the follow request was accepted
|
|
18
18
|
*
|
|
19
19
|
* @category Follow API
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
|
-
export const acceptFollower = async (userId: Amity.
|
|
22
|
+
export const acceptFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
|
|
23
23
|
const client = getActiveClient();
|
|
24
24
|
client.log('follow/acceptFollower', userId);
|
|
25
25
|
|
|
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
|
|
|
13
13
|
*
|
|
14
14
|
* Accept the follow request
|
|
15
15
|
*
|
|
16
|
-
* @param userId the ID of the {@link Amity.
|
|
16
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
17
17
|
* @returns A success boolean if the follow request was accepted
|
|
18
18
|
*
|
|
19
19
|
* @category Follow API
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
|
-
export const acceptMyFollower = async (userId: Amity.
|
|
22
|
+
export const acceptMyFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
|
|
23
23
|
const client = getActiveClient();
|
|
24
24
|
client.log('follow/acceptMyFollower', userId);
|
|
25
25
|
|
|
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
|
|
|
13
13
|
*
|
|
14
14
|
* Decline the follow request or delete the follower
|
|
15
15
|
*
|
|
16
|
-
* @param userId the ID of the {@link Amity.
|
|
16
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
17
17
|
* @returns A success boolean if the follow request was decline
|
|
18
18
|
*
|
|
19
19
|
* @category Follow API
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
|
-
export const declineFollower = async (userId: Amity.
|
|
22
|
+
export const declineFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
|
|
23
23
|
const client = getActiveClient();
|
|
24
24
|
client.log('follow/declineFollower', userId);
|
|
25
25
|
|
|
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
|
|
|
13
13
|
*
|
|
14
14
|
* Decline the follow request or delete the follower
|
|
15
15
|
*
|
|
16
|
-
* @param userId the ID of the {@link Amity.
|
|
16
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
17
17
|
* @returns A success boolean if the follow request was decline
|
|
18
18
|
*
|
|
19
19
|
* @category Follow API
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
|
-
export const declineMyFollower = async (userId: Amity.
|
|
22
|
+
export const declineMyFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
|
|
23
23
|
const client = getActiveClient();
|
|
24
24
|
client.log('follow/declineMyFollower', userId);
|
|
25
25
|
|
|
@@ -13,14 +13,14 @@ import { fireEvent } from '~/core/events';
|
|
|
13
13
|
*
|
|
14
14
|
* Follow the user
|
|
15
15
|
*
|
|
16
|
-
* @param userId the ID of the {@link Amity.
|
|
16
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
17
17
|
* @returns the status {@link Amity.FollowStatus}
|
|
18
18
|
*
|
|
19
19
|
* @category Follow API
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
22
|
export const follow = async (
|
|
23
|
-
userId: Amity.
|
|
23
|
+
userId: Amity.InternalUser['userId'],
|
|
24
24
|
): Promise<Amity.Cached<Amity.FollowStatus>> => {
|
|
25
25
|
const client = getActiveClient();
|
|
26
26
|
client.log('follow/follow', userId);
|
|
@@ -9,14 +9,14 @@ import { pullFromCache, pushToCache } from '~/cache/api';
|
|
|
9
9
|
*
|
|
10
10
|
* Fetches the number of followers, followings, pending requests and the follow status for current user
|
|
11
11
|
*
|
|
12
|
-
* @param userId the ID of the {@link Amity.
|
|
12
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
13
13
|
* @returns the associated {@link Amity.FollowInfo} object
|
|
14
14
|
*
|
|
15
15
|
* @category Follow API
|
|
16
16
|
* @async
|
|
17
17
|
*/
|
|
18
18
|
export const getFollowInfo = async (
|
|
19
|
-
userId: Amity.
|
|
19
|
+
userId: Amity.InternalUser['userId'],
|
|
20
20
|
): Promise<Amity.Cached<Amity.FollowInfo>> => {
|
|
21
21
|
const client = getActiveClient();
|
|
22
22
|
client.log('follow/getFollowInfo', userId);
|
|
@@ -54,13 +54,13 @@ export const getFollowInfo = async (
|
|
|
54
54
|
*
|
|
55
55
|
* Fetches the number of followers, followings, pending requests and the follow status for current user from cache
|
|
56
56
|
*
|
|
57
|
-
* @param userId the ID of the {@link Amity.
|
|
57
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
58
58
|
* @returns the associated {@link Amity.FollowInfo} object
|
|
59
59
|
*
|
|
60
60
|
* @category Follow API
|
|
61
61
|
*/
|
|
62
62
|
getFollowInfo.locally = (
|
|
63
|
-
userId: Amity.
|
|
63
|
+
userId: Amity.InternalUser['userId'],
|
|
64
64
|
): Amity.Cached<Amity.FollowInfo> | undefined => {
|
|
65
65
|
const client = getActiveClient();
|
|
66
66
|
client.log('follow/getFollowInfo.locally', userId);
|
|
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
|
|
|
13
13
|
*
|
|
14
14
|
* Cancel the follow request or unfollow the user
|
|
15
15
|
*
|
|
16
|
-
* @param userId the ID of the {@link Amity.
|
|
17
|
-
* @returns A success boolean if the user {@link Amity.
|
|
16
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
17
|
+
* @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
|
|
18
18
|
*
|
|
19
19
|
* @category Follow API
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
|
-
export const unfollow = async (userId: Amity.
|
|
22
|
+
export const unfollow = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
|
|
23
23
|
const client = getActiveClient();
|
|
24
24
|
client.log('follow/unfollow', userId);
|
|
25
25
|
|
|
@@ -7,7 +7,7 @@ import { getResolver } from '~/core/model';
|
|
|
7
7
|
export const queryFollows = async (
|
|
8
8
|
key: 'followers' | 'following',
|
|
9
9
|
query: {
|
|
10
|
-
userId: Amity.
|
|
10
|
+
userId: Amity.InternalUser['userId'];
|
|
11
11
|
status?: Exclude<Amity.FollowStatusType, 'none'>;
|
|
12
12
|
page?: Amity.PageRaw;
|
|
13
13
|
},
|
|
@@ -29,7 +29,7 @@ import { queryFollowers } from '../api/queryFollowers';
|
|
|
29
29
|
*
|
|
30
30
|
* let followers = []
|
|
31
31
|
* const unsub = getFollowers({
|
|
32
|
-
* userId: Amity.
|
|
32
|
+
* userId: Amity.InternalUser['userId'];
|
|
33
33
|
* }, response => merge(followers, response.data))
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
@@ -29,7 +29,7 @@ import { queryFollowings } from '../api/queryFollowings';
|
|
|
29
29
|
*
|
|
30
30
|
* let followings = []
|
|
31
31
|
* const unsub = getFollowings({
|
|
32
|
-
* userId: Amity.
|
|
32
|
+
* userId: Amity.InternalUser['userId'];
|
|
33
33
|
* }, response => merge(followings, response.data))
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
@@ -20,7 +20,7 @@ import { onFollowInfoUpdated } from '../events';
|
|
|
20
20
|
* @category Follow Observer
|
|
21
21
|
*/
|
|
22
22
|
export const observeFollowInfo = <Events extends ['onFetch', 'onUpdate']>(
|
|
23
|
-
userId: Amity.
|
|
23
|
+
userId: Amity.InternalUser['userId'],
|
|
24
24
|
callback: Amity.ObjectListener<Amity.Snapshot<Amity.FollowInfo>, Events>,
|
|
25
25
|
policy: Amity.QueryPolicy = 'cache_then_server',
|
|
26
26
|
): Amity.Unsubscriber => {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
*
|
|
21
21
|
* Observe all mutations on a list of followers {@link Amity.FollowStatus} for a given user
|
|
22
22
|
*
|
|
23
|
-
* @param userId the ID of the {@link Amity.
|
|
23
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
24
24
|
* @param callback the function to call when new data are available
|
|
25
25
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
26
26
|
*
|
|
@@ -37,7 +37,7 @@ export const observeFollowers = <
|
|
|
37
37
|
'onDeleted',
|
|
38
38
|
],
|
|
39
39
|
>(
|
|
40
|
-
userId: Amity.
|
|
40
|
+
userId: Amity.InternalUser['userId'],
|
|
41
41
|
callback: Amity.ObjectListener<Amity.FollowStatus, Events>,
|
|
42
42
|
): Amity.Unsubscriber => {
|
|
43
43
|
const { log } = getActiveClient();
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
*
|
|
21
21
|
* Observe all mutations on a list of followings {@link Amity.FollowStatus} for a given user
|
|
22
22
|
*
|
|
23
|
-
* @param userId the ID of the {@link Amity.
|
|
23
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
24
24
|
* @param callback the function to call when new data are available
|
|
25
25
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
26
26
|
*
|
|
@@ -37,7 +37,7 @@ export const observeFollowings = <
|
|
|
37
37
|
'onDeleted',
|
|
38
38
|
],
|
|
39
39
|
>(
|
|
40
|
-
userId: Amity.
|
|
40
|
+
userId: Amity.InternalUser['userId'],
|
|
41
41
|
callback: Amity.ObjectListener<Amity.FollowStatus, Events>,
|
|
42
42
|
): Amity.Unsubscriber => {
|
|
43
43
|
const { log } = getActiveClient();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { pullFromCache } from '~/cache/api';
|
|
2
|
+
|
|
3
|
+
export const categoryLinkedObject = (category: Amity.InternalCategory): Amity.Category => {
|
|
4
|
+
return {
|
|
5
|
+
...category,
|
|
6
|
+
get avatar(): Amity.File<'image'> | null {
|
|
7
|
+
if (!category.avatarFileId) return null;
|
|
8
|
+
let avatar: Amity.File<'image'> = {
|
|
9
|
+
fileId: category.avatarFileId?.toString() ? category.avatarFileId.toString() : '',
|
|
10
|
+
type: 'image',
|
|
11
|
+
fileUrl: '',
|
|
12
|
+
createdAt: '',
|
|
13
|
+
attributes: {
|
|
14
|
+
name: '',
|
|
15
|
+
extension: '',
|
|
16
|
+
size: '',
|
|
17
|
+
mimeType: '',
|
|
18
|
+
metadata: {
|
|
19
|
+
exif: {},
|
|
20
|
+
gps: {},
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0,
|
|
23
|
+
isFull: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const cacheData = pullFromCache<Amity.File<'image'>>([
|
|
28
|
+
'file',
|
|
29
|
+
'get',
|
|
30
|
+
`${category.avatarFileId}`,
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
if (cacheData?.data) {
|
|
34
|
+
avatar = cacheData?.data;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return avatar as Amity.File<'image'>;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { categoryLinkedObject } from './categoryLinkedObject';
|
|
1
2
|
import { commentLinkedObject } from './commentLinkedObject';
|
|
3
|
+
import { userLinkedObject } from './userLinkedObject';
|
|
2
4
|
|
|
3
5
|
export const LinkedObject = {
|
|
4
6
|
comment: commentLinkedObject,
|
|
7
|
+
user: userLinkedObject,
|
|
8
|
+
category: categoryLinkedObject,
|
|
5
9
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
2
|
+
|
|
3
|
+
export const userLinkedObject = (user: Amity.InternalUser): Amity.InternalUser => {
|
|
4
|
+
return {
|
|
5
|
+
...user,
|
|
6
|
+
get avatar(): Amity.File<'image'> | null {
|
|
7
|
+
if (!user.avatarFileId) return null;
|
|
8
|
+
let avatar: Amity.File<'image'> = {
|
|
9
|
+
fileId: user.avatarFileId?.toString() ? user.avatarFileId.toString() : '',
|
|
10
|
+
type: 'image',
|
|
11
|
+
fileUrl: '',
|
|
12
|
+
createdAt: '',
|
|
13
|
+
attributes: {
|
|
14
|
+
name: '',
|
|
15
|
+
extension: '',
|
|
16
|
+
size: '',
|
|
17
|
+
mimeType: '',
|
|
18
|
+
metadata: {
|
|
19
|
+
exif: {},
|
|
20
|
+
gps: {},
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0,
|
|
23
|
+
isFull: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const cacheData = pullFromCache<Amity.File<'image'>>(['file', 'get', `${user.avatarFileId}`]);
|
|
28
|
+
|
|
29
|
+
if (cacheData?.data) {
|
|
30
|
+
avatar = cacheData?.data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return avatar as Amity.File<'image'>;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|