@amityco/ts-sdk 7.6.1-316d940a.0 → 7.6.1-63bd9d56.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 +1 -6
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +1 -26
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +0 -6
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +8 -2
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +6 -1
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +3 -1
- package/dist/@types/domains/file.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/stream.d.ts +1 -9
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/index.d.ts +0 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +1 -3
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/events/index.d.ts +1 -1
- package/dist/channelRepository/events/index.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMuted.d.ts +2 -0
- package/dist/channelRepository/events/onChannelMuted.d.ts.map +1 -0
- package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/subscription.d.ts +1 -2
- package/dist/core/subscription.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/index.d.ts +3 -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/fileRepository/api/index.d.ts +1 -0
- package/dist/fileRepository/api/index.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadClip.d.ts +17 -0
- package/dist/fileRepository/api/uploadClip.d.ts.map +1 -0
- package/dist/index.cjs.js +7215 -7438
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +7289 -7510
- package/dist/index.umd.js +3 -3
- package/dist/liveStreamPlayer/utils/eventRegister.d.ts +1 -2
- package/dist/liveStreamPlayer/utils/eventRegister.d.ts.map +1 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +0 -4
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messageRepository/api/deleteMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/api/createClipPost.d.ts +32 -0
- package/dist/postRepository/api/createClipPost.d.ts.map +1 -0
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/api/index.d.ts +1 -0
- package/dist/postRepository/api/index.d.ts.map +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/utils.d.ts +13 -0
- package/dist/postRepository/observers/utils.d.ts.map +1 -0
- 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/streamRepository/api/createStream.d.ts +1 -1
- package/dist/streamRepository/api/createStream.d.ts.map +1 -1
- package/dist/streamRepository/api/index.d.ts +0 -1
- package/dist/streamRepository/api/index.d.ts.map +1 -1
- package/dist/streamRepository/api/updateStream.d.ts +1 -4
- package/dist/streamRepository/api/updateStream.d.ts.map +1 -1
- package/dist/streamRepository/events/index.d.ts +0 -2
- package/dist/streamRepository/events/index.d.ts.map +1 -1
- package/dist/streamRepository/internalApi/getStream.d.ts +2 -2
- package/dist/streamRepository/internalApi/getStream.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreamById.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +4 -5
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +1 -10
- package/src/@types/core/payload.ts +1 -33
- package/src/@types/domains/channel.ts +0 -9
- package/src/@types/domains/content.ts +10 -0
- package/src/@types/domains/feed.ts +18 -1
- package/src/@types/domains/file.ts +5 -0
- package/src/@types/domains/post.ts +4 -4
- package/src/@types/domains/stream.ts +1 -13
- package/src/@types/index.ts +0 -1
- package/src/channelRepository/api/createChannel.ts +8 -11
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +0 -2
- package/src/channelRepository/events/index.ts +1 -1
- package/src/channelRepository/events/onChannelMuted.ts +39 -0
- package/src/channelRepository/internalApi/getChannel.ts +1 -0
- package/src/channelRepository/observers/getChannel.ts +2 -2
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +2 -2
- package/src/channelRepository/utils/constructChannelObject.ts +2 -2
- package/src/client/api/login.ts +0 -2
- package/src/commentRepository/api/deleteComment.ts +6 -6
- package/src/communityRepository/api/getCommunity.ts +0 -9
- package/src/core/events.ts +1 -4
- package/src/core/model/index.ts +2 -1
- package/src/core/subscription.ts +6 -10
- package/src/feedRepository/api/index.ts +0 -1
- package/src/feedRepository/api/queryGlobalFeed.ts +6 -1
- 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/index.ts +2 -0
- package/src/feedRepository/observers/utils.ts +85 -0
- package/src/fileRepository/api/index.ts +1 -0
- package/src/fileRepository/api/uploadClip.ts +71 -0
- package/src/index.ts +0 -2
- package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
- package/src/liveStreamPlayer/utils/eventRegister.ts +1 -16
- package/src/messageRepository/api/deleteMessage.ts +0 -16
- package/src/messageRepository/observers/getMessage.ts +0 -2
- package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +0 -2
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +0 -13
- package/src/postRepository/api/createClipPost.ts +62 -0
- package/src/postRepository/api/createPost.ts +2 -3
- package/src/postRepository/api/index.ts +2 -0
- package/src/postRepository/api/queryPosts.ts +1 -1
- 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/getPosts/PostPaginationController.ts +1 -1
- package/src/postRepository/observers/utils.ts +97 -0
- package/src/postRepository/utils/payload.ts +1 -37
- package/src/reactionRepository/api/addReaction.ts +1 -0
- package/src/reactionRepository/api/removeReaction.ts +1 -0
- package/src/streamRepository/api/createStream.ts +1 -4
- package/src/streamRepository/api/index.ts +0 -1
- package/src/streamRepository/api/updateStream.ts +1 -8
- package/src/streamRepository/events/index.ts +0 -2
- package/src/streamRepository/internalApi/getStream.ts +3 -3
- package/src/streamRepository/observers/getStreamById.ts +0 -2
- package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +1 -5
- package/src/utils/linkedObject/channelLinkedObject.ts +0 -3
- package/src/utils/linkedObject/postLinkedObject.ts +8 -28
- package/src/utils/linkedObject/streamLinkedObject.ts +0 -4
- package/src/utils/postTypePredicate.ts +6 -20
- package/dist/@types/domains/liveReaction.d.ts +0 -20
- package/dist/@types/domains/liveReaction.d.ts.map +0 -1
- package/dist/channelRepository/events/onChannelSetMuted.d.ts +0 -2
- package/dist/channelRepository/events/onChannelSetMuted.d.ts.map +0 -1
- package/dist/channelRepository/events/onChannelSetUserMuted.d.ts +0 -2
- package/dist/channelRepository/events/onChannelSetUserMuted.d.ts.map +0 -1
- package/dist/channelRepository/internalApi/getMyMembership.d.ts +0 -11
- package/dist/channelRepository/internalApi/getMyMembership.d.ts.map +0 -1
- package/dist/channelRepository/observers/getMyMembership.d.ts +0 -2
- package/dist/channelRepository/observers/getMyMembership.d.ts.map +0 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
- package/dist/liveReactionRepository/api/createReaction.d.ts +0 -20
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +0 -1
- package/dist/liveReactionRepository/api/index.d.ts +0 -2
- package/dist/liveReactionRepository/api/index.d.ts.map +0 -1
- package/dist/liveReactionRepository/events/index.d.ts +0 -2
- package/dist/liveReactionRepository/events/index.d.ts.map +0 -1
- package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts +0 -17
- package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts.map +0 -1
- package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts +0 -17
- package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts.map +0 -1
- package/dist/liveReactionRepository/index.d.ts +0 -4
- package/dist/liveReactionRepository/index.d.ts.map +0 -1
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +0 -20
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +0 -1
- package/dist/liveReactionRepository/observers/getReactions.d.ts +0 -19
- package/dist/liveReactionRepository/observers/getReactions.d.ts.map +0 -1
- package/dist/liveReactionRepository/observers/index.d.ts +0 -2
- package/dist/liveReactionRepository/observers/index.d.ts.map +0 -1
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +0 -26
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +0 -1
- package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts +0 -3
- package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/streamRepository/api/editStream.d.ts +0 -18
- package/dist/streamRepository/api/editStream.d.ts.map +0 -1
- package/dist/streamRepository/events/onStreamViewerBanned.d.ts +0 -17
- package/dist/streamRepository/events/onStreamViewerBanned.d.ts.map +0 -1
- package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts +0 -17
- package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts.map +0 -1
- package/dist/streamRepository/internalApi/getLiveChat.d.ts +0 -16
- package/dist/streamRepository/internalApi/getLiveChat.d.ts.map +0 -1
- package/src/@types/domains/liveReaction.ts +0 -25
- package/src/channelRepository/events/onChannelSetMuted.ts +0 -48
- package/src/channelRepository/events/onChannelSetUserMuted.ts +0 -65
- package/src/channelRepository/internalApi/getMyMembership.ts +0 -37
- package/src/channelRepository/observers/getMyMembership.ts +0 -98
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +0 -115
- package/src/liveReactionRepository/api/createReaction.ts +0 -58
- package/src/liveReactionRepository/api/index.ts +0 -1
- package/src/liveReactionRepository/events/index.ts +0 -1
- package/src/liveReactionRepository/events/onLiveReactionCreated.ts +0 -37
- package/src/liveReactionRepository/events/onLiveReactionCreatedLocal.ts +0 -29
- package/src/liveReactionRepository/index.ts +0 -3
- package/src/liveReactionRepository/internalApi/createLiveReaction.ts +0 -42
- package/src/liveReactionRepository/observers/getReactions.ts +0 -59
- package/src/liveReactionRepository/observers/index.ts +0 -1
- package/src/liveReactionRepository/service/ReactionSyncEngine.ts +0 -138
- package/src/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.ts +0 -19
- package/src/streamRepository/api/editStream.ts +0 -51
- package/src/streamRepository/events/onStreamViewerBanned.ts +0 -58
- package/src/streamRepository/events/onStreamViewerUnbanned.ts +0 -47
- package/src/streamRepository/internalApi/getLiveChat.ts +0 -59
|
@@ -73,13 +73,6 @@ declare global {
|
|
|
73
73
|
*/
|
|
74
74
|
targetId?: string; // communityId, userId, etc..
|
|
75
75
|
targetType?: string; // 'community', 'user', etc..
|
|
76
|
-
|
|
77
|
-
/*
|
|
78
|
-
* when stream linked with a post and a live channel.
|
|
79
|
-
*/
|
|
80
|
-
postId?: string;
|
|
81
|
-
channelId?: string;
|
|
82
|
-
channelEnabled?: boolean;
|
|
83
76
|
} & Amity.Metadata &
|
|
84
77
|
Amity.Timestamps &
|
|
85
78
|
Amity.SoftDelete;
|
|
@@ -88,14 +81,9 @@ declare global {
|
|
|
88
81
|
|
|
89
82
|
type StreamLinkedObject = {
|
|
90
83
|
moderation?: Amity.StreamModeration;
|
|
91
|
-
post?: Amity.InternalPost;
|
|
92
|
-
getLiveChat: () => Promise<Amity.Channel<'live'> | undefined>;
|
|
93
84
|
};
|
|
94
85
|
|
|
95
|
-
type Stream =
|
|
96
|
-
isBanned: boolean;
|
|
97
|
-
watcherUrl: null;
|
|
98
|
-
};
|
|
86
|
+
type Stream = Amity.InternalStream & Amity.StreamLinkedObject;
|
|
99
87
|
|
|
100
88
|
type QueryStreams = {
|
|
101
89
|
isLive?: boolean;
|
package/src/@types/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
|
|
5
5
|
import { prepareChannelPayload } from '../utils';
|
|
6
|
-
import {
|
|
6
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
7
7
|
|
|
8
8
|
/* begin_public_function
|
|
9
9
|
id: channel.create
|
|
@@ -23,14 +23,11 @@ import { constructChannelObject } from '../utils/constructChannelObject';
|
|
|
23
23
|
* @async
|
|
24
24
|
*/
|
|
25
25
|
export const createChannel = async <T extends Amity.ChannelType>(
|
|
26
|
-
bundle: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
postId?: string;
|
|
32
|
-
} & Pick<Amity.Channel<T>, 'displayName' | 'avatarFileId' | 'tags' | 'metadata' | 'isPublic'>,
|
|
33
|
-
): Promise<Amity.Cached<Amity.Channel<T>>> => {
|
|
26
|
+
bundle: { type: T; userIds?: Amity.InternalUser['userId'][] } & Pick<
|
|
27
|
+
Amity.Channel<T>,
|
|
28
|
+
'displayName' | 'avatarFileId' | 'tags' | 'metadata' | 'isPublic'
|
|
29
|
+
>,
|
|
30
|
+
): Promise<Amity.Cached<Amity.InternalChannel>> => {
|
|
34
31
|
const client = getActiveClient();
|
|
35
32
|
client.log('user/createChannel', bundle);
|
|
36
33
|
|
|
@@ -56,7 +53,7 @@ export const createChannel = async <T extends Amity.ChannelType>(
|
|
|
56
53
|
|
|
57
54
|
const { channels } = data;
|
|
58
55
|
return {
|
|
59
|
-
data:
|
|
56
|
+
data: constructChannelDynamicValue(channels[0]),
|
|
60
57
|
cachedAt,
|
|
61
58
|
};
|
|
62
59
|
};
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
import { prepareChannelPayload } from '~/channelRepository/utils';
|
|
25
25
|
import { onUserDeleted } from '~/channelRepository/events/onUserDeleted';
|
|
26
26
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
27
|
-
import { onChannelSetUserMuted } from '~/channelRepository/events/onChannelSetUserMuted';
|
|
28
27
|
|
|
29
28
|
export class ChannelMemberLiveCollectionController extends LiveCollectionController<
|
|
30
29
|
'channelUser',
|
|
@@ -90,7 +89,6 @@ export class ChannelMemberLiveCollectionController extends LiveCollectionControl
|
|
|
90
89
|
{ fn: onChannelMemberUnbanned, action: 'onChannelMemberUnbanned' },
|
|
91
90
|
{ fn: onChannelMemberRoleAdded, action: 'onChannelMemberRoleAdded' },
|
|
92
91
|
{ fn: onChannelMemberRoleRemoved, action: 'onChannelMemberRoleRemoved' },
|
|
93
|
-
{ fn: onChannelSetUserMuted, action: 'onChannelSetUserMuted' },
|
|
94
92
|
{ fn: onUserDeleted(this.query.channelId), action: 'onChannelMemberChanged' },
|
|
95
93
|
]);
|
|
96
94
|
}
|
|
@@ -4,7 +4,7 @@ export * from './onChannelDeleted';
|
|
|
4
4
|
|
|
5
5
|
export * from './onChannelJoined';
|
|
6
6
|
export * from './onChannelLeft';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './onChannelMuted';
|
|
8
8
|
|
|
9
9
|
export * from './onChannelMemberAdded';
|
|
10
10
|
export * from './onChannelMemberRemoved';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
|
|
6
|
+
import { prepareChannelPayload } from '../utils';
|
|
7
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
8
|
+
|
|
9
|
+
type CallbackFn = Amity.Listener<Amity.StaticInternalChannel>;
|
|
10
|
+
const callbacks: CallbackFn[] = [];
|
|
11
|
+
let mainDisposer: (() => void) | null = null;
|
|
12
|
+
|
|
13
|
+
const dispose = (cb: CallbackFn) => {
|
|
14
|
+
const index = callbacks.indexOf(cb);
|
|
15
|
+
if (index > -1) {
|
|
16
|
+
callbacks.splice(index, 1);
|
|
17
|
+
}
|
|
18
|
+
if (callbacks.length === 0) {
|
|
19
|
+
mainDisposer?.();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const onChannelMuted = (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
24
|
+
if (callbacks.length === 0) {
|
|
25
|
+
const client = getActiveClient();
|
|
26
|
+
|
|
27
|
+
const filter = async (payload: Amity.ChannelPayload) => {
|
|
28
|
+
const data = await prepareChannelPayload(payload);
|
|
29
|
+
|
|
30
|
+
ingestInCache(data);
|
|
31
|
+
callbacks.forEach(cb => cb(data.channels[0]));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
mainDisposer = createEventSubscriber(client, 'onChannelMuted', 'channel.setMuted', filter);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
callbacks.push(callback);
|
|
38
|
+
return () => dispose(callback);
|
|
39
|
+
};
|
|
@@ -9,6 +9,7 @@ import { pushToTombstone } from '~/cache/api/pushToTombstone';
|
|
|
9
9
|
|
|
10
10
|
import { prepareChannelPayload } from '../utils';
|
|
11
11
|
import { prepareUnreadCountInfo } from '../utils/prepareUnreadCountInfo';
|
|
12
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* ```js
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
onChannelMemberBanned,
|
|
11
11
|
onChannelMemberRemoved,
|
|
12
12
|
onChannelMemberUnbanned,
|
|
13
|
-
|
|
13
|
+
onChannelMuted,
|
|
14
14
|
onChannelUpdated,
|
|
15
15
|
} from '../events';
|
|
16
16
|
import { dropFromCache, pullFromCache } from '~/cache/api';
|
|
@@ -104,7 +104,7 @@ export const getChannel = (
|
|
|
104
104
|
onChannelMemberRemoved,
|
|
105
105
|
onChannelMemberBanned,
|
|
106
106
|
onChannelMemberUnbanned,
|
|
107
|
-
|
|
107
|
+
onChannelMuted,
|
|
108
108
|
convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
109
109
|
convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
|
|
110
110
|
convertEventPayload(
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
onChannelLeft,
|
|
12
12
|
onChannelMemberAdded,
|
|
13
13
|
onChannelMemberRemoved,
|
|
14
|
+
onChannelMuted,
|
|
14
15
|
onChannelUpdated,
|
|
15
16
|
} from '~/channelRepository/events';
|
|
16
17
|
import {
|
|
@@ -57,7 +58,6 @@ import { onUserMessageFeedMarkerResolved } from '~/marker/events/onUserMessageFe
|
|
|
57
58
|
import { onChannelUnreadInfoUpdatedLocal } from '~/marker/events/onChannelUnreadInfoUpdatedLocal';
|
|
58
59
|
import { constructChannelObject } from '~/channelRepository/utils/constructChannelObject';
|
|
59
60
|
import { onChannelUnreadUpdatedLocal } from '~/channelRepository/events/onChannelUnreadUpdatedLocal';
|
|
60
|
-
import { onChannelSetMuted } from '~/channelRepository/events/onChannelSetMuted';
|
|
61
61
|
|
|
62
62
|
export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
63
63
|
'channel',
|
|
@@ -313,7 +313,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
313
313
|
},
|
|
314
314
|
{ fn: onChannelDeleted, action: Amity.ChannelActionType.OnDelete },
|
|
315
315
|
{ fn: onChannelUpdated, action: Amity.ChannelActionType.OnUpdate },
|
|
316
|
-
{ fn:
|
|
316
|
+
{ fn: onChannelMuted, action: Amity.ChannelActionType.OnMute },
|
|
317
317
|
{
|
|
318
318
|
fn: (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
319
319
|
return onChannelJoined(channel => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getChannelMessagePreviewWithUser } from '~/messagePreview/utils';
|
|
2
2
|
import { constructChannelDynamicValue } from './constructChannelDynamicValue';
|
|
3
|
-
import {
|
|
3
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
4
4
|
|
|
5
5
|
export const constructChannelObject = (channel: Amity.StaticInternalChannel): Amity.Channel => {
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ export const constructChannelObject = (channel: Amity.StaticInternalChannel): Am
|
|
|
10
10
|
* 3. [LinkedObject.channel] add markAsRead >> Amity.InternalChannel -> Amity.Channel
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
return
|
|
13
|
+
return LinkedObject.channel(
|
|
14
14
|
constructChannelDynamicValue(getChannelMessagePreviewWithUser(channel)),
|
|
15
15
|
);
|
|
16
16
|
};
|
package/src/client/api/login.ts
CHANGED
|
@@ -13,7 +13,6 @@ import analyticsEngineOnLoginHandler from '~/analytic/utils/analyticsEngineOnLog
|
|
|
13
13
|
import readReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler';
|
|
14
14
|
import legacyReadReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler';
|
|
15
15
|
import objectResolverEngineOnLoginHandler from '~/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler';
|
|
16
|
-
import reactionSyncEngineOnLoginHandler from '~/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler';
|
|
17
16
|
import { logout } from './logout';
|
|
18
17
|
|
|
19
18
|
import { getActiveClient } from './activeClient';
|
|
@@ -202,7 +201,6 @@ export const login = async (
|
|
|
202
201
|
markReadEngineOnLoginHandler(),
|
|
203
202
|
analyticsEngineOnLoginHandler(),
|
|
204
203
|
objectResolverEngineOnLoginHandler(),
|
|
205
|
-
reactionSyncEngineOnLoginHandler(),
|
|
206
204
|
);
|
|
207
205
|
|
|
208
206
|
if (client.useLegacyUnreadCount) {
|
|
@@ -49,6 +49,12 @@ export const deleteComment = async (
|
|
|
49
49
|
// to support hard deletion
|
|
50
50
|
const deleted = { ...comment.data, isDeleted: true };
|
|
51
51
|
|
|
52
|
+
if (permanent) {
|
|
53
|
+
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
54
|
+
} else {
|
|
55
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
if (comment.data.referenceType === 'story') {
|
|
53
59
|
const story = await getStoryByStoryId(comment.data.referenceId);
|
|
54
60
|
|
|
@@ -96,12 +102,6 @@ export const deleteComment = async (
|
|
|
96
102
|
communityUsers: [],
|
|
97
103
|
});
|
|
98
104
|
|
|
99
|
-
if (permanent) {
|
|
100
|
-
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
101
|
-
} else {
|
|
102
|
-
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
103
|
-
}
|
|
104
|
-
|
|
105
105
|
return deleted;
|
|
106
106
|
};
|
|
107
107
|
/* end_public_function */
|
|
@@ -5,7 +5,6 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
|
|
7
7
|
import { prepareCommunityPayload } from '../utils';
|
|
8
|
-
import { LinkedObject } from '~/utils/linkedObject';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* ```js
|
|
@@ -23,8 +22,6 @@ import { LinkedObject } from '~/utils/linkedObject';
|
|
|
23
22
|
*/
|
|
24
23
|
export const getCommunity = async (
|
|
25
24
|
communityId: Amity.Community['communityId'],
|
|
26
|
-
type?: Amity.JoinRequestType,
|
|
27
|
-
includeDiscoverablePrivateCommunity?: boolean,
|
|
28
25
|
): Promise<Amity.Cached<Amity.InternalCommunity>> => {
|
|
29
26
|
const client = getActiveClient();
|
|
30
27
|
client.log('community/getCommunity', communityId);
|
|
@@ -32,12 +29,6 @@ export const getCommunity = async (
|
|
|
32
29
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
33
30
|
const { data: payload } = await client.http.get<Amity.CommunityPayload>(
|
|
34
31
|
`/api/v3/communities/${communityId}`,
|
|
35
|
-
{
|
|
36
|
-
params: {
|
|
37
|
-
type: 'communityJoinRequest',
|
|
38
|
-
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity ?? true,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
32
|
);
|
|
42
33
|
|
|
43
34
|
const data = prepareCommunityPayload(payload);
|
package/src/core/events.ts
CHANGED
|
@@ -32,10 +32,7 @@ const MQTT_EVENTS = [
|
|
|
32
32
|
'video-streaming.didFlag',
|
|
33
33
|
'video-streaming.didTerminate',
|
|
34
34
|
|
|
35
|
-
'
|
|
36
|
-
'video-streaming.viewerDidUnban',
|
|
37
|
-
|
|
38
|
-
'liveReaction.created',
|
|
35
|
+
// 'user.didGlobalBan' remove due to message event,
|
|
39
36
|
] as const;
|
|
40
37
|
|
|
41
38
|
/** @hidden */
|
package/src/core/model/index.ts
CHANGED
|
@@ -61,7 +61,8 @@ export const PAYLOAD2MODEL: Record<string, Amity.Domain> = {
|
|
|
61
61
|
|
|
62
62
|
/** hidden */
|
|
63
63
|
export const isOutdated = <T extends Amity.UpdatedAt>(prevData: T, nextData: T): boolean => {
|
|
64
|
-
|
|
64
|
+
// Check if the new value is outdated.
|
|
65
|
+
if ('updatedAt' in nextData && 'updatedAt' in prevData) {
|
|
65
66
|
return new Date(nextData.updatedAt!) < new Date(prevData.updatedAt!);
|
|
66
67
|
}
|
|
67
68
|
|
package/src/core/subscription.ts
CHANGED
|
@@ -154,16 +154,6 @@ export const getSmartFeedMessageTopic = (): string => {
|
|
|
154
154
|
return `${getNetworkId(user)}/smartfeed/${user._id}/messages`;
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
export const getLiveStreamTopic = (): string => {
|
|
158
|
-
const user = getActiveUser();
|
|
159
|
-
|
|
160
|
-
return `${getNetworkId(user)}/videostreaming`;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export const getLiveReactionTopic = (post: Amity.Post) => {
|
|
164
|
-
return `${post.path}/liveReaction`;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
157
|
let mqttAccessToken: string;
|
|
168
158
|
let mqttUserId: string;
|
|
169
159
|
|
|
@@ -178,3 +168,9 @@ export function subscribeTopic(
|
|
|
178
168
|
|
|
179
169
|
return mqtt.subscribe(topic, callback);
|
|
180
170
|
}
|
|
171
|
+
|
|
172
|
+
export const getLiveStreamTopic = (): string => {
|
|
173
|
+
const user = getActiveUser();
|
|
174
|
+
|
|
175
|
+
return `${getNetworkId(user)}/videostreaming`;
|
|
176
|
+
};
|
|
@@ -11,6 +11,9 @@ import { prepareCommunityPayload } from '~/communityRepository/utils';
|
|
|
11
11
|
id: feed.query.global_feed
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
|
+
*
|
|
15
|
+
* @deprecated This function will to be deprecated. Please use getGlobalFeed instead.
|
|
16
|
+
*
|
|
14
17
|
* ```js
|
|
15
18
|
* import { queryGlobalFeed } from '@amityco/ts-sdk'
|
|
16
19
|
* const posts = await queryGlobalFeed()
|
|
@@ -32,7 +35,7 @@ export const queryGlobalFeed = async (
|
|
|
32
35
|
const client = getActiveClient();
|
|
33
36
|
client.log('feed/queryGlobalFeed', query);
|
|
34
37
|
|
|
35
|
-
const { queryToken, ...params } = query ?? {};
|
|
38
|
+
const { queryToken, dataTypes, resolveParent, ...params } = query ?? {};
|
|
36
39
|
|
|
37
40
|
const options = (() => {
|
|
38
41
|
if (queryToken) return { token: queryToken };
|
|
@@ -44,6 +47,8 @@ export const queryGlobalFeed = async (
|
|
|
44
47
|
{
|
|
45
48
|
params: {
|
|
46
49
|
...params,
|
|
50
|
+
dataTypes,
|
|
51
|
+
resolveParent: resolveParent ?? true,
|
|
47
52
|
options,
|
|
48
53
|
},
|
|
49
54
|
},
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { queryGlobalFeed } from './api';
|
|
2
|
+
export { getCustomRankingGlobalFeed, getGlobalFeed } from './observers';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import hash from 'object-hash';
|
|
2
|
+
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
+
import { CustomRankingGlobalFeedPaginationController } from './PaginationController';
|
|
4
|
+
import { CustomRankingGlobalFeedQueryStreamController } from './QueryStreamController';
|
|
5
|
+
import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
|
|
6
|
+
import { isNonNullable } from '~/utils';
|
|
7
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
8
|
+
import { preparePostPayload } from '~/postRepository/utils/payload';
|
|
9
|
+
import { getGlobalFeedSubscriptions } from '../utils';
|
|
10
|
+
|
|
11
|
+
export class CustomRankingGlobalFeedLiveCollectionController extends LiveCollectionController<
|
|
12
|
+
'post',
|
|
13
|
+
Amity.CustomRankingGlobalFeedLiveCollection,
|
|
14
|
+
Amity.Post,
|
|
15
|
+
CustomRankingGlobalFeedPaginationController
|
|
16
|
+
> {
|
|
17
|
+
private queryStreamController: CustomRankingGlobalFeedQueryStreamController;
|
|
18
|
+
|
|
19
|
+
private query: Amity.CustomRankingGlobalFeedLiveCollection;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
query: Amity.CustomRankingGlobalFeedLiveCollection,
|
|
23
|
+
callback: Amity.LiveCollectionCallback<Amity.Post>,
|
|
24
|
+
) {
|
|
25
|
+
const queryStreamId = hash(query);
|
|
26
|
+
const cacheKey = ['customRankingGlobalFeed', 'collection', queryStreamId];
|
|
27
|
+
const paginationController = new CustomRankingGlobalFeedPaginationController(query);
|
|
28
|
+
|
|
29
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
30
|
+
|
|
31
|
+
this.query = query;
|
|
32
|
+
this.queryStreamController = new CustomRankingGlobalFeedQueryStreamController(
|
|
33
|
+
this.query,
|
|
34
|
+
this.cacheKey,
|
|
35
|
+
this.notifyChange.bind(this),
|
|
36
|
+
preparePostPayload,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
this.callback = callback.bind(this);
|
|
40
|
+
this.loadPage({ initial: true });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected setup() {
|
|
44
|
+
const collection = pullFromCache<Amity.CustomRankingGlobalFeedLiveCollectionCache>(
|
|
45
|
+
this.cacheKey,
|
|
46
|
+
)?.data;
|
|
47
|
+
|
|
48
|
+
if (!collection) {
|
|
49
|
+
pushToCache(this.cacheKey, {
|
|
50
|
+
data: [],
|
|
51
|
+
params: {},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected async persistModel(queryPayload: Amity.PostPayload & Amity.Pagination) {
|
|
57
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected persistQueryStream({
|
|
61
|
+
response,
|
|
62
|
+
direction,
|
|
63
|
+
refresh,
|
|
64
|
+
}: Amity.LiveCollectionPersistQueryStreamParams<'post'>) {
|
|
65
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
startSubscription() {
|
|
69
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
|
|
73
|
+
const collection = pullFromCache<Amity.CustomRankingGlobalFeedLiveCollectionCache>(
|
|
74
|
+
this.cacheKey,
|
|
75
|
+
)?.data;
|
|
76
|
+
if (!collection) return;
|
|
77
|
+
|
|
78
|
+
const data = (
|
|
79
|
+
collection.data
|
|
80
|
+
.map(id => pullFromCache<Amity.InternalPost>(['post', 'get', id])!)
|
|
81
|
+
.filter(isNonNullable)
|
|
82
|
+
.map(({ data }) => data) ?? []
|
|
83
|
+
).map(LinkedObject.post);
|
|
84
|
+
|
|
85
|
+
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
86
|
+
|
|
87
|
+
this.callback({
|
|
88
|
+
onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
|
|
89
|
+
data,
|
|
90
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
91
|
+
loading,
|
|
92
|
+
error,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PaginationController } from '~/core/liveCollection/PaginationController';
|
|
2
|
+
|
|
3
|
+
export class CustomRankingGlobalFeedPaginationController extends PaginationController<
|
|
4
|
+
'post',
|
|
5
|
+
Amity.CustomRankingGlobalFeedLiveCollection
|
|
6
|
+
> {
|
|
7
|
+
async getRequest(
|
|
8
|
+
queryParams: Amity.CustomRankingGlobalFeedLiveCollection,
|
|
9
|
+
token: string | undefined,
|
|
10
|
+
) {
|
|
11
|
+
const { limit, ...params } = queryParams;
|
|
12
|
+
const options = token ? { token } : { limit };
|
|
13
|
+
|
|
14
|
+
const { data: queryResponse } = await this.http.get<Amity.PostPayload & Amity.Pagination>(
|
|
15
|
+
`/api/v5/me/global-feeds`,
|
|
16
|
+
{
|
|
17
|
+
params: {
|
|
18
|
+
...params,
|
|
19
|
+
options,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
return queryResponse;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
|
|
2
|
+
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
|
+
import { getResolver } from '~/core/model';
|
|
5
|
+
import { getActiveClient } from '~/client';
|
|
6
|
+
import { EnumPostActions } from '~/postRepository/observers/enums';
|
|
7
|
+
|
|
8
|
+
export class CustomRankingGlobalFeedQueryStreamController extends QueryStreamController<
|
|
9
|
+
Amity.PostPayload,
|
|
10
|
+
Amity.CustomRankingGlobalFeedLiveCollection
|
|
11
|
+
> {
|
|
12
|
+
private notifyChange: (params: Amity.LiveCollectionNotifyParams) => void;
|
|
13
|
+
|
|
14
|
+
private preparePayload: (response: Amity.PostPayload) => Amity.ProcessedPostPayload;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
query: Amity.CustomRankingGlobalFeedLiveCollection,
|
|
18
|
+
cacheKey: string[],
|
|
19
|
+
notifyChange: (params: Amity.LiveCollectionNotifyParams) => void,
|
|
20
|
+
preparePayload: (response: Amity.PostPayload) => Amity.ProcessedPostPayload,
|
|
21
|
+
) {
|
|
22
|
+
super(query, cacheKey);
|
|
23
|
+
this.notifyChange = notifyChange;
|
|
24
|
+
this.preparePayload = preparePayload;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async saveToMainDB(response: Amity.PostPayload) {
|
|
28
|
+
const processedPayload = await this.preparePayload(response);
|
|
29
|
+
|
|
30
|
+
const client = getActiveClient();
|
|
31
|
+
const cachedAt = client.cache && Date.now();
|
|
32
|
+
|
|
33
|
+
if (client.cache) {
|
|
34
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
appendToQueryStream(
|
|
39
|
+
response: Amity.PostPayload & Partial<Amity.Pagination>,
|
|
40
|
+
direction: Amity.LiveCollectionPageDirection,
|
|
41
|
+
refresh = false,
|
|
42
|
+
) {
|
|
43
|
+
if (refresh) {
|
|
44
|
+
pushToCache(this.cacheKey, {
|
|
45
|
+
data: response.posts.map(getResolver('post')),
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
|
|
49
|
+
|
|
50
|
+
const posts = collection?.data ?? [];
|
|
51
|
+
|
|
52
|
+
pushToCache(this.cacheKey, {
|
|
53
|
+
...collection,
|
|
54
|
+
data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
reactor(action: EnumPostActions) {
|
|
60
|
+
return (post: Amity.InternalPost) => {
|
|
61
|
+
const collection = pullFromCache<Amity.CustomRankingGlobalFeedLiveCollectionCache>(
|
|
62
|
+
this.cacheKey,
|
|
63
|
+
)?.data;
|
|
64
|
+
|
|
65
|
+
if (!collection) return;
|
|
66
|
+
|
|
67
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId)) return;
|
|
68
|
+
|
|
69
|
+
// Delete Action
|
|
70
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
71
|
+
// Parent Post - Remove from collection
|
|
72
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
76
|
+
// If the query has dataTypes array with value, check if post.dataType is include in the array
|
|
77
|
+
if (this.query.dataTypes && this.query.dataTypes.length > 0) {
|
|
78
|
+
if (!this.query.dataTypes.includes(post.dataType)) return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
85
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
pushToCache(this.cacheKey, collection);
|
|
89
|
+
this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
subscribeRTE(
|
|
94
|
+
createSubscriber: {
|
|
95
|
+
fn: (reactor: (post: Amity.InternalPost) => void) => Amity.Unsubscriber;
|
|
96
|
+
action: EnumPostActions;
|
|
97
|
+
}[],
|
|
98
|
+
) {
|
|
99
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
import { dropFromCache } from '~/cache/api';
|
|
3
|
+
|
|
4
|
+
import { ENABLE_CACHE_MESSAGE } from '~/utils/constants';
|
|
5
|
+
import { CustomRankingGlobalFeedLiveCollectionController } from './getCustomRankingGlobalFeed/LiveCollectionController';
|
|
6
|
+
|
|
7
|
+
/* begin_public_function
|
|
8
|
+
id: feed.query.custom_ranking_feed
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* ```js
|
|
12
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
13
|
+
*
|
|
14
|
+
* let posts = []
|
|
15
|
+
* const unsub = FeedRepository.getGlobalFeed({
|
|
16
|
+
* dataTypes: ['video','image'],
|
|
17
|
+
* resolveParent: true,
|
|
18
|
+
* }, response => processResponse(response))
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
22
|
+
*
|
|
23
|
+
* @param params.dataTypes array of data types for the posts
|
|
24
|
+
* @param callback the function to call when new data are available
|
|
25
|
+
* @param config
|
|
26
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
27
|
+
*
|
|
28
|
+
* @category Posts Live Collection
|
|
29
|
+
*/
|
|
30
|
+
export const getCustomRankingGlobalFeed = (
|
|
31
|
+
params: Amity.CustomRankingGlobalFeedLiveCollection,
|
|
32
|
+
callback: Amity.LiveCollectionCallback<Amity.Post>,
|
|
33
|
+
config?: Amity.LiveCollectionConfig,
|
|
34
|
+
): Amity.Unsubscriber => {
|
|
35
|
+
const { log, cache } = getActiveClient();
|
|
36
|
+
|
|
37
|
+
if (!cache) {
|
|
38
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const timestamp = Date.now();
|
|
42
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > listen`);
|
|
43
|
+
|
|
44
|
+
const liveCollection = new CustomRankingGlobalFeedLiveCollectionController(params, callback);
|
|
45
|
+
const disposers = liveCollection.startSubscription();
|
|
46
|
+
|
|
47
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
48
|
+
|
|
49
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
50
|
+
|
|
51
|
+
return () => {
|
|
52
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > dispose`);
|
|
53
|
+
disposers.forEach(fn => fn());
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/* end_public_function */
|