@amityco/ts-sdk 7.22.0 → 7.22.1-0aa28d6.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/errors.d.ts +3 -1
- package/dist/@types/core/errors.d.ts.map +1 -1
- package/dist/@types/core/events.d.ts +7 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +15 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/transport.d.ts +1 -0
- package/dist/@types/core/transport.d.ts.map +1 -1
- package/dist/@types/domains/analytics.d.ts +3 -2
- package/dist/@types/domains/analytics.d.ts.map +1 -1
- package/dist/@types/domains/block.d.ts +5 -0
- package/dist/@types/domains/block.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +31 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +31 -2
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +1 -0
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +14 -0
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +16 -0
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/notificationSettings.d.ts +101 -0
- package/dist/@types/domains/notificationSettings.d.ts.map +1 -0
- package/dist/@types/domains/post.d.ts +2 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/sharableContentType.d.ts +9 -0
- package/dist/@types/domains/sharableContentType.d.ts.map +1 -0
- package/dist/@types/index.d.ts +3 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +1 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +2 -1
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsService.d.ts +1 -0
- package/dist/analytic/service/analytic/AnalyticsService.d.ts.map +1 -1
- package/dist/channelRepository/api/archiveChannel.d.ts +16 -0
- package/dist/channelRepository/api/archiveChannel.d.ts.map +1 -0
- package/dist/channelRepository/api/getArchivedChannelIds.d.ts +13 -0
- package/dist/channelRepository/api/getArchivedChannelIds.d.ts.map +1 -0
- package/dist/channelRepository/api/index.d.ts +3 -0
- package/dist/channelRepository/api/index.d.ts.map +1 -1
- package/dist/channelRepository/api/unarchiveChannel.d.ts +16 -0
- package/dist/channelRepository/api/unarchiveChannel.d.ts.map +1 -0
- package/dist/channelRepository/api/updateChannel.d.ts +1 -1
- package/dist/channelRepository/api/updateChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/banMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/muteMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/channelRepository/channelModeration/api/unmuteMembers.d.ts.map +1 -1
- package/dist/channelRepository/events/index.d.ts +2 -0
- package/dist/channelRepository/events/index.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelArchived.d.ts +10 -0
- package/dist/channelRepository/events/onChannelArchived.d.ts.map +1 -0
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelUnarchived.d.ts +11 -0
- package/dist/channelRepository/events/onChannelUnarchived.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelLiveCollectionController.d.ts +12 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelLiveCollectionController.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelPaginationController.d.ts +11 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelPaginationController.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelQueryStreamController.d.ts +13 -0
- package/dist/channelRepository/observers/getArchivedChannels/ArchivedChannelQueryStreamController.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/getArchivedChannels.d.ts +20 -0
- package/dist/channelRepository/observers/getArchivedChannels/getArchivedChannels.d.ts.map +1 -0
- package/dist/channelRepository/observers/getArchivedChannels/index.d.ts +2 -0
- package/dist/channelRepository/observers/getArchivedChannels/index.d.ts.map +1 -0
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/observers/index.d.ts +2 -0
- package/dist/channelRepository/observers/index.d.ts.map +1 -1
- package/dist/channelRepository/observers/searchChannels/SearchChannelLiveCollectionController.d.ts +14 -0
- package/dist/channelRepository/observers/searchChannels/SearchChannelLiveCollectionController.d.ts.map +1 -0
- package/dist/channelRepository/observers/searchChannels/SearchChannelPaginationController.d.ts +10 -0
- package/dist/channelRepository/observers/searchChannels/SearchChannelPaginationController.d.ts.map +1 -0
- package/dist/channelRepository/observers/searchChannels/SearchChannelQueryStreamController.d.ts +13 -0
- package/dist/channelRepository/observers/searchChannels/SearchChannelQueryStreamController.d.ts.map +1 -0
- package/dist/channelRepository/observers/searchChannels.d.ts +21 -0
- package/dist/channelRepository/observers/searchChannels.d.ts.map +1 -0
- package/dist/channelRepository/observers/tests/integrations/searchChannels.integration.test.d.ts +2 -0
- package/dist/channelRepository/observers/tests/integrations/searchChannels.integration.test.d.ts.map +1 -0
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/client/api/autoSubscription.d.ts +47 -0
- package/dist/client/api/autoSubscription.d.ts.map +1 -0
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/getCoreUserSettings.d.ts +16 -0
- package/dist/client/api/getCoreUserSettings.d.ts.map +1 -0
- package/dist/client/api/getForYouFeedSetting.d.ts +17 -0
- package/dist/client/api/getForYouFeedSetting.d.ts.map +1 -0
- package/dist/client/api/getShareableLinkConfiguration.d.ts +2 -2
- package/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -1
- package/dist/client/api/index.d.ts +5 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/notifications.d.ts +27 -0
- package/dist/client/api/notifications.d.ts.map +1 -0
- package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
- package/dist/client/api/tests/ShareableLinkConfiguration.test.d.ts +2 -0
- package/dist/client/api/tests/ShareableLinkConfiguration.test.d.ts.map +1 -0
- package/dist/client/api/tests/notifications.integration.test.d.ts +2 -0
- package/dist/client/api/tests/notifications.integration.test.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
- package/dist/client/utils/autoSubscriptionManager.d.ts +21 -0
- package/dist/client/utils/autoSubscriptionManager.d.ts.map +1 -0
- package/dist/client/utils/subscribeGlobalTopic.d.ts +6 -1
- package/dist/client/utils/subscribeGlobalTopic.d.ts.map +1 -1
- package/dist/client/utils/tests/autoSubscriptionManager.test.d.ts +2 -0
- package/dist/client/utils/tests/autoSubscriptionManager.test.d.ts.map +1 -0
- package/dist/commentRepository/observers/getComments/CommentLiveCollectionController.d.ts.map +1 -1
- package/dist/commentRepository/observers/tests/integrations/getCommentsExcludeBlockUser.integration.test.d.ts +2 -0
- package/dist/commentRepository/observers/tests/integrations/getCommentsExcludeBlockUser.integration.test.d.ts.map +1 -0
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +32 -0
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/core/query/paging.d.ts +1 -0
- package/dist/core/query/paging.d.ts.map +1 -1
- package/dist/core/subscription.d.ts +3 -0
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/feedRepository/errors/AmityForYouFeedDisabledError.d.ts +13 -0
- package/dist/feedRepository/errors/AmityForYouFeedDisabledError.d.ts.map +1 -0
- package/dist/feedRepository/index.d.ts +2 -1
- package/dist/feedRepository/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/getForYouFeed/CursorController.d.ts +19 -0
- package/dist/feedRepository/observers/getForYouFeed/CursorController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getForYouFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getForYouFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getForYouFeed/PaginationController.d.ts +13 -0
- package/dist/feedRepository/observers/getForYouFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getForYouFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getForYouFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getForYouFeed.d.ts +19 -0
- package/dist/feedRepository/observers/getForYouFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/index.d.ts +1 -0
- package/dist/feedRepository/observers/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/tests/integration/getForYouFeed.integration.test.d.ts +2 -0
- package/dist/feedRepository/observers/tests/integration/getForYouFeed.integration.test.d.ts.map +1 -0
- package/dist/feedRepository/observers/tests/unit/CursorController.test.d.ts +2 -0
- package/dist/feedRepository/observers/tests/unit/CursorController.test.d.ts.map +1 -0
- package/dist/index.cjs.js +2700 -429
- package/dist/index.esm.js +2697 -430
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -0
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messagePreview/utils/updateChannelMessagePreviewCache.d.ts.map +1 -1
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/observers/index.d.ts +1 -0
- package/dist/messageRepository/observers/index.d.ts.map +1 -1
- package/dist/messageRepository/observers/searchMessage/SearchMessageLiveCollectionController.d.ts +12 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessageLiveCollectionController.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessagePaginationController.d.ts +10 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessagePaginationController.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessageQueryStreamController.d.ts +8 -0
- package/dist/messageRepository/observers/searchMessage/SearchMessageQueryStreamController.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/index.d.ts +2 -0
- package/dist/messageRepository/observers/searchMessage/index.d.ts.map +1 -0
- package/dist/messageRepository/observers/searchMessage/searchMessage.d.ts +24 -0
- package/dist/messageRepository/observers/searchMessage/searchMessage.d.ts.map +1 -0
- package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/observers/tests/getPostsExcludeBlockUser.test.d.ts +2 -0
- package/dist/postRepository/observers/tests/getPostsExcludeBlockUser.test.d.ts.map +1 -0
- package/dist/postRepository/tests/integration/postAnalytics.integration.test.d.ts +2 -0
- package/dist/postRepository/tests/integration/postAnalytics.integration.test.d.ts.map +1 -0
- package/dist/postRepository/tests/integration/setup.d.ts +6 -0
- package/dist/postRepository/tests/integration/setup.d.ts.map +1 -0
- package/dist/reactionRepository/internalApi/addReaction.d.ts.map +1 -1
- package/dist/reactionRepository/internalApi/removeReaction.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreams/GetStreamsPageController.d.ts +1 -0
- package/dist/streamRepository/observers/getStreams/GetStreamsPageController.d.ts.map +1 -1
- package/dist/userRepository/api/getAllBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/api/getAllBlockingUsers.d.ts +20 -0
- package/dist/userRepository/api/getAllBlockingUsers.d.ts.map +1 -0
- package/dist/userRepository/api/index.d.ts +1 -0
- package/dist/userRepository/api/index.d.ts.map +1 -1
- package/dist/userRepository/api/tests/integration/getAllBlockingUsers.integration.test.d.ts +2 -0
- package/dist/userRepository/api/tests/integration/getAllBlockingUsers.integration.test.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts +4 -3
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts +13 -0
- package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockingUsers/PaginationController.d.ts +5 -0
- package/dist/userRepository/observers/getBlockingUsers/PaginationController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockingUsers/QueryStreamController.d.ts +16 -0
- package/dist/userRepository/observers/getBlockingUsers/QueryStreamController.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockingUsers.d.ts +17 -0
- package/dist/userRepository/observers/getBlockingUsers.d.ts.map +1 -0
- package/dist/userRepository/observers/index.d.ts +1 -0
- package/dist/userRepository/observers/index.d.ts.map +1 -1
- package/dist/userRepository/observers/tests/integrations/getBlockingUsers.integration.test.d.ts +2 -0
- package/dist/userRepository/observers/tests/integrations/getBlockingUsers.integration.test.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/enum/index.d.ts +5 -0
- package/dist/userRepository/relationship/block/enum/index.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/events/index.d.ts +3 -0
- package/dist/userRepository/relationship/block/events/index.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/events/onUserDidBlock.d.ts +20 -0
- package/dist/userRepository/relationship/block/events/onUserDidBlock.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/events/onUserDidUnblock.d.ts +20 -0
- package/dist/userRepository/relationship/block/events/onUserDidUnblock.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/index.d.ts +1 -0
- package/dist/userRepository/relationship/block/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/utils/blockRealtimeOnLoginHandler.d.ts +12 -0
- package/dist/userRepository/relationship/block/utils/blockRealtimeOnLoginHandler.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/utils/createBlockEventSubscriber.d.ts +11 -0
- package/dist/userRepository/relationship/block/utils/createBlockEventSubscriber.d.ts.map +1 -0
- package/dist/userRepository/services/BlockedUserSyncEngine/blockedUserSyncEngine.d.ts +13 -13
- package/dist/userRepository/services/BlockedUserSyncEngine/blockedUserSyncEngine.d.ts.map +1 -1
- package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngine.d.ts +56 -0
- package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngine.d.ts.map +1 -0
- package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngineOnLoginHandler.d.ts +3 -0
- package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/userRepository/utils/prepareBlockingUserPayload.d.ts +2 -0
- package/dist/userRepository/utils/prepareBlockingUserPayload.d.ts.map +1 -0
- package/dist/utils/constants.d.ts +4 -0
- package/dist/utils/constants.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/tests/dummy/block.d.ts +16 -0
- package/dist/utils/tests/dummy/block.d.ts.map +1 -1
- package/dist/utils/tests/dummy/community.d.ts +2 -0
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -13,6 +13,13 @@ var MembershipAcceptanceTypeEnum;
|
|
|
13
13
|
MembershipAcceptanceTypeEnum["AUTOMATIC"] = "automatic";
|
|
14
14
|
MembershipAcceptanceTypeEnum["INVITATION"] = "invitation";
|
|
15
15
|
})(MembershipAcceptanceTypeEnum || (MembershipAcceptanceTypeEnum = {}));
|
|
16
|
+
var AmityAutoSubscription;
|
|
17
|
+
(function (AmityAutoSubscription) {
|
|
18
|
+
AmityAutoSubscription["CHAT"] = "chat";
|
|
19
|
+
AmityAutoSubscription["NETWORK"] = "network";
|
|
20
|
+
AmityAutoSubscription["LIVESTREAM"] = "livestream";
|
|
21
|
+
AmityAutoSubscription["BLOCK"] = "block";
|
|
22
|
+
})(AmityAutoSubscription || (AmityAutoSubscription = {}));
|
|
16
23
|
|
|
17
24
|
var UserTypeEnum;
|
|
18
25
|
(function (UserTypeEnum) {
|
|
@@ -59,6 +66,13 @@ var FileAccessTypeEnum;
|
|
|
59
66
|
FileAccessTypeEnum["NETWORK"] = "network";
|
|
60
67
|
})(FileAccessTypeEnum || (FileAccessTypeEnum = {}));
|
|
61
68
|
|
|
69
|
+
var AmityChannelNotificationModeEnum;
|
|
70
|
+
(function (AmityChannelNotificationModeEnum) {
|
|
71
|
+
AmityChannelNotificationModeEnum["Default"] = "default";
|
|
72
|
+
AmityChannelNotificationModeEnum["Silent"] = "silent";
|
|
73
|
+
AmityChannelNotificationModeEnum["Subscribe"] = "subscribe";
|
|
74
|
+
})(AmityChannelNotificationModeEnum || (AmityChannelNotificationModeEnum = {}));
|
|
75
|
+
|
|
62
76
|
const CommunityPostSettings = Object.freeze({
|
|
63
77
|
ONLY_ADMIN_CAN_POST: 'ONLY_ADMIN_CAN_POST',
|
|
64
78
|
ADMIN_REVIEW_POST_REQUIRED: 'ADMIN_REVIEW_POST_REQUIRED',
|
|
@@ -234,12 +248,54 @@ var AmityEventOrderOption;
|
|
|
234
248
|
AmityEventOrderOption["Descending"] = "desc";
|
|
235
249
|
})(AmityEventOrderOption || (AmityEventOrderOption = {}));
|
|
236
250
|
|
|
251
|
+
var AmitySharableContentType;
|
|
252
|
+
(function (AmitySharableContentType) {
|
|
253
|
+
AmitySharableContentType["POST"] = "post";
|
|
254
|
+
AmitySharableContentType["COMMUNITY"] = "community";
|
|
255
|
+
AmitySharableContentType["USER"] = "user";
|
|
256
|
+
AmitySharableContentType["LIVESTREAM"] = "livestream";
|
|
257
|
+
AmitySharableContentType["EVENT"] = "event";
|
|
258
|
+
})(AmitySharableContentType || (AmitySharableContentType = {}));
|
|
259
|
+
|
|
237
260
|
var AnalyticsSourceTypeEnum;
|
|
238
261
|
(function (AnalyticsSourceTypeEnum) {
|
|
239
262
|
AnalyticsSourceTypeEnum["POST"] = "post";
|
|
240
263
|
AnalyticsSourceTypeEnum["ROOM"] = "room";
|
|
241
264
|
})(AnalyticsSourceTypeEnum || (AnalyticsSourceTypeEnum = {}));
|
|
242
265
|
|
|
266
|
+
var UserNotificationModuleNameEnum;
|
|
267
|
+
(function (UserNotificationModuleNameEnum) {
|
|
268
|
+
UserNotificationModuleNameEnum["CHAT"] = "chat";
|
|
269
|
+
UserNotificationModuleNameEnum["SOCIAL"] = "social";
|
|
270
|
+
UserNotificationModuleNameEnum["VIDEO_STREAMING"] = "video-streaming";
|
|
271
|
+
})(UserNotificationModuleNameEnum || (UserNotificationModuleNameEnum = {}));
|
|
272
|
+
var CommunityNotificationEventNameEnum;
|
|
273
|
+
(function (CommunityNotificationEventNameEnum) {
|
|
274
|
+
CommunityNotificationEventNameEnum["POST_CREATED"] = "post.created";
|
|
275
|
+
CommunityNotificationEventNameEnum["POST_REACTED"] = "post.reacted";
|
|
276
|
+
CommunityNotificationEventNameEnum["COMMENT_CREATED"] = "comment.created";
|
|
277
|
+
CommunityNotificationEventNameEnum["COMMENT_REPLIED"] = "comment.replied";
|
|
278
|
+
CommunityNotificationEventNameEnum["COMMENT_REACTED"] = "comment.reacted";
|
|
279
|
+
CommunityNotificationEventNameEnum["STORY_CREATED"] = "story.created";
|
|
280
|
+
CommunityNotificationEventNameEnum["STORY_REACTED"] = "story.reacted";
|
|
281
|
+
CommunityNotificationEventNameEnum["STORY_COMMENT_CREATED"] = "story-comment.created";
|
|
282
|
+
CommunityNotificationEventNameEnum["LIVESTREAM_START"] = "video-streaming.didStart";
|
|
283
|
+
})(CommunityNotificationEventNameEnum || (CommunityNotificationEventNameEnum = {}));
|
|
284
|
+
var NotificationSettingsLevelEnum;
|
|
285
|
+
(function (NotificationSettingsLevelEnum) {
|
|
286
|
+
NotificationSettingsLevelEnum["USER"] = "user";
|
|
287
|
+
NotificationSettingsLevelEnum["COMMUNITY"] = "community";
|
|
288
|
+
NotificationSettingsLevelEnum["CHANNEL"] = "channel";
|
|
289
|
+
})(NotificationSettingsLevelEnum || (NotificationSettingsLevelEnum = {}));
|
|
290
|
+
/**
|
|
291
|
+
* `NOT` variant is intentionally excluded from public API (internal server-side use only).
|
|
292
|
+
*/
|
|
293
|
+
var NotificationRolesFilterTypeEnum;
|
|
294
|
+
(function (NotificationRolesFilterTypeEnum) {
|
|
295
|
+
NotificationRolesFilterTypeEnum["ALL"] = "all";
|
|
296
|
+
NotificationRolesFilterTypeEnum["ONLY"] = "only";
|
|
297
|
+
})(NotificationRolesFilterTypeEnum || (NotificationRolesFilterTypeEnum = {}));
|
|
298
|
+
|
|
243
299
|
function getVersion() {
|
|
244
300
|
try {
|
|
245
301
|
// the string ''v7.22.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -252,6 +308,7 @@ function getVersion() {
|
|
|
252
308
|
const VERSION = getVersion();
|
|
253
309
|
|
|
254
310
|
const COLLECTION_DEFAULT_PAGINATION_LIMIT = 5;
|
|
311
|
+
const COLLECTION_DEFAULT_PAGINATION_SIZE = 20;
|
|
255
312
|
const COLLECTION_DEFAULT_CACHING_POLICY = 'cache_then_server';
|
|
256
313
|
const ENABLE_CACHE_MESSAGE = 'For using Live Collection feature you need to enable Cache!';
|
|
257
314
|
const LIVE_OBJECT_ENABLE_CACHE_MESSAGE = 'For using Live Object feature you need to enable Cache!';
|
|
@@ -264,6 +321,9 @@ const DAY = 24 * HOUR;
|
|
|
264
321
|
const WEEK = 7 * DAY;
|
|
265
322
|
const YEAR = 365 * DAY;
|
|
266
323
|
const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
|
|
324
|
+
const API_ENDPOINTS = {
|
|
325
|
+
forYouFeed: '/api/v1/feeds/for-you',
|
|
326
|
+
};
|
|
267
327
|
|
|
268
328
|
// cache constants
|
|
269
329
|
const CACHE_KEY_GET = 'get';
|
|
@@ -644,6 +704,95 @@ function createSnapshot(data, options) {
|
|
|
644
704
|
return Object.assign(Object.assign({}, options), { data });
|
|
645
705
|
}
|
|
646
706
|
|
|
707
|
+
/* eslint-disable max-classes-per-file */
|
|
708
|
+
/**
|
|
709
|
+
* Generic ASC error
|
|
710
|
+
* @category Errors
|
|
711
|
+
*/
|
|
712
|
+
class ASCError extends Error {
|
|
713
|
+
/**
|
|
714
|
+
* @param message A custom error message
|
|
715
|
+
* @param code A normalized error code
|
|
716
|
+
* @param level A normalized failure level descriptor
|
|
717
|
+
*/
|
|
718
|
+
constructor(message, code, level) {
|
|
719
|
+
super(`Amity SDK (${code}): ${message}`);
|
|
720
|
+
this.code = code;
|
|
721
|
+
this.level = level;
|
|
722
|
+
this.type = 'ASC';
|
|
723
|
+
this.timestamp = Date.now();
|
|
724
|
+
if (Error.captureStackTrace)
|
|
725
|
+
Error.captureStackTrace(this, ASCError);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* API level error
|
|
730
|
+
* @category Errors
|
|
731
|
+
*/
|
|
732
|
+
class ASCApiError extends ASCError {
|
|
733
|
+
/**
|
|
734
|
+
* @param code A normalized error code
|
|
735
|
+
* @param level A normalized failure level descriptor
|
|
736
|
+
*/
|
|
737
|
+
// eslint-disable-next-line no-useless-constructor
|
|
738
|
+
constructor(message, code, level) {
|
|
739
|
+
super(message, code, level);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Unexpected error
|
|
744
|
+
* @category Errors
|
|
745
|
+
*/
|
|
746
|
+
class ASCUnknownError extends ASCError {
|
|
747
|
+
/**
|
|
748
|
+
* @param code A normalized error code
|
|
749
|
+
* @param level A normalized failure level descriptor
|
|
750
|
+
*/
|
|
751
|
+
constructor(code = 800000 /* Amity.ClientError.UNKNOWN_ERROR */, level = "fatal" /* Amity.ErrorLevel.FATAL */) {
|
|
752
|
+
super('Unexpected error', code, level);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Network related error
|
|
757
|
+
* @category Errors
|
|
758
|
+
*/
|
|
759
|
+
class ASCConnectionError extends ASCError {
|
|
760
|
+
/**
|
|
761
|
+
* @param message A custom error message
|
|
762
|
+
*/
|
|
763
|
+
constructor(event, message = 'SDK client is having connection issues') {
|
|
764
|
+
super(`${message} (${event})`, event === 'disconnected'
|
|
765
|
+
? 800211 /* Amity.ClientError.DISCONNECTED */
|
|
766
|
+
: 800210 /* Amity.ClientError.CONNECTION_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
767
|
+
this.event = event;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
let activeClient = null;
|
|
772
|
+
/**
|
|
773
|
+
* Get the active client
|
|
774
|
+
*
|
|
775
|
+
* @returns the active client instance
|
|
776
|
+
*
|
|
777
|
+
* @hidden
|
|
778
|
+
*/
|
|
779
|
+
const getActiveClient = () => {
|
|
780
|
+
if (!activeClient) {
|
|
781
|
+
throw new ASCError('There is no active client', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
782
|
+
}
|
|
783
|
+
return activeClient;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* Sets the active client
|
|
787
|
+
*
|
|
788
|
+
* @param client the client to assume as currently active client
|
|
789
|
+
*
|
|
790
|
+
* @hidden
|
|
791
|
+
*/
|
|
792
|
+
const setActiveClient = (client) => {
|
|
793
|
+
activeClient = client;
|
|
794
|
+
};
|
|
795
|
+
|
|
647
796
|
/** @hidden */
|
|
648
797
|
const idResolvers = {
|
|
649
798
|
user: ({ userId }) => userId,
|
|
@@ -652,6 +801,7 @@ const idResolvers = {
|
|
|
652
801
|
channel: ({ channelInternalId }) => channelInternalId,
|
|
653
802
|
subChannel: ({ subChannelId }) => subChannelId,
|
|
654
803
|
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
804
|
+
archivedChannel: ({ channelId }) => channelId,
|
|
655
805
|
message: ({ messageId, referenceId }) => referenceId !== null && referenceId !== void 0 ? referenceId : messageId,
|
|
656
806
|
messagePreviewChannel: ({ channelId }) => `${channelId}`,
|
|
657
807
|
messagePreviewSubChannel: ({ subChannelId }) => `${subChannelId}`,
|
|
@@ -693,6 +843,7 @@ const idResolvers = {
|
|
|
693
843
|
event: ({ eventId }) => eventId,
|
|
694
844
|
eventResponse: ({ userId }) => userId,
|
|
695
845
|
product: ({ productId }) => productId,
|
|
846
|
+
feedMetadata: ({ postId }) => postId,
|
|
696
847
|
};
|
|
697
848
|
/**
|
|
698
849
|
* Retrieve the id resolver matching a domain name
|
|
@@ -715,6 +866,7 @@ const PAYLOAD2MODEL = {
|
|
|
715
866
|
channels: 'channel',
|
|
716
867
|
messageFeeds: 'subChannel',
|
|
717
868
|
channelUsers: 'channelUsers',
|
|
869
|
+
archives: 'archivedChannel',
|
|
718
870
|
messages: 'message',
|
|
719
871
|
messagePreviewChannel: 'messagePreviewChannel',
|
|
720
872
|
messagePreviewSubChannel: 'messagePreviewSubChannel',
|
|
@@ -753,6 +905,7 @@ const PAYLOAD2MODEL = {
|
|
|
753
905
|
viewers: 'viewer',
|
|
754
906
|
eventResponses: 'eventResponse',
|
|
755
907
|
products: 'product',
|
|
908
|
+
feedMetadata: 'feedMetadata',
|
|
756
909
|
};
|
|
757
910
|
/** hidden */
|
|
758
911
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -767,95 +920,6 @@ function getFutureDate(date = new Date().toISOString()) {
|
|
|
767
920
|
return new Date(new Date(date).getTime() + 1).toISOString();
|
|
768
921
|
}
|
|
769
922
|
|
|
770
|
-
/* eslint-disable max-classes-per-file */
|
|
771
|
-
/**
|
|
772
|
-
* Generic ASC error
|
|
773
|
-
* @category Errors
|
|
774
|
-
*/
|
|
775
|
-
class ASCError extends Error {
|
|
776
|
-
/**
|
|
777
|
-
* @param message A custom error message
|
|
778
|
-
* @param code A normalized error code
|
|
779
|
-
* @param level A normalized failure level descriptor
|
|
780
|
-
*/
|
|
781
|
-
constructor(message, code, level) {
|
|
782
|
-
super(`Amity SDK (${code}): ${message}`);
|
|
783
|
-
this.code = code;
|
|
784
|
-
this.level = level;
|
|
785
|
-
this.type = 'ASC';
|
|
786
|
-
this.timestamp = Date.now();
|
|
787
|
-
if (Error.captureStackTrace)
|
|
788
|
-
Error.captureStackTrace(this, ASCError);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* API level error
|
|
793
|
-
* @category Errors
|
|
794
|
-
*/
|
|
795
|
-
class ASCApiError extends ASCError {
|
|
796
|
-
/**
|
|
797
|
-
* @param code A normalized error code
|
|
798
|
-
* @param level A normalized failure level descriptor
|
|
799
|
-
*/
|
|
800
|
-
// eslint-disable-next-line no-useless-constructor
|
|
801
|
-
constructor(message, code, level) {
|
|
802
|
-
super(message, code, level);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Unexpected error
|
|
807
|
-
* @category Errors
|
|
808
|
-
*/
|
|
809
|
-
class ASCUnknownError extends ASCError {
|
|
810
|
-
/**
|
|
811
|
-
* @param code A normalized error code
|
|
812
|
-
* @param level A normalized failure level descriptor
|
|
813
|
-
*/
|
|
814
|
-
constructor(code = 800000 /* Amity.ClientError.UNKNOWN_ERROR */, level = "fatal" /* Amity.ErrorLevel.FATAL */) {
|
|
815
|
-
super('Unexpected error', code, level);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
/**
|
|
819
|
-
* Network related error
|
|
820
|
-
* @category Errors
|
|
821
|
-
*/
|
|
822
|
-
class ASCConnectionError extends ASCError {
|
|
823
|
-
/**
|
|
824
|
-
* @param message A custom error message
|
|
825
|
-
*/
|
|
826
|
-
constructor(event, message = 'SDK client is having connection issues') {
|
|
827
|
-
super(`${message} (${event})`, event === 'disconnected'
|
|
828
|
-
? 800211 /* Amity.ClientError.DISCONNECTED */
|
|
829
|
-
: 800210 /* Amity.ClientError.CONNECTION_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
830
|
-
this.event = event;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
let activeClient = null;
|
|
835
|
-
/**
|
|
836
|
-
* Get the active client
|
|
837
|
-
*
|
|
838
|
-
* @returns the active client instance
|
|
839
|
-
*
|
|
840
|
-
* @hidden
|
|
841
|
-
*/
|
|
842
|
-
const getActiveClient = () => {
|
|
843
|
-
if (!activeClient) {
|
|
844
|
-
throw new ASCError('There is no active client', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
845
|
-
}
|
|
846
|
-
return activeClient;
|
|
847
|
-
};
|
|
848
|
-
/**
|
|
849
|
-
* Sets the active client
|
|
850
|
-
*
|
|
851
|
-
* @param client the client to assume as currently active client
|
|
852
|
-
*
|
|
853
|
-
* @hidden
|
|
854
|
-
*/
|
|
855
|
-
const setActiveClient = (client) => {
|
|
856
|
-
activeClient = client;
|
|
857
|
-
};
|
|
858
|
-
|
|
859
923
|
/**
|
|
860
924
|
* ```js
|
|
861
925
|
* import { enableCache } from '@amityco/ts-sdk'
|
|
@@ -1363,6 +1427,65 @@ const filterBySearchTerm = (collection, searchTerm) => {
|
|
|
1363
1427
|
return m.user && ((_a = m.user.displayName) === null || _a === void 0 ? void 0 : _a.match(containsMatcher));
|
|
1364
1428
|
});
|
|
1365
1429
|
};
|
|
1430
|
+
/**
|
|
1431
|
+
* The ids of users in a block relationship with the current user — in BOTH
|
|
1432
|
+
* directions — derived synchronously from the local follow cache. For every
|
|
1433
|
+
* `status === 'blocked'` row that involves the current user, the OTHER party
|
|
1434
|
+
* is collected: `from === me` (users I blocked, outgoing) contributes `to`;
|
|
1435
|
+
* `to === me` (users who blocked me, incoming) contributes `from`.
|
|
1436
|
+
*
|
|
1437
|
+
* @returns a set of block-related user ids (both directions)
|
|
1438
|
+
*
|
|
1439
|
+
* @hidden
|
|
1440
|
+
*/
|
|
1441
|
+
const getBlockUsersId = () => {
|
|
1442
|
+
var _a;
|
|
1443
|
+
const { userId } = getActiveClient();
|
|
1444
|
+
const ids = new Set();
|
|
1445
|
+
((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
|
|
1446
|
+
.map(entry => entry.data)
|
|
1447
|
+
.filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && (follow.from === userId || follow.to === userId))
|
|
1448
|
+
.forEach(follow => {
|
|
1449
|
+
ids.add(follow.from === userId ? follow.to : follow.from);
|
|
1450
|
+
});
|
|
1451
|
+
return ids;
|
|
1452
|
+
};
|
|
1453
|
+
/**
|
|
1454
|
+
* Filter out posts whose author or any mentionee is in a block relationship
|
|
1455
|
+
* with the current user, in either direction (see {@link getBlockUsersId}).
|
|
1456
|
+
*
|
|
1457
|
+
* @param collection the post collection to filter
|
|
1458
|
+
* @returns a filtered collection excluding posts involving block-related users
|
|
1459
|
+
*
|
|
1460
|
+
* @hidden
|
|
1461
|
+
*/
|
|
1462
|
+
const filterPostsByBlockUsers = (collection) => {
|
|
1463
|
+
const blockUsersId = getBlockUsersId();
|
|
1464
|
+
if (blockUsersId.size === 0)
|
|
1465
|
+
return collection;
|
|
1466
|
+
return collection.filter(post => {
|
|
1467
|
+
var _a, _b;
|
|
1468
|
+
if (blockUsersId.has(post.postedUserId))
|
|
1469
|
+
return false;
|
|
1470
|
+
const mentionedUserIds = (_b = (_a = post.mentionees) === null || _a === void 0 ? void 0 : _a.flatMap(mention => (mention.type === 'user' ? mention.userIds : []))) !== null && _b !== void 0 ? _b : [];
|
|
1471
|
+
return !mentionedUserIds.some(id => blockUsersId.has(id));
|
|
1472
|
+
});
|
|
1473
|
+
};
|
|
1474
|
+
/**
|
|
1475
|
+
* Filter out comments whose creator is in a block relationship with the
|
|
1476
|
+
* current user, in either direction (see {@link getBlockUsersId}).
|
|
1477
|
+
*
|
|
1478
|
+
* @param collection the comment collection to filter
|
|
1479
|
+
* @returns a filtered collection excluding comments from block-related users
|
|
1480
|
+
*
|
|
1481
|
+
* @hidden
|
|
1482
|
+
*/
|
|
1483
|
+
const filterCommentsByBlockUsers = (collection) => {
|
|
1484
|
+
const blockUsersId = getBlockUsersId();
|
|
1485
|
+
if (blockUsersId.size === 0)
|
|
1486
|
+
return collection;
|
|
1487
|
+
return collection.filter(comment => !blockUsersId.has(comment.userId));
|
|
1488
|
+
};
|
|
1366
1489
|
|
|
1367
1490
|
// Note:
|
|
1368
1491
|
// this file should contain a suite of sorting utilities to help the
|
|
@@ -1833,13 +1956,13 @@ class NetworkActivitiesWatcher {
|
|
|
1833
1956
|
this._listener.clear();
|
|
1834
1957
|
}
|
|
1835
1958
|
}
|
|
1836
|
-
let instance$
|
|
1959
|
+
let instance$b;
|
|
1837
1960
|
var NetworkActivitiesWatcher$1 = {
|
|
1838
1961
|
getInstance: () => {
|
|
1839
|
-
if (!instance$
|
|
1840
|
-
instance$
|
|
1962
|
+
if (!instance$b) {
|
|
1963
|
+
instance$b = new NetworkActivitiesWatcher();
|
|
1841
1964
|
}
|
|
1842
|
-
return instance$
|
|
1965
|
+
return instance$b;
|
|
1843
1966
|
},
|
|
1844
1967
|
};
|
|
1845
1968
|
|
|
@@ -20678,18 +20801,149 @@ var mqtt$1 = {exports: {}};
|
|
|
20678
20801
|
|
|
20679
20802
|
var mqtt = /*@__PURE__*/getDefaultExportFromCjs(mqtt$1.exports);
|
|
20680
20803
|
|
|
20804
|
+
class SessionWatcher {
|
|
20805
|
+
constructor() {
|
|
20806
|
+
this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
|
|
20807
|
+
this._listener = new Map();
|
|
20808
|
+
}
|
|
20809
|
+
onSessionStateChange(callback) {
|
|
20810
|
+
this._listener.set(callback, callback);
|
|
20811
|
+
return () => {
|
|
20812
|
+
this._listener.delete(callback);
|
|
20813
|
+
};
|
|
20814
|
+
}
|
|
20815
|
+
setSessionState(state, reason) {
|
|
20816
|
+
if (this._sessionState === state)
|
|
20817
|
+
return;
|
|
20818
|
+
this._sessionState = state;
|
|
20819
|
+
this._listener.forEach(cb => cb(state, reason));
|
|
20820
|
+
}
|
|
20821
|
+
destroy() {
|
|
20822
|
+
this._listener.clear();
|
|
20823
|
+
}
|
|
20824
|
+
}
|
|
20825
|
+
let instance$a;
|
|
20826
|
+
var SessionWatcher$1 = {
|
|
20827
|
+
getInstance: () => {
|
|
20828
|
+
if (!instance$a) {
|
|
20829
|
+
instance$a = new SessionWatcher();
|
|
20830
|
+
}
|
|
20831
|
+
return instance$a;
|
|
20832
|
+
},
|
|
20833
|
+
};
|
|
20834
|
+
|
|
20835
|
+
/**
|
|
20836
|
+
* ```js
|
|
20837
|
+
* import { onSessionStateChange } from '@amityco/ts-sdk'
|
|
20838
|
+
* const dispose = onSessionStateChange((state: Amity.SessionStates) => {
|
|
20839
|
+
* // ...
|
|
20840
|
+
* })
|
|
20841
|
+
* ```
|
|
20842
|
+
*
|
|
20843
|
+
* Fired when any {@link Amity.Client} has a session state change
|
|
20844
|
+
*
|
|
20845
|
+
* @param callback The function to call when the event was fired
|
|
20846
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
20847
|
+
*
|
|
20848
|
+
* @category Client Events
|
|
20849
|
+
*/
|
|
20850
|
+
const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
|
|
20851
|
+
|
|
20852
|
+
const TOPICS = {
|
|
20853
|
+
[AmityAutoSubscription.NETWORK]: [getNetworkTopic],
|
|
20854
|
+
[AmityAutoSubscription.CHAT]: [
|
|
20855
|
+
getSmartFeedChannelTopic,
|
|
20856
|
+
getSmartFeedSubChannelTopic,
|
|
20857
|
+
getSmartFeedMessageTopic,
|
|
20858
|
+
],
|
|
20859
|
+
[AmityAutoSubscription.LIVESTREAM]: [getLiveStreamTopic],
|
|
20860
|
+
[AmityAutoSubscription.BLOCK]: [getMyFollowersTopic, getMyFollowingsTopic],
|
|
20861
|
+
};
|
|
20862
|
+
const DEFAULT_TOPICS = [
|
|
20863
|
+
AmityAutoSubscription.CHAT,
|
|
20864
|
+
AmityAutoSubscription.NETWORK,
|
|
20865
|
+
AmityAutoSubscription.LIVESTREAM,
|
|
20866
|
+
AmityAutoSubscription.BLOCK,
|
|
20867
|
+
];
|
|
20868
|
+
const ALL_FEATURES = Object.values(AmityAutoSubscription);
|
|
20869
|
+
/** Ref-counted, reconnect-resilient registry of the managed auto-subscriptions. */
|
|
20870
|
+
class AutoSubscriptionManager {
|
|
20871
|
+
constructor() {
|
|
20872
|
+
this.refCountByFeature = new Map();
|
|
20873
|
+
this.disposers = new Map();
|
|
20874
|
+
this.seed();
|
|
20875
|
+
}
|
|
20876
|
+
seed() {
|
|
20877
|
+
this.refCountByFeature.clear();
|
|
20878
|
+
DEFAULT_TOPICS.forEach(feature => this.refCountByFeature.set(feature, 1));
|
|
20879
|
+
}
|
|
20880
|
+
isActive(feature) {
|
|
20881
|
+
var _a;
|
|
20882
|
+
return ((_a = this.refCountByFeature.get(feature)) !== null && _a !== void 0 ? _a : 0) > 0;
|
|
20883
|
+
}
|
|
20884
|
+
subscribeTopics(feature) {
|
|
20885
|
+
this.unsubscribeTopics(feature);
|
|
20886
|
+
this.disposers.set(feature, TOPICS[feature].map(buildTopic => subscribeTopic(buildTopic())));
|
|
20887
|
+
}
|
|
20888
|
+
unsubscribeTopics(feature) {
|
|
20889
|
+
var _a;
|
|
20890
|
+
((_a = this.disposers.get(feature)) !== null && _a !== void 0 ? _a : []).forEach(dispose => dispose());
|
|
20891
|
+
this.disposers.delete(feature);
|
|
20892
|
+
}
|
|
20893
|
+
/** Subscribe every enabled handle's topics, converging the broker to the registry. Called on each (re)connect. */
|
|
20894
|
+
initialize() {
|
|
20895
|
+
ALL_FEATURES.forEach(feature => {
|
|
20896
|
+
if (this.isActive(feature))
|
|
20897
|
+
this.subscribeTopics(feature);
|
|
20898
|
+
});
|
|
20899
|
+
}
|
|
20900
|
+
subscribe(feature) {
|
|
20901
|
+
var _a;
|
|
20902
|
+
const next = ((_a = this.refCountByFeature.get(feature)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
20903
|
+
this.refCountByFeature.set(feature, next);
|
|
20904
|
+
if (next === 1)
|
|
20905
|
+
this.subscribeTopics(feature);
|
|
20906
|
+
}
|
|
20907
|
+
unsubscribe(feature) {
|
|
20908
|
+
var _a;
|
|
20909
|
+
const next = Math.max(0, ((_a = this.refCountByFeature.get(feature)) !== null && _a !== void 0 ? _a : 0) - 1);
|
|
20910
|
+
this.refCountByFeature.set(feature, next);
|
|
20911
|
+
if (next === 0)
|
|
20912
|
+
this.unsubscribeTopics(feature);
|
|
20913
|
+
}
|
|
20914
|
+
subscriptions() {
|
|
20915
|
+
return ALL_FEATURES.map(feature => ({
|
|
20916
|
+
feature,
|
|
20917
|
+
isActive: this.isActive(feature),
|
|
20918
|
+
isSystem: true,
|
|
20919
|
+
topicCount: TOPICS[feature].length,
|
|
20920
|
+
}));
|
|
20921
|
+
}
|
|
20922
|
+
reset() {
|
|
20923
|
+
ALL_FEATURES.forEach(feature => this.unsubscribeTopics(feature));
|
|
20924
|
+
this.disposers.clear();
|
|
20925
|
+
this.seed();
|
|
20926
|
+
}
|
|
20927
|
+
}
|
|
20928
|
+
let instance$9 = null;
|
|
20929
|
+
const getAutoSubscriptionManager = () => {
|
|
20930
|
+
if (!instance$9)
|
|
20931
|
+
instance$9 = new AutoSubscriptionManager();
|
|
20932
|
+
return instance$9;
|
|
20933
|
+
};
|
|
20934
|
+
/** Resets the registry to its default baseline when the session ends. */
|
|
20935
|
+
const resetAutoSubscriptionsOnLogout = () => onSessionStateChange(state => {
|
|
20936
|
+
if (state !== "established" /* Amity.SessionStates.ESTABLISHED */)
|
|
20937
|
+
getAutoSubscriptionManager().reset();
|
|
20938
|
+
});
|
|
20939
|
+
|
|
20940
|
+
/**
|
|
20941
|
+
* (Re)subscribes the managed auto-subscription registry on every (re)connect.
|
|
20942
|
+
* The hardcoded topic list was promoted to the toggleable, ref-counted registry
|
|
20943
|
+
* in {@link getAutoSubscriptionManager} — see `client.manageAutoSubscriptions`.
|
|
20944
|
+
*/
|
|
20681
20945
|
const subscribeGlobalTopic = () => {
|
|
20682
|
-
|
|
20683
|
-
subscribeTopic(getNetworkTopic()),
|
|
20684
|
-
subscribeTopic(getSmartFeedChannelTopic()),
|
|
20685
|
-
subscribeTopic(getSmartFeedSubChannelTopic()),
|
|
20686
|
-
subscribeTopic(getSmartFeedMessageTopic()),
|
|
20687
|
-
// subscribing to user topic is necessary to handle ban event
|
|
20688
|
-
subscribeTopic(getUserTopic(getActiveUser())),
|
|
20689
|
-
subscribeTopic(getMarkerUserFeedTopic()),
|
|
20690
|
-
subscribeTopic(getLiveStreamTopic()),
|
|
20691
|
-
];
|
|
20692
|
-
return () => disposers.forEach(fn => fn());
|
|
20946
|
+
getAutoSubscriptionManager().initialize();
|
|
20693
20947
|
};
|
|
20694
20948
|
|
|
20695
20949
|
class OnMemoryStorage {
|
|
@@ -21225,8 +21479,12 @@ const getChannelMessagePreviewWithUser = (channel) => {
|
|
|
21225
21479
|
return Object.assign(Object.assign({}, channel), { messagePreview: messagePreviewWithUser });
|
|
21226
21480
|
};
|
|
21227
21481
|
|
|
21482
|
+
const convertDateStringToTimestamp = (dateString) => {
|
|
21483
|
+
return new Date(dateString).getTime();
|
|
21484
|
+
};
|
|
21485
|
+
|
|
21228
21486
|
const updateChannelMessagePreviewCache = (rawPayload) => {
|
|
21229
|
-
var _a
|
|
21487
|
+
var _a;
|
|
21230
21488
|
const withMessageFeedInfo = (messagePreview) => {
|
|
21231
21489
|
var _a;
|
|
21232
21490
|
const messageFeedInfo = (_a = rawPayload.messageFeedsInfo) === null || _a === void 0 ? void 0 : _a.find(messageFeed => {
|
|
@@ -21248,10 +21506,26 @@ const updateChannelMessagePreviewCache = (rawPayload) => {
|
|
|
21248
21506
|
subChannelUpdatedAt: messageFeedInfo === null || messageFeedInfo === void 0 ? void 0 : messageFeedInfo.updatedAt,
|
|
21249
21507
|
};
|
|
21250
21508
|
};
|
|
21251
|
-
|
|
21252
|
-
|
|
21253
|
-
|
|
21254
|
-
|
|
21509
|
+
// Skip server previews older than what's cached — the cache may carry a newer
|
|
21510
|
+
// preview written by handleMessageCreated from an MQTT message that the server
|
|
21511
|
+
// payload hasn't surfaced yet. Mirrors isLastestMessageOnChannel.
|
|
21512
|
+
const newPreviews = ((_a = rawPayload.messagePreviews) !== null && _a !== void 0 ? _a : [])
|
|
21513
|
+
.map(withMessageFeedInfo)
|
|
21514
|
+
.filter(preview => {
|
|
21515
|
+
var _a;
|
|
21516
|
+
const cached = (_a = pullFromCache([
|
|
21517
|
+
'messagePreviewChannel',
|
|
21518
|
+
'get',
|
|
21519
|
+
preview.channelId,
|
|
21520
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21521
|
+
if (!cached)
|
|
21522
|
+
return true;
|
|
21523
|
+
return (convertDateStringToTimestamp(cached.createdAt) <=
|
|
21524
|
+
convertDateStringToTimestamp(preview.createdAt));
|
|
21525
|
+
});
|
|
21526
|
+
if (newPreviews.length === 0)
|
|
21527
|
+
return;
|
|
21528
|
+
ingestInCache({ messagePreviewChannel: newPreviews });
|
|
21255
21529
|
};
|
|
21256
21530
|
|
|
21257
21531
|
const getSubChannelMessagePreview = (subChannelId) => {
|
|
@@ -21879,11 +22153,7 @@ getSubChannel$1.locally = (subChannelId) => {
|
|
|
21879
22153
|
};
|
|
21880
22154
|
};
|
|
21881
22155
|
|
|
21882
|
-
const
|
|
21883
|
-
return new Date(dateString).getTime();
|
|
21884
|
-
};
|
|
21885
|
-
|
|
21886
|
-
const getMessagePreviewSetting$1 = async () => {
|
|
22156
|
+
const getMessagePreviewSetting$2 = async () => {
|
|
21887
22157
|
const client = getActiveClient();
|
|
21888
22158
|
return client.getMessagePreviewSetting(false);
|
|
21889
22159
|
};
|
|
@@ -21918,7 +22188,7 @@ const isLastestMessageOnChannel = (message) => {
|
|
|
21918
22188
|
convertDateStringToTimestamp(cache.createdAt) <= convertDateStringToTimestamp(message.createdAt));
|
|
21919
22189
|
};
|
|
21920
22190
|
const handleMessageCreatedOnSubChannel = async (message) => {
|
|
21921
|
-
const messagePreviewSetting = await getMessagePreviewSetting$
|
|
22191
|
+
const messagePreviewSetting = await getMessagePreviewSetting$2();
|
|
21922
22192
|
const { channelId, messageId: messagePreviewId, creatorId, createdAt, updatedAt, data, dataType, subChannelId, channelSegment: segment, isDeleted, } = message;
|
|
21923
22193
|
// 1. get subChannel from cache, if not exist fetch from server
|
|
21924
22194
|
const subChannelCache = await getSubChannelCache(subChannelId);
|
|
@@ -22090,24 +22360,41 @@ const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated:
|
|
|
22090
22360
|
});
|
|
22091
22361
|
};
|
|
22092
22362
|
const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
22363
|
+
var _a, _b;
|
|
22093
22364
|
const channelsUnread = [];
|
|
22094
22365
|
for (let i = 0; i < channels.length; i += 1) {
|
|
22095
22366
|
if (isUnreadCountSupport(channels[i])) {
|
|
22096
22367
|
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
22097
22368
|
const channelUser = channelUsers.find(channelUser => channelUser.channelId === channels[i].channelId && channelUser.userId === currentUserId);
|
|
22098
|
-
|
|
22369
|
+
// readToSegment, lastMentionedSegment and lastSegment are monotonically non-decreasing;
|
|
22370
|
+
// prefer cached values when ahead of the server so a refetch returning stale data cannot
|
|
22371
|
+
const cached = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22372
|
+
const lastSegment = Math.max((_b = cached === null || cached === void 0 ? void 0 : cached.lastSegment) !== null && _b !== void 0 ? _b : 0, channels[i].messageCount);
|
|
22099
22373
|
let readToSegment = null;
|
|
22100
22374
|
let lastMentionedSegment = null;
|
|
22375
|
+
let unreadCount = 0;
|
|
22101
22376
|
let isMentioned = false;
|
|
22102
22377
|
if (channelUser) {
|
|
22103
|
-
|
|
22104
|
-
|
|
22105
|
-
|
|
22106
|
-
|
|
22378
|
+
const serverRead = channelUser.readToSegment;
|
|
22379
|
+
const serverMention = channelUser.lastMentionedSegment;
|
|
22380
|
+
readToSegment =
|
|
22381
|
+
typeof (cached === null || cached === void 0 ? void 0 : cached.readToSegment) === 'number' &&
|
|
22382
|
+
(typeof serverRead !== 'number' || cached.readToSegment > serverRead)
|
|
22383
|
+
? cached.readToSegment
|
|
22384
|
+
: serverRead !== null && serverRead !== void 0 ? serverRead : null;
|
|
22385
|
+
lastMentionedSegment =
|
|
22386
|
+
typeof (cached === null || cached === void 0 ? void 0 : cached.lastMentionedSegment) === 'number' &&
|
|
22387
|
+
(typeof serverMention !== 'number' || cached.lastMentionedSegment > serverMention)
|
|
22388
|
+
? cached.lastMentionedSegment
|
|
22389
|
+
: serverMention !== null && serverMention !== void 0 ? serverMention : null;
|
|
22390
|
+
const readForCalc = readToSegment !== null && readToSegment !== void 0 ? readToSegment : 0;
|
|
22391
|
+
unreadCount = Math.max(lastSegment - readForCalc, 0);
|
|
22392
|
+
isMentioned =
|
|
22393
|
+
typeof lastMentionedSegment === 'number' && readForCalc < lastMentionedSegment;
|
|
22107
22394
|
}
|
|
22108
22395
|
const cacheChannelUnread = {
|
|
22109
22396
|
channelId: channels[i].channelId,
|
|
22110
|
-
lastSegment
|
|
22397
|
+
lastSegment,
|
|
22111
22398
|
readToSegment,
|
|
22112
22399
|
lastMentionedSegment,
|
|
22113
22400
|
unreadCount,
|
|
@@ -22117,6 +22404,8 @@ const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
|
22117
22404
|
pushToCache(cacheKey, cacheChannelUnread);
|
|
22118
22405
|
channelsUnread.push(cacheChannelUnread);
|
|
22119
22406
|
}
|
|
22407
|
+
}
|
|
22408
|
+
if (channelsUnread.length > 0) {
|
|
22120
22409
|
fireEvent('local.channelUnread.updated', channelsUnread);
|
|
22121
22410
|
}
|
|
22122
22411
|
};
|
|
@@ -22816,7 +23105,7 @@ const onChannelMemberRoleRemoved = (callback) => {
|
|
|
22816
23105
|
const client = getActiveClient();
|
|
22817
23106
|
const filter = async (payload) => {
|
|
22818
23107
|
const { channels, channelUsers } = payload;
|
|
22819
|
-
|
|
23108
|
+
callbacks$1.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
|
|
22820
23109
|
};
|
|
22821
23110
|
mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
|
|
22822
23111
|
}
|
|
@@ -22824,6 +23113,39 @@ const onChannelMemberRoleRemoved = (callback) => {
|
|
|
22824
23113
|
return () => dispose$1(callback);
|
|
22825
23114
|
};
|
|
22826
23115
|
|
|
23116
|
+
/**
|
|
23117
|
+
* Fired when a {@link Amity.Channel} has been archived by the active user.
|
|
23118
|
+
*
|
|
23119
|
+
* @param callback The function to call when the event was fired
|
|
23120
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23121
|
+
*
|
|
23122
|
+
* @category Channel Events
|
|
23123
|
+
*/
|
|
23124
|
+
const onChannelArchived = (callback) => {
|
|
23125
|
+
const client = getActiveClient();
|
|
23126
|
+
const filter = async (payload) => {
|
|
23127
|
+
callback(payload);
|
|
23128
|
+
};
|
|
23129
|
+
return createEventSubscriber(client, 'onChannelArchived', 'local.channel.archived', filter);
|
|
23130
|
+
};
|
|
23131
|
+
|
|
23132
|
+
/**
|
|
23133
|
+
* Fired when a previously archived {@link Amity.Channel} has been unarchived
|
|
23134
|
+
* by the active user.
|
|
23135
|
+
*
|
|
23136
|
+
* @param callback The function to call when the event was fired
|
|
23137
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23138
|
+
*
|
|
23139
|
+
* @category Channel Events
|
|
23140
|
+
*/
|
|
23141
|
+
const onChannelUnarchived = (callback) => {
|
|
23142
|
+
const client = getActiveClient();
|
|
23143
|
+
const filter = async (payload) => {
|
|
23144
|
+
callback(payload);
|
|
23145
|
+
};
|
|
23146
|
+
return createEventSubscriber(client, 'onChannelUnarchived', 'local.channel.unarchived', filter);
|
|
23147
|
+
};
|
|
23148
|
+
|
|
22827
23149
|
const callbacks = [];
|
|
22828
23150
|
let mainDisposer = null;
|
|
22829
23151
|
const dispose = (cb) => {
|
|
@@ -22937,6 +23259,17 @@ const channelLinkedObject = (channel) => {
|
|
|
22937
23259
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
22938
23260
|
previewMembers,
|
|
22939
23261
|
myMembership: (callback) => getMyMembership(channel.channelId, callback),
|
|
23262
|
+
get avatar() {
|
|
23263
|
+
var _a;
|
|
23264
|
+
if (!channel.avatarFileId)
|
|
23265
|
+
return undefined;
|
|
23266
|
+
const avatar = (_a = pullFromCache([
|
|
23267
|
+
'file',
|
|
23268
|
+
'get',
|
|
23269
|
+
`${channel.avatarFileId}`,
|
|
23270
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23271
|
+
return avatar;
|
|
23272
|
+
},
|
|
22940
23273
|
});
|
|
22941
23274
|
};
|
|
22942
23275
|
|
|
@@ -23035,54 +23368,6 @@ getChannelByIds$1.locally = (channelIds) => {
|
|
|
23035
23368
|
};
|
|
23036
23369
|
};
|
|
23037
23370
|
|
|
23038
|
-
class SessionWatcher {
|
|
23039
|
-
constructor() {
|
|
23040
|
-
this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
|
|
23041
|
-
this._listener = new Map();
|
|
23042
|
-
}
|
|
23043
|
-
onSessionStateChange(callback) {
|
|
23044
|
-
this._listener.set(callback, callback);
|
|
23045
|
-
return () => {
|
|
23046
|
-
this._listener.delete(callback);
|
|
23047
|
-
};
|
|
23048
|
-
}
|
|
23049
|
-
setSessionState(state, reason) {
|
|
23050
|
-
if (this._sessionState === state)
|
|
23051
|
-
return;
|
|
23052
|
-
this._sessionState = state;
|
|
23053
|
-
this._listener.forEach(cb => cb(state, reason));
|
|
23054
|
-
}
|
|
23055
|
-
destroy() {
|
|
23056
|
-
this._listener.clear();
|
|
23057
|
-
}
|
|
23058
|
-
}
|
|
23059
|
-
let instance$8;
|
|
23060
|
-
var SessionWatcher$1 = {
|
|
23061
|
-
getInstance: () => {
|
|
23062
|
-
if (!instance$8) {
|
|
23063
|
-
instance$8 = new SessionWatcher();
|
|
23064
|
-
}
|
|
23065
|
-
return instance$8;
|
|
23066
|
-
},
|
|
23067
|
-
};
|
|
23068
|
-
|
|
23069
|
-
/**
|
|
23070
|
-
* ```js
|
|
23071
|
-
* import { onSessionStateChange } from '@amityco/ts-sdk'
|
|
23072
|
-
* const dispose = onSessionStateChange((state: Amity.SessionStates) => {
|
|
23073
|
-
* // ...
|
|
23074
|
-
* })
|
|
23075
|
-
* ```
|
|
23076
|
-
*
|
|
23077
|
-
* Fired when any {@link Amity.Client} has a session state change
|
|
23078
|
-
*
|
|
23079
|
-
* @param callback The function to call when the event was fired
|
|
23080
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23081
|
-
*
|
|
23082
|
-
* @category Client Events
|
|
23083
|
-
*/
|
|
23084
|
-
const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
|
|
23085
|
-
|
|
23086
23371
|
const setIntervalTask = (handler, timeout) => {
|
|
23087
23372
|
const timer = setInterval(handler, timeout);
|
|
23088
23373
|
return () => clearInterval(timer);
|
|
@@ -23254,7 +23539,7 @@ const convertMessagePreviewSetting = (chatSetting) => {
|
|
|
23254
23539
|
* @category private
|
|
23255
23540
|
* @async
|
|
23256
23541
|
*/
|
|
23257
|
-
const getMessagePreviewSetting = async (refresh = true) => {
|
|
23542
|
+
const getMessagePreviewSetting$1 = async (refresh = true) => {
|
|
23258
23543
|
var _a;
|
|
23259
23544
|
const messagePreviewSetting = (_a = pullFromCache([
|
|
23260
23545
|
'MessagePreviewSetting',
|
|
@@ -23275,7 +23560,7 @@ const getMessagePreviewSetting = async (refresh = true) => {
|
|
|
23275
23560
|
*/
|
|
23276
23561
|
const initializeMessagePreviewSetting = async () => {
|
|
23277
23562
|
var _a;
|
|
23278
|
-
const newMessagePreviewSetting = await getMessagePreviewSetting();
|
|
23563
|
+
const newMessagePreviewSetting = await getMessagePreviewSetting$1();
|
|
23279
23564
|
const messagePreviewSetting = (_a = pullFromCache([
|
|
23280
23565
|
'MessagePreviewSetting',
|
|
23281
23566
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
@@ -23346,6 +23631,26 @@ const getSocialSettings = async () => {
|
|
|
23346
23631
|
return data.socialNetworkSetting;
|
|
23347
23632
|
};
|
|
23348
23633
|
|
|
23634
|
+
/**
|
|
23635
|
+
* ```js
|
|
23636
|
+
* import { createClient } from '@amityco/ts-sdk'
|
|
23637
|
+
* const client = createClient(apiKey, apiRegion)
|
|
23638
|
+
* const userSettings = await client.getCoreUserSettings()
|
|
23639
|
+
* ```
|
|
23640
|
+
*
|
|
23641
|
+
* Fetches a {@link Amity.CoreUserSettings} object
|
|
23642
|
+
*
|
|
23643
|
+
* @returns A Promise of {@link Amity.CoreUserSettings} object
|
|
23644
|
+
*
|
|
23645
|
+
* @category Client API
|
|
23646
|
+
* @async
|
|
23647
|
+
*/
|
|
23648
|
+
const getCoreUserSettings = async () => {
|
|
23649
|
+
const client = getActiveClient();
|
|
23650
|
+
const { data } = await client.http.get(`/api/v3/network-settings/users`);
|
|
23651
|
+
return data;
|
|
23652
|
+
};
|
|
23653
|
+
|
|
23349
23654
|
/* begin_public_function
|
|
23350
23655
|
id: client.getProductCatalogueSetting
|
|
23351
23656
|
*/
|
|
@@ -23369,6 +23674,33 @@ const getProductCatalogueSetting = async () => {
|
|
|
23369
23674
|
};
|
|
23370
23675
|
/* end_public_function */
|
|
23371
23676
|
|
|
23677
|
+
/* begin_public_function
|
|
23678
|
+
id: client.getForYouFeedSetting
|
|
23679
|
+
*/
|
|
23680
|
+
/**
|
|
23681
|
+
* ```js
|
|
23682
|
+
* import { Client } from '@amityco/ts-sdk'
|
|
23683
|
+
* const forYouFeedSetting = await Client.getForYouFeedSetting()
|
|
23684
|
+
* ```
|
|
23685
|
+
*
|
|
23686
|
+
* Fetches the network-level {@link Amity.ForYouFeedSetting} — whether the For You
|
|
23687
|
+
* feed feature is enabled for the current network. Use `forYouFeed.enabled` as a
|
|
23688
|
+
* feature gate before querying {@link getForYouFeed}.
|
|
23689
|
+
*
|
|
23690
|
+
* @returns A Promise of {@link Amity.ForYouFeedSetting} object
|
|
23691
|
+
*
|
|
23692
|
+
* @category Client API
|
|
23693
|
+
* @async
|
|
23694
|
+
*/
|
|
23695
|
+
const getForYouFeedSetting = async () => {
|
|
23696
|
+
var _a, _b;
|
|
23697
|
+
const client = getActiveClient();
|
|
23698
|
+
const { data } = await client.http.get(`/api/v3/network-settings/for-you-feed`);
|
|
23699
|
+
// Surface only `enabled`; ignore server-side ranking config (scoringConfig, etc.)
|
|
23700
|
+
return { forYouFeed: { enabled: (_b = (_a = data.forYouFeed) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false } };
|
|
23701
|
+
};
|
|
23702
|
+
/* end_public_function */
|
|
23703
|
+
|
|
23372
23704
|
const checkUserPermission = (userId, permission) => {
|
|
23373
23705
|
var _a;
|
|
23374
23706
|
const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
@@ -23876,7 +24208,7 @@ class AnalyticsEventSyncer {
|
|
|
23876
24208
|
|
|
23877
24209
|
class AnalyticsEventCapturer {
|
|
23878
24210
|
constructor() {
|
|
23879
|
-
this._expireTime = 5 *
|
|
24211
|
+
this._expireTime = 5 * SECOND$1;
|
|
23880
24212
|
this._poolLimit = 1000;
|
|
23881
24213
|
this._recentViewed = {};
|
|
23882
24214
|
this._recentHighPriorityViewed = {};
|
|
@@ -23930,12 +24262,36 @@ class AnalyticsEventCapturer {
|
|
|
23930
24262
|
}
|
|
23931
24263
|
markPostAsViewed(postId) {
|
|
23932
24264
|
this.markAs({
|
|
23933
|
-
uniqueId: postId
|
|
24265
|
+
uniqueId: `post.${postId}`,
|
|
23934
24266
|
contentId: postId,
|
|
23935
24267
|
contentType: "post" /* Amity.AnalyticEventContentType.Post */,
|
|
23936
24268
|
activityType: "view" /* Amity.AnalyticEventActivityType.View */,
|
|
23937
24269
|
});
|
|
23938
24270
|
}
|
|
24271
|
+
markPostAsMeaningfullyViewed(postId, feedRenderPosition) {
|
|
24272
|
+
var _a;
|
|
24273
|
+
const cached = (_a = pullFromCache(['feedMetadata', 'get', postId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
24274
|
+
const metadata = {};
|
|
24275
|
+
if (feedRenderPosition !== undefined)
|
|
24276
|
+
metadata.feedRenderPosition = feedRenderPosition;
|
|
24277
|
+
if (cached) {
|
|
24278
|
+
metadata.feedSnapshotPosition = cached.feedSnapshotPosition;
|
|
24279
|
+
metadata.feedInjectionType = cached.feedInjectionType;
|
|
24280
|
+
metadata.feedRelevanceScore = cached.feedRelevanceScore;
|
|
24281
|
+
metadata.feedPopularityScore = cached.feedPopularityScore;
|
|
24282
|
+
metadata.feedFreshnessScore = cached.feedFreshnessScore;
|
|
24283
|
+
metadata.feedAffinityScore = cached.feedAffinityScore;
|
|
24284
|
+
metadata.feedFinalScore = cached.feedFinalScore;
|
|
24285
|
+
metadata.feedMmrPenalty = cached.feedMmrPenalty;
|
|
24286
|
+
}
|
|
24287
|
+
this.markAs({
|
|
24288
|
+
uniqueId: `post.${postId}.meaningfulView`,
|
|
24289
|
+
contentId: postId,
|
|
24290
|
+
contentType: "post" /* Amity.AnalyticEventContentType.Post */,
|
|
24291
|
+
activityType: "meaningfulView" /* Amity.AnalyticEventActivityType.MeaningfulView */,
|
|
24292
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
|
|
24293
|
+
});
|
|
24294
|
+
}
|
|
23939
24295
|
markStory(story, activityType) {
|
|
23940
24296
|
if (!story.expiresAt)
|
|
23941
24297
|
return;
|
|
@@ -24075,6 +24431,12 @@ class AnalyticsEngine {
|
|
|
24075
24431
|
this._eventCapturer.markPostAsViewed(postId);
|
|
24076
24432
|
}
|
|
24077
24433
|
}
|
|
24434
|
+
markPostAsMeaningfullyViewed(postId, feedRenderPosition) {
|
|
24435
|
+
if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
|
|
24436
|
+
this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
24437
|
+
this._eventCapturer.markPostAsMeaningfullyViewed(postId, feedRenderPosition);
|
|
24438
|
+
}
|
|
24439
|
+
}
|
|
24078
24440
|
markStoryAsViewed(story) {
|
|
24079
24441
|
if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
|
|
24080
24442
|
this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */ // For case token_expired, we assume token is expired and gonna re-connect soon
|
|
@@ -24126,13 +24488,13 @@ class AnalyticsEngine {
|
|
|
24126
24488
|
this._eventCapturer.resetAllBuckets();
|
|
24127
24489
|
}
|
|
24128
24490
|
}
|
|
24129
|
-
let instance$
|
|
24491
|
+
let instance$8;
|
|
24130
24492
|
var AnalyticsEngine$1 = {
|
|
24131
24493
|
getInstance: () => {
|
|
24132
|
-
if (!instance$
|
|
24133
|
-
instance$
|
|
24494
|
+
if (!instance$8) {
|
|
24495
|
+
instance$8 = new AnalyticsEngine();
|
|
24134
24496
|
}
|
|
24135
|
-
return instance$
|
|
24497
|
+
return instance$8;
|
|
24136
24498
|
},
|
|
24137
24499
|
};
|
|
24138
24500
|
|
|
@@ -24299,9 +24661,8 @@ class MessageReadReceiptSyncEngine {
|
|
|
24299
24661
|
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
24300
24662
|
const cacheKey = ['channelUnread', 'get', channelId];
|
|
24301
24663
|
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24302
|
-
if (
|
|
24303
|
-
channelUnread
|
|
24304
|
-
segment > channelUnread.readToSegment) {
|
|
24664
|
+
if (channelUnread &&
|
|
24665
|
+
(typeof channelUnread.readToSegment !== 'number' || segment > channelUnread.readToSegment)) {
|
|
24305
24666
|
channelUnread.readToSegment = segment;
|
|
24306
24667
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
24307
24668
|
pushToCache(cacheKey, channelUnread);
|
|
@@ -24360,12 +24721,12 @@ class MessageReadReceiptSyncEngine {
|
|
|
24360
24721
|
}
|
|
24361
24722
|
}
|
|
24362
24723
|
}
|
|
24363
|
-
let instance$
|
|
24724
|
+
let instance$7 = null;
|
|
24364
24725
|
var ReadReceiptSyncEngine = {
|
|
24365
24726
|
getInstance: () => {
|
|
24366
|
-
if (!instance$
|
|
24367
|
-
instance$
|
|
24368
|
-
return instance$
|
|
24727
|
+
if (!instance$7)
|
|
24728
|
+
instance$7 = new MessageReadReceiptSyncEngine();
|
|
24729
|
+
return instance$7;
|
|
24369
24730
|
},
|
|
24370
24731
|
};
|
|
24371
24732
|
|
|
@@ -24619,12 +24980,12 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
24619
24980
|
}
|
|
24620
24981
|
}
|
|
24621
24982
|
}
|
|
24622
|
-
let instance$
|
|
24983
|
+
let instance$6 = null;
|
|
24623
24984
|
var LegacyReadReceiptSyncEngine = {
|
|
24624
24985
|
getInstance: () => {
|
|
24625
|
-
if (!instance$
|
|
24626
|
-
instance$
|
|
24627
|
-
return instance$
|
|
24986
|
+
if (!instance$6)
|
|
24987
|
+
instance$6 = new LegacyMessageReadReceiptSyncEngine();
|
|
24988
|
+
return instance$6;
|
|
24628
24989
|
},
|
|
24629
24990
|
};
|
|
24630
24991
|
|
|
@@ -24870,12 +25231,12 @@ class ObjectResolverEngine {
|
|
|
24870
25231
|
this.stopResolver();
|
|
24871
25232
|
}
|
|
24872
25233
|
}
|
|
24873
|
-
let instance$
|
|
25234
|
+
let instance$5 = null;
|
|
24874
25235
|
var ObjectResolverEngine$1 = {
|
|
24875
25236
|
getInstance: () => {
|
|
24876
|
-
if (!instance$
|
|
24877
|
-
instance$
|
|
24878
|
-
return instance$
|
|
25237
|
+
if (!instance$5)
|
|
25238
|
+
instance$5 = new ObjectResolverEngine();
|
|
25239
|
+
return instance$5;
|
|
24879
25240
|
},
|
|
24880
25241
|
};
|
|
24881
25242
|
|
|
@@ -25025,13 +25386,13 @@ class LiveReactionSyncEngine {
|
|
|
25025
25386
|
this.stopReactionsSync();
|
|
25026
25387
|
}
|
|
25027
25388
|
}
|
|
25028
|
-
let instance$
|
|
25389
|
+
let instance$4;
|
|
25029
25390
|
var ReactionSyncEngine = {
|
|
25030
25391
|
getInstance: () => {
|
|
25031
|
-
if (!instance$
|
|
25032
|
-
instance$
|
|
25392
|
+
if (!instance$4) {
|
|
25393
|
+
instance$4 = new LiveReactionSyncEngine();
|
|
25033
25394
|
}
|
|
25034
|
-
return instance$
|
|
25395
|
+
return instance$4;
|
|
25035
25396
|
},
|
|
25036
25397
|
};
|
|
25037
25398
|
|
|
@@ -25061,19 +25422,20 @@ function prepareBlockedUserPayload(response) {
|
|
|
25061
25422
|
}), users: users.map(convertRawUserToInternalUser) });
|
|
25062
25423
|
}
|
|
25063
25424
|
|
|
25064
|
-
const BLOCK_LIST_LIMIT = 100;
|
|
25065
|
-
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
25425
|
+
const BLOCK_LIST_LIMIT$1 = 100;
|
|
25426
|
+
const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
|
|
25066
25427
|
/**
|
|
25067
25428
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
25068
25429
|
* of blocked users. Provides a lazy `ensureFetched()` gate for the
|
|
25069
25430
|
* `getAllBlockedUsers()` API.
|
|
25070
25431
|
*
|
|
25071
25432
|
* Key behaviours:
|
|
25072
|
-
* - `
|
|
25073
|
-
* - `
|
|
25433
|
+
* - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
|
|
25434
|
+
* - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
|
|
25074
25435
|
* - `ensureFetched()` fetches from server only when cache is expired or never fetched
|
|
25075
25436
|
* - `lastFetchedAt` is only updated on successful fetch
|
|
25076
|
-
* -
|
|
25437
|
+
* - reads query the follow cache live, so block/unblock changes are reflected
|
|
25438
|
+
* even within the TTL window
|
|
25077
25439
|
*
|
|
25078
25440
|
* @internal
|
|
25079
25441
|
*/
|
|
@@ -25081,12 +25443,7 @@ class BlockedUserSyncEngine {
|
|
|
25081
25443
|
constructor() {
|
|
25082
25444
|
/** Epoch ms of last successful fetch. null = never fetched in this session. */
|
|
25083
25445
|
this.lastFetchedAt = null;
|
|
25084
|
-
/** Ordered list of userId strings from the most recent successful fetch. */
|
|
25085
|
-
this.blockedUserIds = [];
|
|
25086
25446
|
}
|
|
25087
|
-
// ---------------------------------------------------------------------------
|
|
25088
|
-
// SessionComponent lifecycle
|
|
25089
|
-
// ---------------------------------------------------------------------------
|
|
25090
25447
|
/** No-op — fetch is lazy, triggered by consumer calling getAllBlockedUsers(). */
|
|
25091
25448
|
// eslint-disable-next-line class-methods-use-this
|
|
25092
25449
|
onSessionEstablished() {
|
|
@@ -25095,24 +25452,17 @@ class BlockedUserSyncEngine {
|
|
|
25095
25452
|
/** Resets state so the next session starts with a cold cache. */
|
|
25096
25453
|
onSessionDestroyed() {
|
|
25097
25454
|
this.lastFetchedAt = null;
|
|
25098
|
-
this.blockedUserIds = [];
|
|
25099
25455
|
}
|
|
25100
25456
|
/** No-op for this engine. */
|
|
25101
25457
|
// eslint-disable-next-line class-methods-use-this
|
|
25102
25458
|
onTokenExpired() {
|
|
25103
25459
|
// intentionally empty
|
|
25104
25460
|
}
|
|
25105
|
-
// ---------------------------------------------------------------------------
|
|
25106
|
-
// Cache helpers
|
|
25107
|
-
// ---------------------------------------------------------------------------
|
|
25108
25461
|
isCacheExpired() {
|
|
25109
25462
|
if (this.lastFetchedAt === null)
|
|
25110
25463
|
return true;
|
|
25111
|
-
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
25464
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$1;
|
|
25112
25465
|
}
|
|
25113
|
-
// ---------------------------------------------------------------------------
|
|
25114
|
-
// Core fetch gate
|
|
25115
|
-
// ---------------------------------------------------------------------------
|
|
25116
25466
|
/**
|
|
25117
25467
|
* Ensures the local store is populated with fresh blocked-user data.
|
|
25118
25468
|
*
|
|
@@ -25128,52 +25478,50 @@ class BlockedUserSyncEngine {
|
|
|
25128
25478
|
if (!this.isCacheExpired())
|
|
25129
25479
|
return;
|
|
25130
25480
|
const client = getActiveClient();
|
|
25131
|
-
const { data } = await client.http.get('/api/v4/me/user-blocks', { params: { options: { limit: BLOCK_LIST_LIMIT }, isDeleted: false } });
|
|
25481
|
+
const { data } = await client.http.get('/api/v4/me/user-blocks', { params: { options: { limit: BLOCK_LIST_LIMIT$1 }, isDeleted: false } });
|
|
25132
25482
|
const cachedAt = client.cache && Date.now();
|
|
25133
25483
|
const payload = prepareBlockedUserPayload(data);
|
|
25134
25484
|
if (client.cache) {
|
|
25135
25485
|
ingestInCache(payload, { cachedAt });
|
|
25136
25486
|
}
|
|
25137
|
-
// Keep the ordered list of blocked user IDs for getCachedUsers()
|
|
25138
|
-
this.blockedUserIds = payload.users.map(u => u.userId);
|
|
25139
25487
|
// Only update timestamp on success — failure leaves it unchanged so the
|
|
25140
25488
|
// next call retries.
|
|
25141
25489
|
this.lastFetchedAt = Date.now();
|
|
25142
25490
|
}
|
|
25143
|
-
// ---------------------------------------------------------------------------
|
|
25144
|
-
// Local store read
|
|
25145
|
-
// ---------------------------------------------------------------------------
|
|
25146
25491
|
/**
|
|
25147
|
-
* Returns blocked
|
|
25492
|
+
* Returns the blocked users by querying the follow cache live — the outgoing
|
|
25493
|
+
* direction (`from === me`, `status === 'blocked'`). Reading the cache (not a
|
|
25494
|
+
* fetched snapshot) means `blockUser()` / `unblockUser()` changes are reflected
|
|
25495
|
+
* even within the TTL window.
|
|
25148
25496
|
*
|
|
25149
|
-
* Applies the spec-mandated
|
|
25150
|
-
* -
|
|
25151
|
-
* -
|
|
25152
|
-
*
|
|
25153
|
-
* This always reads the latest local state, so changes made by `blockUser()`
|
|
25154
|
-
* and `unblockUser()` are reflected even within the TTL window.
|
|
25497
|
+
* Applies the spec-mandated query:
|
|
25498
|
+
* - filter `from === currentUserId`, `status === 'blocked'`, blocked user not deleted
|
|
25499
|
+
* - sort by `updatedAt` DESC
|
|
25500
|
+
* - hard limit of 100 results
|
|
25155
25501
|
*/
|
|
25502
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25156
25503
|
getCachedUsers() {
|
|
25504
|
+
var _a;
|
|
25157
25505
|
const client = getActiveClient();
|
|
25158
|
-
if (!client.cache)
|
|
25159
|
-
// No cache available — fall back to the in-memory list from the last fetch
|
|
25506
|
+
if (!client.cache)
|
|
25160
25507
|
return [];
|
|
25161
|
-
}
|
|
25162
|
-
return
|
|
25163
|
-
.map(
|
|
25508
|
+
const { userId } = client;
|
|
25509
|
+
return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
|
|
25510
|
+
.map(entry => entry.data)
|
|
25511
|
+
.filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && follow.from === userId)
|
|
25512
|
+
.sort((a, b) => { var _a, _b; return (((_a = a.updatedAt) !== null && _a !== void 0 ? _a : '') < ((_b = b.updatedAt) !== null && _b !== void 0 ? _b : '') ? 1 : -1); })
|
|
25513
|
+
.map(follow => { var _a; return (_a = pullFromCache(['user', 'get', follow.to])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
25164
25514
|
.filter((user) => user != null && user.isDeleted !== true)
|
|
25165
|
-
.slice(0, BLOCK_LIST_LIMIT)
|
|
25515
|
+
.slice(0, BLOCK_LIST_LIMIT$1)
|
|
25516
|
+
.map(userLinkedObject);
|
|
25166
25517
|
}
|
|
25167
25518
|
}
|
|
25168
|
-
|
|
25169
|
-
// Module-level singleton
|
|
25170
|
-
// ---------------------------------------------------------------------------
|
|
25171
|
-
let instance$2 = null;
|
|
25519
|
+
let instance$3 = null;
|
|
25172
25520
|
var BlockedUserSyncEngine$1 = {
|
|
25173
25521
|
getInstance: () => {
|
|
25174
|
-
if (!instance$
|
|
25175
|
-
instance$
|
|
25176
|
-
return instance$
|
|
25522
|
+
if (!instance$3)
|
|
25523
|
+
instance$3 = new BlockedUserSyncEngine();
|
|
25524
|
+
return instance$3;
|
|
25177
25525
|
},
|
|
25178
25526
|
};
|
|
25179
25527
|
|
|
@@ -25195,6 +25543,290 @@ var blockedUserSyncEngineOnLoginHandler = () => {
|
|
|
25195
25543
|
};
|
|
25196
25544
|
};
|
|
25197
25545
|
|
|
25546
|
+
function prepareBlockingUserPayload(response) {
|
|
25547
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
25548
|
+
return Object.assign(Object.assign({}, rest), { follows: follows.map(follow => {
|
|
25549
|
+
const followUser = users.find(user => user.userId === follow.from);
|
|
25550
|
+
return Object.assign(Object.assign({}, follow), { user: convertRawUserToInternalUser(followUser) });
|
|
25551
|
+
}), users: users.map(convertRawUserToInternalUser) });
|
|
25552
|
+
}
|
|
25553
|
+
|
|
25554
|
+
const BLOCK_LIST_LIMIT = 100;
|
|
25555
|
+
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
25556
|
+
/**
|
|
25557
|
+
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
25558
|
+
* of blocking users (the "blocked-by" list — users who blocked the current
|
|
25559
|
+
* user). Provides a lazy `ensureFetched()` gate for the `getAllBlockingUsers()`
|
|
25560
|
+
* API. Directional inverse of {@link BlockedUserSyncEngine}.
|
|
25561
|
+
*
|
|
25562
|
+
* Key behaviours:
|
|
25563
|
+
* - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
|
|
25564
|
+
* - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
|
|
25565
|
+
* - `ensureFetched()` fetches from server only when cache is expired or never fetched
|
|
25566
|
+
* - `lastFetchedAt` is only updated on successful fetch
|
|
25567
|
+
* - reads query the follow cache live, so block/unblock changes are reflected
|
|
25568
|
+
* even within the TTL window
|
|
25569
|
+
*
|
|
25570
|
+
* @internal
|
|
25571
|
+
*/
|
|
25572
|
+
class BlockingUserSyncEngine {
|
|
25573
|
+
constructor() {
|
|
25574
|
+
/** Epoch ms of last successful fetch. null = never fetched in this session. */
|
|
25575
|
+
this.lastFetchedAt = null;
|
|
25576
|
+
}
|
|
25577
|
+
/** No-op — fetch is lazy, triggered by consumer calling getAllBlockingUsers(). */
|
|
25578
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25579
|
+
onSessionEstablished() {
|
|
25580
|
+
// intentionally empty
|
|
25581
|
+
}
|
|
25582
|
+
/** Resets state so the next session starts with a cold cache. */
|
|
25583
|
+
onSessionDestroyed() {
|
|
25584
|
+
this.lastFetchedAt = null;
|
|
25585
|
+
}
|
|
25586
|
+
/** No-op for this engine. */
|
|
25587
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25588
|
+
onTokenExpired() {
|
|
25589
|
+
// intentionally empty
|
|
25590
|
+
}
|
|
25591
|
+
isCacheExpired() {
|
|
25592
|
+
if (this.lastFetchedAt === null)
|
|
25593
|
+
return true;
|
|
25594
|
+
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
25595
|
+
}
|
|
25596
|
+
/**
|
|
25597
|
+
* Ensures the local store is populated with fresh blocking-user data.
|
|
25598
|
+
*
|
|
25599
|
+
* - If the cache is still within the 5-minute TTL window: resolves immediately
|
|
25600
|
+
* (no server call).
|
|
25601
|
+
* - If the cache is expired (or never fetched): fetches from the server,
|
|
25602
|
+
* persists the payload to the cache, and updates `lastFetchedAt`.
|
|
25603
|
+
*
|
|
25604
|
+
* On failure the error propagates to the caller and `lastFetchedAt` is NOT
|
|
25605
|
+
* updated, so the next call will retry.
|
|
25606
|
+
*/
|
|
25607
|
+
async ensureFetched() {
|
|
25608
|
+
if (!this.isCacheExpired())
|
|
25609
|
+
return;
|
|
25610
|
+
const client = getActiveClient();
|
|
25611
|
+
const { data } = await client.http.get('/api/v4/me/blockers', { params: { options: { limit: BLOCK_LIST_LIMIT }, isDeleted: false } });
|
|
25612
|
+
const cachedAt = client.cache && Date.now();
|
|
25613
|
+
const payload = prepareBlockingUserPayload(data);
|
|
25614
|
+
if (client.cache) {
|
|
25615
|
+
ingestInCache(payload, { cachedAt });
|
|
25616
|
+
}
|
|
25617
|
+
// Only update timestamp on success — failure leaves it unchanged so the
|
|
25618
|
+
// next call retries.
|
|
25619
|
+
this.lastFetchedAt = Date.now();
|
|
25620
|
+
}
|
|
25621
|
+
/**
|
|
25622
|
+
* Returns the "blocked-by" users by querying the follow cache live — the
|
|
25623
|
+
* incoming direction (`to === me`, `status === 'blocked'`). Reading the cache
|
|
25624
|
+
* (not a fetched snapshot) means RTE `user.didBlock` / `user.didUnblock`
|
|
25625
|
+
* changes are reflected even within the TTL window.
|
|
25626
|
+
*
|
|
25627
|
+
* Applies the spec-mandated query (REQ-012/013/014):
|
|
25628
|
+
* - filter `to === currentUserId`, `status === 'blocked'`, blocker not deleted
|
|
25629
|
+
* - sort by `updatedAt` DESC
|
|
25630
|
+
* - hard limit of 100 results
|
|
25631
|
+
*/
|
|
25632
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25633
|
+
getCachedUsers() {
|
|
25634
|
+
var _a;
|
|
25635
|
+
const client = getActiveClient();
|
|
25636
|
+
if (!client.cache)
|
|
25637
|
+
return [];
|
|
25638
|
+
const { userId } = client;
|
|
25639
|
+
return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
|
|
25640
|
+
.map(entry => entry.data)
|
|
25641
|
+
.filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && follow.to === userId)
|
|
25642
|
+
.sort((a, b) => { var _a, _b; return (((_a = a.updatedAt) !== null && _a !== void 0 ? _a : '') < ((_b = b.updatedAt) !== null && _b !== void 0 ? _b : '') ? 1 : -1); })
|
|
25643
|
+
.map(follow => { var _a; return (_a = pullFromCache(['user', 'get', follow.from])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
25644
|
+
.filter((user) => user != null && user.isDeleted !== true)
|
|
25645
|
+
.slice(0, BLOCK_LIST_LIMIT)
|
|
25646
|
+
.map(userLinkedObject);
|
|
25647
|
+
}
|
|
25648
|
+
}
|
|
25649
|
+
let instance$2 = null;
|
|
25650
|
+
var BlockingUserSyncEngine$1 = {
|
|
25651
|
+
getInstance: () => {
|
|
25652
|
+
if (!instance$2)
|
|
25653
|
+
instance$2 = new BlockingUserSyncEngine();
|
|
25654
|
+
return instance$2;
|
|
25655
|
+
},
|
|
25656
|
+
};
|
|
25657
|
+
|
|
25658
|
+
var blockingUserSyncEngineOnLoginHandler = () => {
|
|
25659
|
+
const blockingUserSyncEngine = BlockingUserSyncEngine$1.getInstance();
|
|
25660
|
+
onSessionStateChange(state => {
|
|
25661
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
25662
|
+
blockingUserSyncEngine.onSessionEstablished();
|
|
25663
|
+
}
|
|
25664
|
+
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
25665
|
+
blockingUserSyncEngine.onTokenExpired();
|
|
25666
|
+
}
|
|
25667
|
+
else {
|
|
25668
|
+
blockingUserSyncEngine.onSessionDestroyed();
|
|
25669
|
+
}
|
|
25670
|
+
});
|
|
25671
|
+
return () => {
|
|
25672
|
+
blockingUserSyncEngine.onSessionDestroyed();
|
|
25673
|
+
};
|
|
25674
|
+
};
|
|
25675
|
+
|
|
25676
|
+
function prepareFollowersPayload(response) {
|
|
25677
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
25678
|
+
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
25679
|
+
}
|
|
25680
|
+
function prepareFollowingsPayload(response) {
|
|
25681
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
25682
|
+
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
25683
|
+
}
|
|
25684
|
+
function prepareFollowStatusPayload(response) {
|
|
25685
|
+
const { follows } = response, rest = __rest(response, ["follows"]);
|
|
25686
|
+
return Object.assign(Object.assign({}, rest), { follows });
|
|
25687
|
+
}
|
|
25688
|
+
|
|
25689
|
+
/**
|
|
25690
|
+
* Subscribes to a block MQTT event (`user.didBlock` / `user.didUnblock`),
|
|
25691
|
+
* ingests the carried `FollowersPayload` (follows + users) into the cache so
|
|
25692
|
+
* the block-relationship rows (`['follow', 'get', from#to]`) and user rows are
|
|
25693
|
+
* kept current, then forwards the affected {@link Amity.FollowStatus} to the
|
|
25694
|
+
* caller.
|
|
25695
|
+
*
|
|
25696
|
+
* @hidden
|
|
25697
|
+
*/
|
|
25698
|
+
const createBlockEventSubscriber = (event, callback) => {
|
|
25699
|
+
const client = getActiveClient();
|
|
25700
|
+
const filter = (data) => {
|
|
25701
|
+
const payload = prepareFollowersPayload(data);
|
|
25702
|
+
if (client.cache) {
|
|
25703
|
+
ingestInCache(payload);
|
|
25704
|
+
}
|
|
25705
|
+
callback(payload.follows[0]);
|
|
25706
|
+
};
|
|
25707
|
+
return createEventSubscriber(client, event, event, filter);
|
|
25708
|
+
};
|
|
25709
|
+
|
|
25710
|
+
/**
|
|
25711
|
+
* ```js
|
|
25712
|
+
* import { onUserDidBlock } from '@amityco/ts-sdk'
|
|
25713
|
+
* const dispose = onUserDidBlock(status => {
|
|
25714
|
+
* // ...
|
|
25715
|
+
* })
|
|
25716
|
+
* ```
|
|
25717
|
+
*
|
|
25718
|
+
* Fired when a block relationship is created in real time — either a user
|
|
25719
|
+
* blocks the current user (incoming) or the current user blocks someone on
|
|
25720
|
+
* another device (outgoing). The local block-relationship store is updated
|
|
25721
|
+
* before the callback runs.
|
|
25722
|
+
*
|
|
25723
|
+
* @param callback The function to call when the event was fired
|
|
25724
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
25725
|
+
*
|
|
25726
|
+
* @category Block Events
|
|
25727
|
+
*/
|
|
25728
|
+
const onUserDidBlock = (callback) => createBlockEventSubscriber('user.didBlock', callback);
|
|
25729
|
+
|
|
25730
|
+
/**
|
|
25731
|
+
* ```js
|
|
25732
|
+
* import { onUserDidUnblock } from '@amityco/ts-sdk'
|
|
25733
|
+
* const dispose = onUserDidUnblock(status => {
|
|
25734
|
+
* // ...
|
|
25735
|
+
* })
|
|
25736
|
+
* ```
|
|
25737
|
+
*
|
|
25738
|
+
* Fired when a block relationship is removed in real time — either a user
|
|
25739
|
+
* unblocks the current user (incoming) or the current user unblocks someone on
|
|
25740
|
+
* another device (outgoing). The local block-relationship store is updated
|
|
25741
|
+
* before the callback runs.
|
|
25742
|
+
*
|
|
25743
|
+
* @param callback The function to call when the event was fired
|
|
25744
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
25745
|
+
*
|
|
25746
|
+
* @category Block Events
|
|
25747
|
+
*/
|
|
25748
|
+
const onUserDidUnblock = (callback) => createBlockEventSubscriber('user.didUnblock', callback);
|
|
25749
|
+
|
|
25750
|
+
/**
|
|
25751
|
+
* Keeps the follow cache current for incoming/outgoing block changes for the
|
|
25752
|
+
* whole session — the ingest happens as a side effect inside
|
|
25753
|
+
* createBlockEventSubscriber, so the one-shot `getAllBlockedUsers()` /
|
|
25754
|
+
* `getAllBlockingUsers()` reflect RTE block/unblock within the TTL window.
|
|
25755
|
+
*
|
|
25756
|
+
* Registered via `setupLoginSubscriptions`; the returned unsubscriber is torn
|
|
25757
|
+
* down on logout.
|
|
25758
|
+
*/
|
|
25759
|
+
var blockRealtimeOnLoginHandler = () => {
|
|
25760
|
+
const disposers = [onUserDidBlock(() => { }), onUserDidUnblock(() => { })];
|
|
25761
|
+
return () => disposers.forEach(dispose => dispose());
|
|
25762
|
+
};
|
|
25763
|
+
|
|
25764
|
+
class CursorController {
|
|
25765
|
+
constructor(networkId, userId) {
|
|
25766
|
+
this.networkId = networkId;
|
|
25767
|
+
this.userId = userId;
|
|
25768
|
+
}
|
|
25769
|
+
static current() {
|
|
25770
|
+
try {
|
|
25771
|
+
const user = getCurrentUser();
|
|
25772
|
+
if (!user)
|
|
25773
|
+
return null;
|
|
25774
|
+
const networkId = getNetworkId(user);
|
|
25775
|
+
const { userId } = user;
|
|
25776
|
+
return networkId && userId ? new CursorController(networkId, userId) : null;
|
|
25777
|
+
}
|
|
25778
|
+
catch (_a) {
|
|
25779
|
+
return null;
|
|
25780
|
+
}
|
|
25781
|
+
}
|
|
25782
|
+
static isExpired(expiredAt) {
|
|
25783
|
+
return Date.now() >= expiredAt;
|
|
25784
|
+
}
|
|
25785
|
+
static clearOnLogout() {
|
|
25786
|
+
return onSessionStateChange(state => {
|
|
25787
|
+
var _a;
|
|
25788
|
+
if (state === "terminated" /* Amity.SessionStates.TERMINATED */)
|
|
25789
|
+
(_a = CursorController.current()) === null || _a === void 0 ? void 0 : _a.clear();
|
|
25790
|
+
});
|
|
25791
|
+
}
|
|
25792
|
+
get key() {
|
|
25793
|
+
return `amity:forYouFeed:cursor:${this.networkId}:${this.userId}`;
|
|
25794
|
+
}
|
|
25795
|
+
async get() {
|
|
25796
|
+
const raw = await getItem(this.key);
|
|
25797
|
+
if (!raw)
|
|
25798
|
+
return null;
|
|
25799
|
+
try {
|
|
25800
|
+
const parsed = JSON.parse(raw);
|
|
25801
|
+
if (typeof (parsed === null || parsed === void 0 ? void 0 : parsed.cursor) !== 'string' || typeof (parsed === null || parsed === void 0 ? void 0 : parsed.expiredAt) !== 'number')
|
|
25802
|
+
return null;
|
|
25803
|
+
return {
|
|
25804
|
+
cursor: parsed.cursor,
|
|
25805
|
+
expiredAt: parsed.expiredAt,
|
|
25806
|
+
reachedEndOfFeed: parsed.reachedEndOfFeed === true,
|
|
25807
|
+
};
|
|
25808
|
+
}
|
|
25809
|
+
catch (_a) {
|
|
25810
|
+
return null;
|
|
25811
|
+
}
|
|
25812
|
+
}
|
|
25813
|
+
async set(value) {
|
|
25814
|
+
await setItem(this.key, JSON.stringify(value));
|
|
25815
|
+
}
|
|
25816
|
+
async markReachedEndOfFeed(expiredAt) {
|
|
25817
|
+
var _a;
|
|
25818
|
+
const stored = await this.get();
|
|
25819
|
+
await this.set({
|
|
25820
|
+
cursor: (_a = stored === null || stored === void 0 ? void 0 : stored.cursor) !== null && _a !== void 0 ? _a : '',
|
|
25821
|
+
expiredAt,
|
|
25822
|
+
reachedEndOfFeed: true,
|
|
25823
|
+
});
|
|
25824
|
+
}
|
|
25825
|
+
async clear() {
|
|
25826
|
+
await setItem(this.key, '');
|
|
25827
|
+
}
|
|
25828
|
+
}
|
|
25829
|
+
|
|
25198
25830
|
const EVENTS = [
|
|
25199
25831
|
'disconnected',
|
|
25200
25832
|
'error',
|
|
@@ -25384,7 +26016,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
|
|
|
25384
26016
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
25385
26017
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
25386
26018
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
25387
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler());
|
|
26019
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout());
|
|
25388
26020
|
if (client.useLegacyUnreadCount) {
|
|
25389
26021
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
25390
26022
|
}
|
|
@@ -26083,16 +26715,13 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
26083
26715
|
}
|
|
26084
26716
|
if (client.useLegacyUnreadCount) {
|
|
26085
26717
|
rawPayload.messages.forEach(message => {
|
|
26086
|
-
var _a, _b;
|
|
26718
|
+
var _a, _b, _c;
|
|
26087
26719
|
const channelUnread = (_a = pullFromCache([
|
|
26088
26720
|
'channelUnread',
|
|
26089
26721
|
'get',
|
|
26090
26722
|
message.channelId,
|
|
26091
26723
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
26092
|
-
if (!channelUnread ||
|
|
26093
|
-
channelUnread.lastSegment >= message.segment ||
|
|
26094
|
-
typeof channelUnread.readToSegment !== 'number' ||
|
|
26095
|
-
typeof channelUnread.lastMentionedSegment !== 'number')
|
|
26724
|
+
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
26096
26725
|
return;
|
|
26097
26726
|
const lastSegment = message.segment;
|
|
26098
26727
|
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
@@ -26104,7 +26733,8 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
26104
26733
|
const lastMentionedSegment = isMentionedInMessage
|
|
26105
26734
|
? message.segment
|
|
26106
26735
|
: channelUnread.lastMentionedSegment;
|
|
26107
|
-
const
|
|
26736
|
+
const readToSegment = (_c = channelUnread.readToSegment) !== null && _c !== void 0 ? _c : 0;
|
|
26737
|
+
const updatedChannelUnread = Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: Math.max(lastSegment - readToSegment, 0), lastMentionedSegment, isMentioned: typeof lastMentionedSegment === 'number' && readToSegment < lastMentionedSegment });
|
|
26108
26738
|
pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
|
|
26109
26739
|
fireEvent('local.channelUnread.updated', [updatedChannelUnread]);
|
|
26110
26740
|
});
|
|
@@ -26467,14 +27097,17 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
26467
27097
|
validateUrls,
|
|
26468
27098
|
validateTexts,
|
|
26469
27099
|
getFeedSettings,
|
|
27100
|
+
getCoreUserSettings,
|
|
26470
27101
|
getSocialSettings,
|
|
27102
|
+
getChatSettings,
|
|
26471
27103
|
getVisitorDeviceId: getDeviceId,
|
|
26472
|
-
getMessagePreviewSetting,
|
|
27104
|
+
getMessagePreviewSetting: getMessagePreviewSetting$1,
|
|
26473
27105
|
use: () => setActiveClient(client),
|
|
26474
27106
|
isUnreadCountEnabled,
|
|
26475
27107
|
useLegacyUnreadCount,
|
|
26476
27108
|
getMarkerSyncConsistentMode,
|
|
26477
27109
|
getProductCatalogueSetting,
|
|
27110
|
+
getForYouFeedSetting,
|
|
26478
27111
|
/**
|
|
26479
27112
|
* Prefix for the deviceId key in the local storage or async storage.
|
|
26480
27113
|
* This is allow user to have multiple SDK client and Mqtt client within the same app.
|
|
@@ -26742,11 +27375,18 @@ const getLinkPreviewMetadata = async (url) => {
|
|
|
26742
27375
|
return data;
|
|
26743
27376
|
};
|
|
26744
27377
|
|
|
27378
|
+
const CONTENT_TYPE_CONFIG = {
|
|
27379
|
+
[AmitySharableContentType.POST]: { key: 'posts', placeholder: 'postId' },
|
|
27380
|
+
[AmitySharableContentType.COMMUNITY]: { key: 'communities', placeholder: 'communityId' },
|
|
27381
|
+
[AmitySharableContentType.USER]: { key: 'users', placeholder: 'userId' },
|
|
27382
|
+
[AmitySharableContentType.LIVESTREAM]: { key: 'livestream', placeholder: 'livestream' },
|
|
27383
|
+
[AmitySharableContentType.EVENT]: { key: 'events', placeholder: 'eventId' },
|
|
27384
|
+
};
|
|
26745
27385
|
/**
|
|
26746
27386
|
* ```js
|
|
26747
27387
|
* import Client from '@amityco/ts-sdk'
|
|
26748
|
-
* const
|
|
26749
|
-
* const
|
|
27388
|
+
* const config = await Client.getShareableLinkConfiguration()
|
|
27389
|
+
* const link = config.generateLink(AmitySharableContentType.EVENT, eventId)
|
|
26750
27390
|
* ```
|
|
26751
27391
|
*
|
|
26752
27392
|
* Fetches a {@link Amity.ShareableLinkConfiguration} object
|
|
@@ -26757,9 +27397,29 @@ const getLinkPreviewMetadata = async (url) => {
|
|
|
26757
27397
|
* @async
|
|
26758
27398
|
*/
|
|
26759
27399
|
const getShareableLinkConfiguration = async () => {
|
|
27400
|
+
var _a, _b;
|
|
26760
27401
|
const client = getActiveClient();
|
|
26761
27402
|
const { data } = await client.http.get(`/api/v3/network-settings/shareable-deep-links`);
|
|
26762
|
-
|
|
27403
|
+
const domain = (_a = data.domain) !== null && _a !== void 0 ? _a : '';
|
|
27404
|
+
const patterns = (_b = data.patterns) !== null && _b !== void 0 ? _b : {};
|
|
27405
|
+
return {
|
|
27406
|
+
domain,
|
|
27407
|
+
patterns,
|
|
27408
|
+
isEnabled(contentType) {
|
|
27409
|
+
const { key } = CONTENT_TYPE_CONFIG[contentType];
|
|
27410
|
+
return !!domain && !!patterns[key];
|
|
27411
|
+
},
|
|
27412
|
+
getPattern(contentType) {
|
|
27413
|
+
const { key } = CONTENT_TYPE_CONFIG[contentType];
|
|
27414
|
+
return patterns[key] || null;
|
|
27415
|
+
},
|
|
27416
|
+
generateLink(contentType, referenceId) {
|
|
27417
|
+
const { key, placeholder } = CONTENT_TYPE_CONFIG[contentType];
|
|
27418
|
+
if (!domain || !patterns[key])
|
|
27419
|
+
return null;
|
|
27420
|
+
return domain + patterns[key].replace(`{${placeholder}}`, referenceId);
|
|
27421
|
+
},
|
|
27422
|
+
};
|
|
26763
27423
|
};
|
|
26764
27424
|
|
|
26765
27425
|
/**
|
|
@@ -26950,6 +27610,205 @@ const setAccessTokenHandler = (accessTokenHandler) => {
|
|
|
26950
27610
|
client.accessTokenHandler = accessTokenHandler;
|
|
26951
27611
|
};
|
|
26952
27612
|
|
|
27613
|
+
function parseRolesFilter(listenFromRoleIds, ignoreFromRoleIds) {
|
|
27614
|
+
if (ignoreFromRoleIds && ignoreFromRoleIds.length > 0) {
|
|
27615
|
+
return { type: 'not', roleIds: ignoreFromRoleIds };
|
|
27616
|
+
}
|
|
27617
|
+
if (listenFromRoleIds && listenFromRoleIds.length > 0) {
|
|
27618
|
+
return { type: NotificationRolesFilterTypeEnum.ONLY, roleIds: listenFromRoleIds };
|
|
27619
|
+
}
|
|
27620
|
+
return { type: NotificationRolesFilterTypeEnum.ALL };
|
|
27621
|
+
}
|
|
27622
|
+
function serializeRolesFilter(rolesFilter) {
|
|
27623
|
+
if ((rolesFilter === null || rolesFilter === void 0 ? void 0 : rolesFilter.type) === NotificationRolesFilterTypeEnum.ONLY) {
|
|
27624
|
+
return { listenFromRoleIds: rolesFilter.roleIds };
|
|
27625
|
+
}
|
|
27626
|
+
return { listenFromRoleIds: [] };
|
|
27627
|
+
}
|
|
27628
|
+
class ChannelNotifications {
|
|
27629
|
+
constructor(channelId) {
|
|
27630
|
+
this.channelId = channelId;
|
|
27631
|
+
}
|
|
27632
|
+
async enable() {
|
|
27633
|
+
const client = getActiveClient();
|
|
27634
|
+
const body = {
|
|
27635
|
+
level: NotificationSettingsLevelEnum.CHANNEL,
|
|
27636
|
+
channelId: this.channelId,
|
|
27637
|
+
isPushNotifiable: true,
|
|
27638
|
+
};
|
|
27639
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27640
|
+
}
|
|
27641
|
+
async disable() {
|
|
27642
|
+
const client = getActiveClient();
|
|
27643
|
+
const body = {
|
|
27644
|
+
level: NotificationSettingsLevelEnum.CHANNEL,
|
|
27645
|
+
channelId: this.channelId,
|
|
27646
|
+
isPushNotifiable: false,
|
|
27647
|
+
};
|
|
27648
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27649
|
+
}
|
|
27650
|
+
async getSettings() {
|
|
27651
|
+
const client = getActiveClient();
|
|
27652
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.CHANNEL}&channelId=${encodeURIComponent(this.channelId)}`);
|
|
27653
|
+
return { isEnabled: data.isPushNotifiable };
|
|
27654
|
+
}
|
|
27655
|
+
}
|
|
27656
|
+
class UserNotifications {
|
|
27657
|
+
async enable(modules) {
|
|
27658
|
+
var _a;
|
|
27659
|
+
const client = getActiveClient();
|
|
27660
|
+
const notifiableEvents = (_a = modules === null || modules === void 0 ? void 0 : modules.map(module => (Object.assign({ moduleName: module.moduleName, isPushNotifiable: module.isEnabled }, serializeRolesFilter(module.rolesFilter))))) !== null && _a !== void 0 ? _a : [];
|
|
27661
|
+
const body = {
|
|
27662
|
+
level: NotificationSettingsLevelEnum.USER,
|
|
27663
|
+
isPushNotifiable: true,
|
|
27664
|
+
notifiableEvents,
|
|
27665
|
+
};
|
|
27666
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27667
|
+
}
|
|
27668
|
+
async disableAllNotifications() {
|
|
27669
|
+
const client = getActiveClient();
|
|
27670
|
+
const body = {
|
|
27671
|
+
level: NotificationSettingsLevelEnum.USER,
|
|
27672
|
+
isPushNotifiable: false,
|
|
27673
|
+
notifiableEvents: [],
|
|
27674
|
+
};
|
|
27675
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27676
|
+
}
|
|
27677
|
+
async getSettings() {
|
|
27678
|
+
var _a;
|
|
27679
|
+
const client = getActiveClient();
|
|
27680
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.USER}`);
|
|
27681
|
+
const validModuleNames = Object.values(UserNotificationModuleNameEnum);
|
|
27682
|
+
const modules = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
27683
|
+
.filter(e => e.moduleName != null && validModuleNames.includes(e.moduleName))
|
|
27684
|
+
.map(e => ({
|
|
27685
|
+
moduleName: e.moduleName,
|
|
27686
|
+
isEnabled: e.isPushNotifiable,
|
|
27687
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
27688
|
+
}));
|
|
27689
|
+
return { isEnabled: data.isPushNotifiable, modules };
|
|
27690
|
+
}
|
|
27691
|
+
}
|
|
27692
|
+
class CommunityNotifications {
|
|
27693
|
+
constructor(communityId) {
|
|
27694
|
+
this.communityId = communityId;
|
|
27695
|
+
}
|
|
27696
|
+
async enable(events) {
|
|
27697
|
+
var _a;
|
|
27698
|
+
const client = getActiveClient();
|
|
27699
|
+
const notifiableEvents = (_a = events === null || events === void 0 ? void 0 : events.map(event => (Object.assign({ moduleName: UserNotificationModuleNameEnum.SOCIAL, name: event.eventName, isPushNotifiable: event.isEnabled }, serializeRolesFilter(event.rolesFilter))))) !== null && _a !== void 0 ? _a : [];
|
|
27700
|
+
const body = {
|
|
27701
|
+
level: NotificationSettingsLevelEnum.COMMUNITY,
|
|
27702
|
+
communityId: this.communityId,
|
|
27703
|
+
isPushNotifiable: true,
|
|
27704
|
+
notifiableEvents,
|
|
27705
|
+
};
|
|
27706
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27707
|
+
}
|
|
27708
|
+
async disable() {
|
|
27709
|
+
const client = getActiveClient();
|
|
27710
|
+
const body = {
|
|
27711
|
+
level: NotificationSettingsLevelEnum.COMMUNITY,
|
|
27712
|
+
communityId: this.communityId,
|
|
27713
|
+
isPushNotifiable: false,
|
|
27714
|
+
notifiableEvents: [],
|
|
27715
|
+
};
|
|
27716
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27717
|
+
}
|
|
27718
|
+
async getSettings() {
|
|
27719
|
+
var _a;
|
|
27720
|
+
const client = getActiveClient();
|
|
27721
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.COMMUNITY}&communityId=${encodeURIComponent(this.communityId)}`);
|
|
27722
|
+
const validEventNames = Object.values(CommunityNotificationEventNameEnum);
|
|
27723
|
+
const events = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
27724
|
+
.filter(e => e.name != null && validEventNames.includes(e.name))
|
|
27725
|
+
.map(e => ({
|
|
27726
|
+
eventName: e.name,
|
|
27727
|
+
isEnabled: e.isPushNotifiable,
|
|
27728
|
+
isNetworkEnabled: e.isNetworkEnabled,
|
|
27729
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
27730
|
+
}));
|
|
27731
|
+
return { isEnabled: data.isPushNotifiable, events };
|
|
27732
|
+
}
|
|
27733
|
+
}
|
|
27734
|
+
class Notifications {
|
|
27735
|
+
user() {
|
|
27736
|
+
return new UserNotifications();
|
|
27737
|
+
}
|
|
27738
|
+
community(communityId) {
|
|
27739
|
+
return new CommunityNotifications(communityId);
|
|
27740
|
+
}
|
|
27741
|
+
channel(channelId) {
|
|
27742
|
+
return new ChannelNotifications(channelId);
|
|
27743
|
+
}
|
|
27744
|
+
}
|
|
27745
|
+
const notifications = () => new Notifications();
|
|
27746
|
+
|
|
27747
|
+
/* begin_public_function
|
|
27748
|
+
id: client.enable_auto_subscriptions
|
|
27749
|
+
*/
|
|
27750
|
+
/**
|
|
27751
|
+
* ```js
|
|
27752
|
+
* import { Client, AmityAutoSubscription } from '@amityco/ts-sdk'
|
|
27753
|
+
* Client.enableAutoSubscriptions([AmityAutoSubscription.BLOCK])
|
|
27754
|
+
* ```
|
|
27755
|
+
*
|
|
27756
|
+
* Enables one or more managed auto-subscription handles. Managed handles are
|
|
27757
|
+
* re-applied on every (re)connect and ref-counted. All handles are on by
|
|
27758
|
+
* default; use this to re-enable handles previously turned off via
|
|
27759
|
+
* {@link disableAutoSubscriptions}. Synchronous fire-and-forget — the registry
|
|
27760
|
+
* updates immediately and the broker subscribe is retried on reconnect.
|
|
27761
|
+
*
|
|
27762
|
+
* @param features the {@link AmityAutoSubscription} handles to enable
|
|
27763
|
+
*
|
|
27764
|
+
* @category Client API
|
|
27765
|
+
*/
|
|
27766
|
+
const enableAutoSubscriptions = (features) => {
|
|
27767
|
+
const manager = getAutoSubscriptionManager();
|
|
27768
|
+
features.forEach(feature => manager.subscribe(feature));
|
|
27769
|
+
};
|
|
27770
|
+
/* end_public_function */
|
|
27771
|
+
/* begin_public_function
|
|
27772
|
+
id: client.disable_auto_subscriptions
|
|
27773
|
+
*/
|
|
27774
|
+
/**
|
|
27775
|
+
* ```js
|
|
27776
|
+
* import { Client, AmityAutoSubscription } from '@amityco/ts-sdk'
|
|
27777
|
+
* Client.disableAutoSubscriptions([AmityAutoSubscription.LIVESTREAM])
|
|
27778
|
+
* ```
|
|
27779
|
+
*
|
|
27780
|
+
* Disables one or more managed auto-subscription handles. The change persists
|
|
27781
|
+
* across reconnect (it is not silently re-enabled) until
|
|
27782
|
+
* {@link enableAutoSubscriptions} is called again. Synchronous fire-and-forget.
|
|
27783
|
+
*
|
|
27784
|
+
* @param features the {@link AmityAutoSubscription} handles to disable
|
|
27785
|
+
*
|
|
27786
|
+
* @category Client API
|
|
27787
|
+
*/
|
|
27788
|
+
const disableAutoSubscriptions = (features) => {
|
|
27789
|
+
const manager = getAutoSubscriptionManager();
|
|
27790
|
+
features.forEach(feature => manager.unsubscribe(feature));
|
|
27791
|
+
};
|
|
27792
|
+
/* end_public_function */
|
|
27793
|
+
/* begin_public_function
|
|
27794
|
+
id: client.auto_subscriptions
|
|
27795
|
+
*/
|
|
27796
|
+
/**
|
|
27797
|
+
* ```js
|
|
27798
|
+
* import { Client } from '@amityco/ts-sdk'
|
|
27799
|
+
* Client.autoSubscriptions().forEach(s => console.log(s.feature, s.isActive, s.topicCount))
|
|
27800
|
+
* ```
|
|
27801
|
+
*
|
|
27802
|
+
* Inspects the managed auto-subscription registry — each handle's `isActive`,
|
|
27803
|
+
* `isSystem`, and `topicCount`.
|
|
27804
|
+
*
|
|
27805
|
+
* @returns a snapshot of the managed subscription registry
|
|
27806
|
+
*
|
|
27807
|
+
* @category Client API
|
|
27808
|
+
*/
|
|
27809
|
+
const autoSubscriptions = () => getAutoSubscriptionManager().subscriptions();
|
|
27810
|
+
/* end_public_function */
|
|
27811
|
+
|
|
26953
27812
|
/**
|
|
26954
27813
|
* ```js
|
|
26955
27814
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk'
|
|
@@ -27324,12 +28183,19 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
27324
28183
|
getSocialSettings: getSocialSettings,
|
|
27325
28184
|
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
27326
28185
|
getProductCatalogueSetting: getProductCatalogueSetting,
|
|
28186
|
+
getForYouFeedSetting: getForYouFeedSetting,
|
|
27327
28187
|
loginAsVisitor: loginAsVisitor,
|
|
27328
28188
|
loginAsBot: loginAsBot,
|
|
27329
28189
|
getCurrentUser: getCurrentUser,
|
|
27330
28190
|
getCurrentUserType: getCurrentUserType,
|
|
27331
28191
|
setCurrentUserType: setCurrentUserType,
|
|
27332
28192
|
setAccessTokenHandler: setAccessTokenHandler,
|
|
28193
|
+
getChatSettings: getChatSettings,
|
|
28194
|
+
getCoreUserSettings: getCoreUserSettings,
|
|
28195
|
+
notifications: notifications,
|
|
28196
|
+
enableAutoSubscriptions: enableAutoSubscriptions,
|
|
28197
|
+
disableAutoSubscriptions: disableAutoSubscriptions,
|
|
28198
|
+
autoSubscriptions: autoSubscriptions,
|
|
27333
28199
|
onConnectionError: onConnectionError,
|
|
27334
28200
|
onClientDisconnected: onClientDisconnected,
|
|
27335
28201
|
onClientBanned: onClientBanned,
|
|
@@ -27347,19 +28213,6 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
27347
28213
|
getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
|
|
27348
28214
|
});
|
|
27349
28215
|
|
|
27350
|
-
function prepareFollowersPayload(response) {
|
|
27351
|
-
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
27352
|
-
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
27353
|
-
}
|
|
27354
|
-
function prepareFollowingsPayload(response) {
|
|
27355
|
-
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
27356
|
-
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
27357
|
-
}
|
|
27358
|
-
function prepareFollowStatusPayload(response) {
|
|
27359
|
-
const { follows } = response, rest = __rest(response, ["follows"]);
|
|
27360
|
-
return Object.assign(Object.assign({}, rest), { follows });
|
|
27361
|
-
}
|
|
27362
|
-
|
|
27363
28216
|
/* begin_public_function
|
|
27364
28217
|
id: user.relationship.block
|
|
27365
28218
|
*/
|
|
@@ -28537,6 +29390,8 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
28537
29390
|
__proto__: null,
|
|
28538
29391
|
blockUser: blockUser,
|
|
28539
29392
|
unBlockUser: unBlockUser,
|
|
29393
|
+
onUserDidBlock: onUserDidBlock,
|
|
29394
|
+
onUserDidUnblock: onUserDidUnblock,
|
|
28540
29395
|
follow: follow,
|
|
28541
29396
|
unfollow: unfollow,
|
|
28542
29397
|
acceptMyFollower: acceptMyFollower,
|
|
@@ -29366,7 +30221,7 @@ const getWatchSessionStorage = () => {
|
|
|
29366
30221
|
return storageInstance;
|
|
29367
30222
|
};
|
|
29368
30223
|
|
|
29369
|
-
const privateKey = "
|
|
30224
|
+
const privateKey = "MIIEpQIBAAKCAQEAwAEc/oZgYIvKSUG/C3mONYLR4ZPgAjMEX4bJ+xqqakUDRtqlNO+eZs2blQ1Ko0DBkqPExyQezvjibH5W2UZBV5RaBTlTcNVKTToMBEGesAfaEcM3qUyQHxdbFYZv6P4sb14dcwxTQ8usmaV8ooiR1Fcaso5ZWYcZ8Hb46FbQ7OoVumsBtPWwfZ4f003o5VCl6AIM6lcLv9UDLlFVYhE+PeXpRHtfWlGqxMvqC9oinlwhL6nWv6VjQXW4nhcib72dPBzfHT7k/PMKto2SxALYdb68ENiAGuJLWi3AUHSyYCJK2w7wIlWfJUAI0v26ub10IpExr6D5QuW2577jjP93iwIDAQABAoIBAFWfqXhwIIatkFY+9Z1+ZcbDQimgsmMIsUiQaX6Lk7e0cxOj6czDlxYtVtaPiNtow2pLkjNkjkCqiP7tEHnwdK9DvylZOTa2R15NJpK3WLcTqVIGhsn/FL5owfvFah6zSsmXZParZm5zY9NZE03ALZhOB9/cz0e3kf/EbpfeL2mW7MApyiUt5i09ycchroOpcWp73ipIxvgigtZyUGFmsQicWhUs28F0D7w4Qfk76yG3nqXeb+BAMhCaIaa/k/aAxhiZG/ygEQWQrcC8gfe+jyicMAQPDEVS9YuUMGsLjIjKuVLZzp2xirQnhc2i2zVNEIvG6soprPOBEMQugzrtX5ECgYEA3b7KAbBIbDl1e4ZSCWhHdHkiWVZHaopsR/LhqDDNhXjWjq3AesgV6k0j9EdziMn/HmmOso0bz99GTV3JZf4A9ztTLumJlkHbdVtlgOqSjrFLj12rH9KXTheyIhWSpUmm8+WB1xasFbqpvJaGo7F3pd2Fqj1XR4mp5BO7c/t7LJ0CgYEA3aouEzXQ9THRKYocdfY69EI1Il1t/d/RSqqd9BxEjxBgxkM13ZiYIn/R4WW/nCUrlmhxG44Aa2Gob4Ahfsui2xKTg/g/3Zk/rAxAEGkfOLGoenaJMD41fH4wUq3FRYwkvnaMb9Hd6f/TlBHslIRa2NN58bSBGJCyBP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
|
|
29370
30225
|
/*
|
|
29371
30226
|
* The crypto algorithm used for importing key and signing string
|
|
29372
30227
|
*/
|
|
@@ -30688,6 +31543,10 @@ const postLinkedObject = (post) => {
|
|
|
30688
31543
|
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
30689
31544
|
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
30690
31545
|
},
|
|
31546
|
+
markAsMeaningfullyViewed: (feedRenderPosition) => {
|
|
31547
|
+
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
31548
|
+
analyticsEngineInstance.markPostAsMeaningfullyViewed(post.postId, feedRenderPosition);
|
|
31549
|
+
},
|
|
30691
31550
|
},
|
|
30692
31551
|
get productTags() {
|
|
30693
31552
|
var _a, _b;
|
|
@@ -30877,6 +31736,11 @@ const addReaction$1 = async (referenceType, referenceId, reactionName, reference
|
|
|
30877
31736
|
});
|
|
30878
31737
|
return true;
|
|
30879
31738
|
}
|
|
31739
|
+
if (referenceType === 'message') {
|
|
31740
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
31741
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
31742
|
+
return true;
|
|
31743
|
+
}
|
|
30880
31744
|
}
|
|
30881
31745
|
return true;
|
|
30882
31746
|
};
|
|
@@ -30955,7 +31819,7 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
30955
31819
|
return true;
|
|
30956
31820
|
}
|
|
30957
31821
|
if (referenceType === 'story') {
|
|
30958
|
-
fireEvent('local.story.
|
|
31822
|
+
fireEvent('local.story.reactionRemoved', {
|
|
30959
31823
|
story: updatedModel,
|
|
30960
31824
|
reactor: {
|
|
30961
31825
|
userId: client.userId,
|
|
@@ -30965,6 +31829,11 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
30965
31829
|
});
|
|
30966
31830
|
return true;
|
|
30967
31831
|
}
|
|
31832
|
+
if (referenceType === 'message') {
|
|
31833
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
31834
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
31835
|
+
return true;
|
|
31836
|
+
}
|
|
30968
31837
|
}
|
|
30969
31838
|
return true;
|
|
30970
31839
|
};
|
|
@@ -31237,7 +32106,7 @@ const createEventResponseSubscriber = (event, callback) => {
|
|
|
31237
32106
|
const eventResponse = pullFromCache([
|
|
31238
32107
|
'eventResponse',
|
|
31239
32108
|
'get',
|
|
31240
|
-
|
|
32109
|
+
unpackedPayload.eventResponses[0].userId,
|
|
31241
32110
|
]);
|
|
31242
32111
|
callback(eventResponse.data);
|
|
31243
32112
|
}
|
|
@@ -31901,7 +32770,38 @@ const getAllBlockedUsers = async () => {
|
|
|
31901
32770
|
const engine = BlockedUserSyncEngine$1.getInstance();
|
|
31902
32771
|
// Ensure data is fetched (no-op if cache is fresh)
|
|
31903
32772
|
await engine.ensureFetched();
|
|
31904
|
-
|
|
32773
|
+
return engine.getCachedUsers();
|
|
32774
|
+
};
|
|
32775
|
+
/* end_public_function */
|
|
32776
|
+
|
|
32777
|
+
/* begin_public_function
|
|
32778
|
+
id: user.get_all_blocking_users
|
|
32779
|
+
*/
|
|
32780
|
+
/**
|
|
32781
|
+
* ```js
|
|
32782
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
32783
|
+
* const blockingUsers = await UserRepository.getAllBlockingUsers()
|
|
32784
|
+
* ```
|
|
32785
|
+
*
|
|
32786
|
+
* Returns all users who have blocked the current user
|
|
32787
|
+
* non-paginated list (limit 100) with TTL-based caching (5-minute window). Within the
|
|
32788
|
+
* TTL window, subsequent calls resolve instantly from the local store without any
|
|
32789
|
+
* server call. After the TTL expires, the next call triggers a fresh server fetch.
|
|
32790
|
+
*
|
|
32791
|
+
* The directional inverse of {@link getAllBlockedUsers}.
|
|
32792
|
+
*
|
|
32793
|
+
* @returns A promise that resolves to an array of blocking {@link Amity.User} objects
|
|
32794
|
+
*
|
|
32795
|
+
* @category Block API
|
|
32796
|
+
* @async
|
|
32797
|
+
*/
|
|
32798
|
+
const getAllBlockingUsers = async () => {
|
|
32799
|
+
const client = getActiveClient();
|
|
32800
|
+
client.log('user/getAllBlockingUsers');
|
|
32801
|
+
const engine = BlockingUserSyncEngine$1.getInstance();
|
|
32802
|
+
// Ensure data is fetched (no-op if cache is fresh)
|
|
32803
|
+
await engine.ensureFetched();
|
|
32804
|
+
// Read from the engine's bounded ID list — O(blocking users) not O(cache size)
|
|
31905
32805
|
return engine.getCachedUsers();
|
|
31906
32806
|
};
|
|
31907
32807
|
/* end_public_function */
|
|
@@ -32284,6 +33184,12 @@ class BlockedUserPaginationController extends PaginationController {
|
|
|
32284
33184
|
}
|
|
32285
33185
|
}
|
|
32286
33186
|
|
|
33187
|
+
var EnumBlockActions;
|
|
33188
|
+
(function (EnumBlockActions) {
|
|
33189
|
+
EnumBlockActions["OnBlocked"] = "onBlocked";
|
|
33190
|
+
EnumBlockActions["OnUnblocked"] = "onUnblocked";
|
|
33191
|
+
})(EnumBlockActions || (EnumBlockActions = {}));
|
|
33192
|
+
|
|
32287
33193
|
class BlockedUserQueryStreamController extends QueryStreamController {
|
|
32288
33194
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
32289
33195
|
super(query, cacheKey);
|
|
@@ -32313,11 +33219,16 @@ class BlockedUserQueryStreamController extends QueryStreamController {
|
|
|
32313
33219
|
}
|
|
32314
33220
|
reactor(action) {
|
|
32315
33221
|
return (targetUser) => {
|
|
32316
|
-
var _a;
|
|
32317
|
-
|
|
33222
|
+
var _a, _b;
|
|
33223
|
+
const isRemoval = action === EnumFollowActions.OnFollowed || action === EnumBlockActions.OnUnblocked;
|
|
33224
|
+
const isAddition = action === EnumBlockActions.OnBlocked;
|
|
33225
|
+
if (isRemoval || isAddition) {
|
|
32318
33226
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32319
|
-
const
|
|
32320
|
-
|
|
33227
|
+
const ids = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
33228
|
+
const data = isAddition
|
|
33229
|
+
? [...new Set([...ids, targetUser.userId])]
|
|
33230
|
+
: ids.filter(id => id !== targetUser.userId);
|
|
33231
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data }));
|
|
32321
33232
|
}
|
|
32322
33233
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
32323
33234
|
};
|
|
@@ -32372,7 +33283,6 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
|
32372
33283
|
fn: onUserDeleted$2,
|
|
32373
33284
|
action: EnumUserActions.OnUserDeleted,
|
|
32374
33285
|
},
|
|
32375
|
-
// In the case of unblocking a user, we need to subscribe to the follow events
|
|
32376
33286
|
{
|
|
32377
33287
|
fn: convertEventPayload(onLocalUserFollowed, 'to', 'user'),
|
|
32378
33288
|
action: EnumFollowActions.OnFollowed,
|
|
@@ -32381,6 +33291,28 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
|
32381
33291
|
fn: convertEventPayload(onUserFollowed, 'to', 'user'),
|
|
32382
33292
|
action: EnumFollowActions.OnFollowed,
|
|
32383
33293
|
},
|
|
33294
|
+
{
|
|
33295
|
+
fn: (reactor) => onUserDidBlock(status => {
|
|
33296
|
+
var _a;
|
|
33297
|
+
if (status.from !== getActiveClient().userId)
|
|
33298
|
+
return;
|
|
33299
|
+
const blocked = (_a = pullFromCache(['user', 'get', status.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33300
|
+
if (blocked)
|
|
33301
|
+
reactor(blocked);
|
|
33302
|
+
}),
|
|
33303
|
+
action: EnumBlockActions.OnBlocked,
|
|
33304
|
+
},
|
|
33305
|
+
{
|
|
33306
|
+
fn: (reactor) => onUserDidUnblock(status => {
|
|
33307
|
+
var _a;
|
|
33308
|
+
if (status.from !== getActiveClient().userId)
|
|
33309
|
+
return;
|
|
33310
|
+
const blocked = (_a = pullFromCache(['user', 'get', status.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33311
|
+
if (blocked)
|
|
33312
|
+
reactor(blocked);
|
|
33313
|
+
}),
|
|
33314
|
+
action: EnumBlockActions.OnUnblocked,
|
|
33315
|
+
},
|
|
32384
33316
|
]);
|
|
32385
33317
|
}
|
|
32386
33318
|
notifyChange({ origin, loading, error }) {
|
|
@@ -32448,6 +33380,184 @@ const getBlockedUsers = (params, callback, config) => {
|
|
|
32448
33380
|
};
|
|
32449
33381
|
/* end_public_function */
|
|
32450
33382
|
|
|
33383
|
+
class BlockingUserQueryStreamController extends QueryStreamController {
|
|
33384
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
33385
|
+
super(query, cacheKey);
|
|
33386
|
+
this.notifyChange = notifyChange;
|
|
33387
|
+
this.preparePayload = preparePayload;
|
|
33388
|
+
}
|
|
33389
|
+
async saveToMainDB(response) {
|
|
33390
|
+
const processedPayload = await this.preparePayload(response);
|
|
33391
|
+
const client = getActiveClient();
|
|
33392
|
+
const cachedAt = client.cache && Date.now();
|
|
33393
|
+
if (client.cache) {
|
|
33394
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
33395
|
+
}
|
|
33396
|
+
}
|
|
33397
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
33398
|
+
var _a, _b;
|
|
33399
|
+
if (refresh) {
|
|
33400
|
+
pushToCache(this.cacheKey, {
|
|
33401
|
+
data: response.users.map(getResolver('user')),
|
|
33402
|
+
});
|
|
33403
|
+
}
|
|
33404
|
+
else {
|
|
33405
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33406
|
+
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
33407
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
|
|
33408
|
+
}
|
|
33409
|
+
}
|
|
33410
|
+
reactor(action) {
|
|
33411
|
+
return (user) => {
|
|
33412
|
+
var _a, _b;
|
|
33413
|
+
if (user &&
|
|
33414
|
+
(action === EnumBlockActions.OnBlocked || action === EnumBlockActions.OnUnblocked)) {
|
|
33415
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33416
|
+
const ids = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
33417
|
+
const data = action === EnumBlockActions.OnBlocked
|
|
33418
|
+
? [...new Set([...ids, user.userId])]
|
|
33419
|
+
: ids.filter(id => id !== user.userId);
|
|
33420
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data }));
|
|
33421
|
+
}
|
|
33422
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
33423
|
+
};
|
|
33424
|
+
}
|
|
33425
|
+
subscribeRTE(createSubscriber) {
|
|
33426
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
33427
|
+
}
|
|
33428
|
+
}
|
|
33429
|
+
|
|
33430
|
+
class BlockingUserPaginationController extends PaginationController {
|
|
33431
|
+
async getRequest(queryParams, token) {
|
|
33432
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_SIZE } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
33433
|
+
const options = token ? { token } : { limit };
|
|
33434
|
+
const { data: queryResponse } = await this.http.get('/api/v4/me/blockers', {
|
|
33435
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
33436
|
+
});
|
|
33437
|
+
return queryResponse;
|
|
33438
|
+
}
|
|
33439
|
+
}
|
|
33440
|
+
|
|
33441
|
+
class BlockingUserLiveCollectionController extends LiveCollectionController {
|
|
33442
|
+
constructor(callback) {
|
|
33443
|
+
const queryStreamId = `blocking-users-${getActiveClient().userId}`;
|
|
33444
|
+
const query = {};
|
|
33445
|
+
const cacheKey = ['blockingUsers', 'collection', queryStreamId];
|
|
33446
|
+
const paginationController = new BlockingUserPaginationController(query);
|
|
33447
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
33448
|
+
this.queryStreamController = new BlockingUserQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this), prepareBlockingUserPayload);
|
|
33449
|
+
this.callback = callback.bind(this);
|
|
33450
|
+
this.loadPage({ initial: true });
|
|
33451
|
+
}
|
|
33452
|
+
setup() {
|
|
33453
|
+
var _a;
|
|
33454
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33455
|
+
if (!collection) {
|
|
33456
|
+
pushToCache(this.cacheKey, {
|
|
33457
|
+
data: [],
|
|
33458
|
+
params: {},
|
|
33459
|
+
});
|
|
33460
|
+
}
|
|
33461
|
+
}
|
|
33462
|
+
async persistModel(queryPayload) {
|
|
33463
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
33464
|
+
}
|
|
33465
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
33466
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
33467
|
+
}
|
|
33468
|
+
startSubscription() {
|
|
33469
|
+
return this.queryStreamController.subscribeRTE([
|
|
33470
|
+
{
|
|
33471
|
+
fn: onUserDeleted$2,
|
|
33472
|
+
action: EnumUserActions.OnUserDeleted,
|
|
33473
|
+
},
|
|
33474
|
+
{
|
|
33475
|
+
fn: (reactor) => onUserDidBlock(status => {
|
|
33476
|
+
var _a;
|
|
33477
|
+
if (status.to !== getActiveClient().userId)
|
|
33478
|
+
return;
|
|
33479
|
+
const blocker = (_a = pullFromCache(['user', 'get', status.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33480
|
+
if (blocker)
|
|
33481
|
+
reactor(blocker);
|
|
33482
|
+
}),
|
|
33483
|
+
action: EnumBlockActions.OnBlocked,
|
|
33484
|
+
},
|
|
33485
|
+
{
|
|
33486
|
+
fn: (reactor) => onUserDidUnblock(status => {
|
|
33487
|
+
var _a;
|
|
33488
|
+
if (status.to !== getActiveClient().userId)
|
|
33489
|
+
return;
|
|
33490
|
+
const blocker = (_a = pullFromCache(['user', 'get', status.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33491
|
+
if (blocker)
|
|
33492
|
+
reactor(blocker);
|
|
33493
|
+
}),
|
|
33494
|
+
action: EnumBlockActions.OnUnblocked,
|
|
33495
|
+
},
|
|
33496
|
+
]);
|
|
33497
|
+
}
|
|
33498
|
+
notifyChange({ origin, loading, error }) {
|
|
33499
|
+
var _a, _b;
|
|
33500
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33501
|
+
if (!collection)
|
|
33502
|
+
return;
|
|
33503
|
+
const data = this.applyFilter((_b = collection.data
|
|
33504
|
+
.map(id => pullFromCache(['user', 'get', id]))
|
|
33505
|
+
.filter(isNonNullable)
|
|
33506
|
+
.map(({ data }) => data)
|
|
33507
|
+
.map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
|
|
33508
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
33509
|
+
return;
|
|
33510
|
+
this.callback({
|
|
33511
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
33512
|
+
data,
|
|
33513
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
33514
|
+
loading,
|
|
33515
|
+
error,
|
|
33516
|
+
});
|
|
33517
|
+
}
|
|
33518
|
+
applyFilter(data) {
|
|
33519
|
+
let users = data;
|
|
33520
|
+
users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
|
|
33521
|
+
return users;
|
|
33522
|
+
}
|
|
33523
|
+
}
|
|
33524
|
+
|
|
33525
|
+
/* begin_public_function
|
|
33526
|
+
id: user.get_blocking_users
|
|
33527
|
+
*/
|
|
33528
|
+
/**
|
|
33529
|
+
* ```js
|
|
33530
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
33531
|
+
* const unsubscribe = UserRepository.getBlockingUsers(({ data: users }) => {
|
|
33532
|
+
* console.log(users)
|
|
33533
|
+
* })
|
|
33534
|
+
* ```
|
|
33535
|
+
*
|
|
33536
|
+
* Observe the {@link Amity.User}s who have blocked the current user
|
|
33537
|
+
*
|
|
33538
|
+
* @param callback to receive updates on the blocking {@link Amity.User}s
|
|
33539
|
+
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
33540
|
+
*
|
|
33541
|
+
* @category User API
|
|
33542
|
+
*/
|
|
33543
|
+
const getBlockingUsers = (callback) => {
|
|
33544
|
+
const { log, cache } = getActiveClient();
|
|
33545
|
+
if (!cache)
|
|
33546
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
33547
|
+
const timestamp = Date.now();
|
|
33548
|
+
log(`getBlockingUsers(tmpid: ${timestamp}) > listen`);
|
|
33549
|
+
const blockingUserLiveCollection = new BlockingUserLiveCollectionController(callback);
|
|
33550
|
+
const disposers = blockingUserLiveCollection.startSubscription();
|
|
33551
|
+
const cacheKey = blockingUserLiveCollection.getCacheKey();
|
|
33552
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
33553
|
+
return () => {
|
|
33554
|
+
log(`getBlockingUsers(tmpid: ${timestamp}) > dispose`);
|
|
33555
|
+
disposers.forEach(fn => fn());
|
|
33556
|
+
dropFromCache(cacheKey);
|
|
33557
|
+
};
|
|
33558
|
+
};
|
|
33559
|
+
/* end_public_function */
|
|
33560
|
+
|
|
32451
33561
|
class SearchUserPaginationController extends PaginationController {
|
|
32452
33562
|
async getRequest(queryParams, token) {
|
|
32453
33563
|
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, displayName } = queryParams, params = __rest(queryParams, ["limit", "displayName"]);
|
|
@@ -32714,6 +33824,7 @@ var index$q = /*#__PURE__*/Object.freeze({
|
|
|
32714
33824
|
unflagUser: unflagUser,
|
|
32715
33825
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
32716
33826
|
getAllBlockedUsers: getAllBlockedUsers,
|
|
33827
|
+
getAllBlockingUsers: getAllBlockingUsers,
|
|
32717
33828
|
onUserUpdated: onUserUpdated,
|
|
32718
33829
|
onUserDeleted: onUserDeleted$2,
|
|
32719
33830
|
onUserFlagged: onUserFlagged,
|
|
@@ -32722,6 +33833,7 @@ var index$q = /*#__PURE__*/Object.freeze({
|
|
|
32722
33833
|
getUser: getUser,
|
|
32723
33834
|
getUsers: getUsers,
|
|
32724
33835
|
getBlockedUsers: getBlockedUsers,
|
|
33836
|
+
getBlockingUsers: getBlockingUsers,
|
|
32725
33837
|
searchUserByDisplayName: searchUserByDisplayName,
|
|
32726
33838
|
getReachedUsers: getReachedUsers,
|
|
32727
33839
|
get AmityUserSearchMatchType () { return AmityUserSearchMatchType; }
|
|
@@ -33888,7 +35000,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
33888
35000
|
return true;
|
|
33889
35001
|
}
|
|
33890
35002
|
if (referenceType === 'story') {
|
|
33891
|
-
fireEvent('local.story.
|
|
35003
|
+
fireEvent('local.story.reactionRemoved', {
|
|
33892
35004
|
story: updatedModel,
|
|
33893
35005
|
reactor: {
|
|
33894
35006
|
userId: client.userId,
|
|
@@ -35472,6 +36584,104 @@ const unmuteChannel = async (channelId) => {
|
|
|
35472
36584
|
};
|
|
35473
36585
|
/* end_public_function */
|
|
35474
36586
|
|
|
36587
|
+
/* begin_public_function
|
|
36588
|
+
id: channel.archive
|
|
36589
|
+
*/
|
|
36590
|
+
/**
|
|
36591
|
+
* ```js
|
|
36592
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
36593
|
+
* const success = await ChannelRepository.archiveChannel('foobar')
|
|
36594
|
+
* ```
|
|
36595
|
+
*
|
|
36596
|
+
* Archive a {@link Amity.Channel}.
|
|
36597
|
+
*
|
|
36598
|
+
* @param channelId The id of the {@link Amity.Channel} to archive
|
|
36599
|
+
* @returns A success boolean
|
|
36600
|
+
*
|
|
36601
|
+
* @category Channel API
|
|
36602
|
+
* @async
|
|
36603
|
+
*/
|
|
36604
|
+
const archiveChannel = async (channelId) => {
|
|
36605
|
+
const client = getActiveClient();
|
|
36606
|
+
client.log('channel/archiveChannel', channelId);
|
|
36607
|
+
await client.http.post(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
36608
|
+
const archive = {
|
|
36609
|
+
channelId,
|
|
36610
|
+
archivedAt: new Date().toISOString(),
|
|
36611
|
+
};
|
|
36612
|
+
if (client.cache) {
|
|
36613
|
+
pushToCache(['archivedChannel', 'get', getResolver('archivedChannel')(archive)], archive);
|
|
36614
|
+
}
|
|
36615
|
+
fireEvent('local.channel.archived', { archives: [archive] });
|
|
36616
|
+
};
|
|
36617
|
+
/* end_public_function */
|
|
36618
|
+
|
|
36619
|
+
/* begin_public_function
|
|
36620
|
+
id: channel.unarchive
|
|
36621
|
+
*/
|
|
36622
|
+
/**
|
|
36623
|
+
* ```js
|
|
36624
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
36625
|
+
* const success = await ChannelRepository.unarchiveChannel('foobar')
|
|
36626
|
+
* ```
|
|
36627
|
+
*
|
|
36628
|
+
* Unarchive a previously archived {@link Amity.Channel}.
|
|
36629
|
+
*
|
|
36630
|
+
* @param channelId The id of the {@link Amity.Channel} to unarchive
|
|
36631
|
+
* @returns A success boolean
|
|
36632
|
+
*
|
|
36633
|
+
* @category Channel API
|
|
36634
|
+
* @async
|
|
36635
|
+
*/
|
|
36636
|
+
const unarchiveChannel = async (channelId) => {
|
|
36637
|
+
var _a;
|
|
36638
|
+
const client = getActiveClient();
|
|
36639
|
+
client.log('channel/unarchiveChannel', channelId);
|
|
36640
|
+
await client.http.delete(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
36641
|
+
const cached = (_a = pullFromCache(['archivedChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
36642
|
+
const archive = cached !== null && cached !== void 0 ? cached : {
|
|
36643
|
+
channelId,
|
|
36644
|
+
archivedAt: new Date().toISOString(),
|
|
36645
|
+
};
|
|
36646
|
+
if (client.cache) {
|
|
36647
|
+
dropFromCache(['archivedChannel', 'get', channelId], true);
|
|
36648
|
+
}
|
|
36649
|
+
fireEvent('local.channel.unarchived', { archives: [archive] });
|
|
36650
|
+
};
|
|
36651
|
+
/* end_public_function */
|
|
36652
|
+
|
|
36653
|
+
/* begin_public_function
|
|
36654
|
+
id: channel.archive.ids
|
|
36655
|
+
*/
|
|
36656
|
+
/**
|
|
36657
|
+
* ```js
|
|
36658
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
36659
|
+
* const ids = await ChannelRepository.getArchivedChannelIds()
|
|
36660
|
+
* ```
|
|
36661
|
+
*
|
|
36662
|
+
* @returns A list of archived channel ids sorted by `archivedAt` descending.
|
|
36663
|
+
*
|
|
36664
|
+
* @category Channel API
|
|
36665
|
+
* @async
|
|
36666
|
+
*/
|
|
36667
|
+
const getArchivedChannelIds = async () => {
|
|
36668
|
+
var _a;
|
|
36669
|
+
const client = getActiveClient();
|
|
36670
|
+
client.log('channel/getArchivedChannelIds');
|
|
36671
|
+
const { data: payload } = await client.http.get(`/api/v1/archives/channels`);
|
|
36672
|
+
const archives = (_a = payload.archives) !== null && _a !== void 0 ? _a : [];
|
|
36673
|
+
if (client.cache) {
|
|
36674
|
+
dropFromCache(['archivedChannel', 'get']);
|
|
36675
|
+
archives.forEach(archive => {
|
|
36676
|
+
if (!archive.channelId)
|
|
36677
|
+
return;
|
|
36678
|
+
pushToCache(['archivedChannel', 'get', archive.channelId], archive);
|
|
36679
|
+
});
|
|
36680
|
+
}
|
|
36681
|
+
return archives.map(entry => entry.channelId).filter(channelId => !!channelId);
|
|
36682
|
+
};
|
|
36683
|
+
/* end_public_function */
|
|
36684
|
+
|
|
35475
36685
|
/**
|
|
35476
36686
|
* ```js
|
|
35477
36687
|
* import { onMessageUpdated } from '@amityco/ts-sdk'
|
|
@@ -36850,6 +38060,160 @@ const getMessages = (params, callback, config) => {
|
|
|
36850
38060
|
};
|
|
36851
38061
|
/* end_public_function */
|
|
36852
38062
|
|
|
38063
|
+
class SearchMessagePaginationController extends PaginationController {
|
|
38064
|
+
async getRequest(queryParams, token) {
|
|
38065
|
+
const { query, exactMatch, channelId, messageFeedId, userIds, tags, types, sortBy, orderBy, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, } = queryParams;
|
|
38066
|
+
const options = token ? { token } : { limit, sortBy, orderBy };
|
|
38067
|
+
const { data: queryResponse } = await this.http.get(`/api/v2/search/messages`, {
|
|
38068
|
+
params: {
|
|
38069
|
+
query,
|
|
38070
|
+
exactMatch,
|
|
38071
|
+
channelId,
|
|
38072
|
+
messageFeedId,
|
|
38073
|
+
userIds,
|
|
38074
|
+
tags,
|
|
38075
|
+
types,
|
|
38076
|
+
options,
|
|
38077
|
+
},
|
|
38078
|
+
});
|
|
38079
|
+
return queryResponse;
|
|
38080
|
+
}
|
|
38081
|
+
}
|
|
38082
|
+
|
|
38083
|
+
class SearchMessageQueryStreamController extends QueryStreamController {
|
|
38084
|
+
constructor(query, cacheKey, notifyChange) {
|
|
38085
|
+
super(query, cacheKey);
|
|
38086
|
+
this.notifyChange = notifyChange;
|
|
38087
|
+
}
|
|
38088
|
+
async saveToMainDB(response) {
|
|
38089
|
+
var _a;
|
|
38090
|
+
const processedPayload = await prepareMessagePayload(response);
|
|
38091
|
+
const client = getActiveClient();
|
|
38092
|
+
const cachedAt = client.cache && Date.now();
|
|
38093
|
+
if (client.cache) {
|
|
38094
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
38095
|
+
if ((_a = response.channels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
38096
|
+
response.channels.forEach(channel => {
|
|
38097
|
+
pushToCache(['channel', 'get', channel.channelId], channel, { cachedAt });
|
|
38098
|
+
});
|
|
38099
|
+
}
|
|
38100
|
+
}
|
|
38101
|
+
}
|
|
38102
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
38103
|
+
var _a, _b;
|
|
38104
|
+
if (refresh) {
|
|
38105
|
+
pushToCache(this.cacheKey, {
|
|
38106
|
+
data: response.messages.map(getResolver('message')),
|
|
38107
|
+
});
|
|
38108
|
+
return;
|
|
38109
|
+
}
|
|
38110
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38111
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
38112
|
+
const incoming = response.messages.map(getResolver('message'));
|
|
38113
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
38114
|
+
? [...new Set([...incoming, ...existing])]
|
|
38115
|
+
: [...new Set([...existing, ...incoming])] }));
|
|
38116
|
+
}
|
|
38117
|
+
}
|
|
38118
|
+
|
|
38119
|
+
class SearchMessageLiveCollectionController extends LiveCollectionController {
|
|
38120
|
+
constructor(query, callback) {
|
|
38121
|
+
const queryStreamId = hash(query);
|
|
38122
|
+
const cacheKey = ['message', 'search', queryStreamId];
|
|
38123
|
+
const paginationController = new SearchMessagePaginationController(query);
|
|
38124
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
38125
|
+
this.queryStreamController = new SearchMessageQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
38126
|
+
this.callback = callback.bind(this);
|
|
38127
|
+
this.loadPage({ initial: true });
|
|
38128
|
+
}
|
|
38129
|
+
startSubscription() {
|
|
38130
|
+
return [];
|
|
38131
|
+
}
|
|
38132
|
+
notifyChange({ origin, loading, error }) {
|
|
38133
|
+
var _a, _b;
|
|
38134
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38135
|
+
if (!collection)
|
|
38136
|
+
return;
|
|
38137
|
+
const data = (_b = collection.data
|
|
38138
|
+
.map(messageId => getMessageFromMainDB(messageId))
|
|
38139
|
+
.filter(isNonNullable)
|
|
38140
|
+
.map(message => LinkedObject.message(message))) !== null && _b !== void 0 ? _b : [];
|
|
38141
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
38142
|
+
return;
|
|
38143
|
+
this.callback({
|
|
38144
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
38145
|
+
data,
|
|
38146
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
38147
|
+
loading,
|
|
38148
|
+
error,
|
|
38149
|
+
});
|
|
38150
|
+
}
|
|
38151
|
+
setup() {
|
|
38152
|
+
var _a;
|
|
38153
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38154
|
+
if (!collection) {
|
|
38155
|
+
pushToCache(this.cacheKey, {
|
|
38156
|
+
data: [],
|
|
38157
|
+
params: {},
|
|
38158
|
+
});
|
|
38159
|
+
}
|
|
38160
|
+
}
|
|
38161
|
+
async persistModel(response) {
|
|
38162
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
38163
|
+
}
|
|
38164
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
38165
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
38166
|
+
}
|
|
38167
|
+
}
|
|
38168
|
+
|
|
38169
|
+
/* begin_public_function
|
|
38170
|
+
id: message.search
|
|
38171
|
+
*/
|
|
38172
|
+
/**
|
|
38173
|
+
* ```js
|
|
38174
|
+
* import { MessageRepository } from '@amityco/ts-sdk';
|
|
38175
|
+
*
|
|
38176
|
+
* let messages = [];
|
|
38177
|
+
*
|
|
38178
|
+
* const unsubscribe = MessageRepository.searchMessage(
|
|
38179
|
+
* { query: 'hello' },
|
|
38180
|
+
* response => merge(messages, response.data),
|
|
38181
|
+
* );
|
|
38182
|
+
* ```
|
|
38183
|
+
*
|
|
38184
|
+
* Live collection of {@link Amity.Message}s matching the search query. Backed
|
|
38185
|
+
* by `GET /api/v2/search/messages`. The first emission delivers the first
|
|
38186
|
+
* page; pagination is driven by `response.onNextPage()`.
|
|
38187
|
+
*
|
|
38188
|
+
* @param params Search parameters. `query` is required.
|
|
38189
|
+
* @param callback Called whenever new data are available.
|
|
38190
|
+
* @returns An {@link Amity.Unsubscriber} function to stop observing.
|
|
38191
|
+
*
|
|
38192
|
+
* @category Message Live Collection
|
|
38193
|
+
*/
|
|
38194
|
+
const searchMessage = (params, callback) => {
|
|
38195
|
+
if (!params.query || params.query.trim().length === 0) {
|
|
38196
|
+
throw new Error('Query is required for message search');
|
|
38197
|
+
}
|
|
38198
|
+
const { log, cache } = getActiveClient();
|
|
38199
|
+
if (!cache) {
|
|
38200
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
38201
|
+
}
|
|
38202
|
+
const timestamp = Date.now();
|
|
38203
|
+
log(`searchMessage(tmpid: ${timestamp}) > listen`);
|
|
38204
|
+
const controller = new SearchMessageLiveCollectionController(params, callback);
|
|
38205
|
+
const disposers = controller.startSubscription();
|
|
38206
|
+
const cacheKey = controller.getCacheKey();
|
|
38207
|
+
disposers.push(() => {
|
|
38208
|
+
dropFromCache(cacheKey);
|
|
38209
|
+
});
|
|
38210
|
+
return () => {
|
|
38211
|
+
log(`searchMessage(tmpid: ${timestamp}) > dispose`);
|
|
38212
|
+
disposers.forEach(fn => fn());
|
|
38213
|
+
};
|
|
38214
|
+
};
|
|
38215
|
+
/* end_public_function */
|
|
38216
|
+
|
|
36853
38217
|
var index$n = /*#__PURE__*/Object.freeze({
|
|
36854
38218
|
__proto__: null,
|
|
36855
38219
|
createMessage: createMessage,
|
|
@@ -36875,6 +38239,7 @@ var index$n = /*#__PURE__*/Object.freeze({
|
|
|
36875
38239
|
onMessageFetched: onMessageFetched,
|
|
36876
38240
|
getMessage: getMessage,
|
|
36877
38241
|
getMessages: getMessages,
|
|
38242
|
+
searchMessage: searchMessage,
|
|
36878
38243
|
convertFromRaw: convertFromRaw$1,
|
|
36879
38244
|
prepareMessagePayload: prepareMessagePayload,
|
|
36880
38245
|
convertParams: convertParams,
|
|
@@ -37722,6 +39087,7 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
37722
39087
|
"onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
37723
39088
|
"onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
37724
39089
|
"onResolveChannel" /* Amity.ChannelActionType.OnResolveChannel */,
|
|
39090
|
+
"onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
37725
39091
|
].includes(action)) {
|
|
37726
39092
|
if (Array.isArray(payload)) {
|
|
37727
39093
|
collection.data = [
|
|
@@ -37731,6 +39097,12 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
37731
39097
|
else
|
|
37732
39098
|
collection.data = [...new Set([payload.channelInternalId, ...collection.data])];
|
|
37733
39099
|
}
|
|
39100
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
39101
|
+
const ids = Array.isArray(payload)
|
|
39102
|
+
? payload.map(getResolver('channel'))
|
|
39103
|
+
: [getResolver('channel')(payload)];
|
|
39104
|
+
collection.data = collection.data.filter(channelInternalId => !ids.includes(channelInternalId));
|
|
39105
|
+
}
|
|
37734
39106
|
pushToCache(this.cacheKey, collection);
|
|
37735
39107
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
37736
39108
|
};
|
|
@@ -37997,6 +39369,32 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
37997
39369
|
},
|
|
37998
39370
|
{ fn: onChannelMemberAdded, action: "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */ },
|
|
37999
39371
|
{ fn: onChannelMemberRemoved, action: "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */ },
|
|
39372
|
+
{
|
|
39373
|
+
fn: (reactor) => onChannelArchived(payload => {
|
|
39374
|
+
const channels = payload.archives
|
|
39375
|
+
.map(archive => {
|
|
39376
|
+
var _a;
|
|
39377
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39378
|
+
})
|
|
39379
|
+
.filter((c) => Boolean(c));
|
|
39380
|
+
if (channels.length > 0)
|
|
39381
|
+
reactor(channels);
|
|
39382
|
+
}),
|
|
39383
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
39384
|
+
},
|
|
39385
|
+
{
|
|
39386
|
+
fn: (reactor) => onChannelUnarchived(payload => {
|
|
39387
|
+
const channels = payload.archives
|
|
39388
|
+
.map(archive => {
|
|
39389
|
+
var _a;
|
|
39390
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39391
|
+
})
|
|
39392
|
+
.filter((c) => Boolean(c));
|
|
39393
|
+
if (channels.length > 0)
|
|
39394
|
+
reactor(channels);
|
|
39395
|
+
}),
|
|
39396
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
39397
|
+
},
|
|
38000
39398
|
{
|
|
38001
39399
|
fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
38002
39400
|
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
@@ -38175,181 +39573,766 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
38175
39573
|
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
38176
39574
|
},
|
|
38177
39575
|
];
|
|
38178
|
-
if (this.paginationController instanceof PaginationController) {
|
|
38179
|
-
return [
|
|
38180
|
-
...subscriptions,
|
|
38181
|
-
{
|
|
38182
|
-
fn: (callback) => {
|
|
38183
|
-
return onChannelCreated(channel => {
|
|
38184
|
-
resolveUnreadInfoOnChannelEvent(channel);
|
|
38185
|
-
callback(channel);
|
|
38186
|
-
});
|
|
38187
|
-
},
|
|
38188
|
-
action: "onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
38189
|
-
},
|
|
38190
|
-
];
|
|
38191
|
-
}
|
|
38192
|
-
return subscriptions;
|
|
39576
|
+
if (this.paginationController instanceof PaginationController) {
|
|
39577
|
+
return [
|
|
39578
|
+
...subscriptions,
|
|
39579
|
+
{
|
|
39580
|
+
fn: (callback) => {
|
|
39581
|
+
return onChannelCreated(channel => {
|
|
39582
|
+
resolveUnreadInfoOnChannelEvent(channel);
|
|
39583
|
+
callback(channel);
|
|
39584
|
+
});
|
|
39585
|
+
},
|
|
39586
|
+
action: "onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
39587
|
+
},
|
|
39588
|
+
];
|
|
39589
|
+
}
|
|
39590
|
+
return subscriptions;
|
|
39591
|
+
}
|
|
39592
|
+
}
|
|
39593
|
+
|
|
39594
|
+
/* eslint-disable no-use-before-define */
|
|
39595
|
+
/* begin_public_function
|
|
39596
|
+
id: channel.query
|
|
39597
|
+
*/
|
|
39598
|
+
/**
|
|
39599
|
+
* ```js
|
|
39600
|
+
* import { getChannels } from '@amityco/ts-sdk'
|
|
39601
|
+
*
|
|
39602
|
+
* let channels = []
|
|
39603
|
+
* const unsub = getChannels({
|
|
39604
|
+
* displayName: Amity.Channel['displayName'],
|
|
39605
|
+
* }, response => merge(channels, response.data))
|
|
39606
|
+
* ```
|
|
39607
|
+
*
|
|
39608
|
+
* Observe all mutations on a list of {@link Amity.Channel}s
|
|
39609
|
+
*
|
|
39610
|
+
* @param params for querying channels
|
|
39611
|
+
* @param callback the function to call when new data are available
|
|
39612
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channels
|
|
39613
|
+
*
|
|
39614
|
+
* @category Channel Live Collection
|
|
39615
|
+
*/
|
|
39616
|
+
const getChannels = (params, callback, config) => {
|
|
39617
|
+
const { log, cache, userId } = getActiveClient();
|
|
39618
|
+
if (!cache) {
|
|
39619
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
39620
|
+
}
|
|
39621
|
+
const timestamp = Date.now();
|
|
39622
|
+
log(`getChannels(tmpid: ${timestamp}) > listen`);
|
|
39623
|
+
const channelLiveCollection = new ChannelLiveCollectionController(params, callback);
|
|
39624
|
+
const disposers = channelLiveCollection.startSubscription();
|
|
39625
|
+
const cacheKey = channelLiveCollection.getCacheKey();
|
|
39626
|
+
disposers.push(() => {
|
|
39627
|
+
dropFromCache(cacheKey);
|
|
39628
|
+
});
|
|
39629
|
+
return () => {
|
|
39630
|
+
log(`getChannels(tmpid: ${timestamp}) > dispose`);
|
|
39631
|
+
disposers.forEach(fn => fn());
|
|
39632
|
+
};
|
|
39633
|
+
};
|
|
39634
|
+
/* end_public_function */
|
|
39635
|
+
|
|
39636
|
+
/**
|
|
39637
|
+
*
|
|
39638
|
+
* Calculate user unread from {@link Amity.ChannelUnread} objects
|
|
39639
|
+
*
|
|
39640
|
+
* @returns the {@link Amity.UserUnread} objects
|
|
39641
|
+
*
|
|
39642
|
+
* @category Channel API
|
|
39643
|
+
* @async
|
|
39644
|
+
*/
|
|
39645
|
+
const getTotalChannelsUnread$1 = () => {
|
|
39646
|
+
var _a;
|
|
39647
|
+
const client = getActiveClient();
|
|
39648
|
+
client.log('channel/getTotalChannelsUnread.locally');
|
|
39649
|
+
const cachedChannelsUnread = ((_a = queryCache(['channelUnread', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
|
|
39650
|
+
return !data.isDeleted;
|
|
39651
|
+
})) || [];
|
|
39652
|
+
const totalChannelsUnread = (cachedChannelsUnread === null || cachedChannelsUnread === void 0 ? void 0 : cachedChannelsUnread.reduce((acc, { data }) => {
|
|
39653
|
+
acc.unreadCount += data.unreadCount;
|
|
39654
|
+
acc.isMentioned = acc.isMentioned || data.isMentioned;
|
|
39655
|
+
return acc;
|
|
39656
|
+
}, { unreadCount: 0, isMentioned: false })) || { unreadCount: 0, isMentioned: false };
|
|
39657
|
+
const cachedAt = client.cache && Date.now();
|
|
39658
|
+
return {
|
|
39659
|
+
data: totalChannelsUnread,
|
|
39660
|
+
cachedAt,
|
|
39661
|
+
};
|
|
39662
|
+
};
|
|
39663
|
+
|
|
39664
|
+
/* begin_public_function
|
|
39665
|
+
id: totalChannelsUnread.get
|
|
39666
|
+
*/
|
|
39667
|
+
/**
|
|
39668
|
+
* ```js
|
|
39669
|
+
* import { ChannelRepository } from '@amityco/ts-sdk';
|
|
39670
|
+
*
|
|
39671
|
+
* let totalChannelsUnread;
|
|
39672
|
+
*
|
|
39673
|
+
* const unsubscribe = ChannelRepository.getTotalChannelsUnread(response => {
|
|
39674
|
+
* unread = response.data;
|
|
39675
|
+
* });
|
|
39676
|
+
* ```
|
|
39677
|
+
*
|
|
39678
|
+
* Observe all mutation on a given {@link Amity.UserUnread}
|
|
39679
|
+
*
|
|
39680
|
+
* @returns An {@link Amity.UserUnread} function to run when willing to stop observing the message
|
|
39681
|
+
*
|
|
39682
|
+
* @category User Unread Live Object
|
|
39683
|
+
*
|
|
39684
|
+
*/
|
|
39685
|
+
const getTotalChannelsUnread = (callback) => {
|
|
39686
|
+
const { _id: userId } = getActiveUser();
|
|
39687
|
+
if (!userId)
|
|
39688
|
+
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
39689
|
+
const { log, cache } = getActiveClient();
|
|
39690
|
+
if (!cache) {
|
|
39691
|
+
console.log('For using Live Object feature you need to enable Cache!');
|
|
39692
|
+
}
|
|
39693
|
+
const timestamp = Date.now();
|
|
39694
|
+
log(`liveTotalChannelsUnread(tmpid: ${timestamp}) > listen`);
|
|
39695
|
+
const disposers = [];
|
|
39696
|
+
let isUnsyncedModel = false; // for messages
|
|
39697
|
+
let model;
|
|
39698
|
+
const dispatcher = (data) => {
|
|
39699
|
+
const { data: userUnread } = data;
|
|
39700
|
+
const callbackModel = userUnread
|
|
39701
|
+
? {
|
|
39702
|
+
unreadCount: userUnread.unreadCount,
|
|
39703
|
+
isMentioned: userUnread.isMentioned,
|
|
39704
|
+
}
|
|
39705
|
+
: undefined;
|
|
39706
|
+
model = callbackModel ? convertGetterPropsToStatic(callbackModel) : callbackModel;
|
|
39707
|
+
callback({
|
|
39708
|
+
data: callbackModel
|
|
39709
|
+
? Object.assign(Object.assign({}, callbackModel), { isMentioned: callbackModel.isMentioned }) : callbackModel,
|
|
39710
|
+
loading: data.loading,
|
|
39711
|
+
error: data.error,
|
|
39712
|
+
});
|
|
39713
|
+
};
|
|
39714
|
+
const realtimeRouter = (_) => {
|
|
39715
|
+
const { data: userUnread } = getTotalChannelsUnread$1();
|
|
39716
|
+
if (isEqual(model, userUnread))
|
|
39717
|
+
return;
|
|
39718
|
+
dispatcher({
|
|
39719
|
+
loading: false,
|
|
39720
|
+
data: userUnread,
|
|
39721
|
+
});
|
|
39722
|
+
};
|
|
39723
|
+
const onFetch = () => {
|
|
39724
|
+
const query = createQuery(async () => getTotalChannelsUnread$1());
|
|
39725
|
+
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
39726
|
+
if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
|
|
39727
|
+
dispatcher({
|
|
39728
|
+
data,
|
|
39729
|
+
origin,
|
|
39730
|
+
loading: false,
|
|
39731
|
+
error: new ASCApiError(UNSYNCED_OBJECT_CACHED_AT_MESSAGE, 800800 /* Amity.ClientError.DISALOOW_UNSYNCED_OBJECT */, "error" /* Amity.ErrorLevel.ERROR */),
|
|
39732
|
+
});
|
|
39733
|
+
isUnsyncedModel = true;
|
|
39734
|
+
disposers.forEach(fn => fn());
|
|
39735
|
+
}
|
|
39736
|
+
else if (!isUnsyncedModel) {
|
|
39737
|
+
dispatcher({ loading, data, origin, error });
|
|
39738
|
+
}
|
|
39739
|
+
if (error) {
|
|
39740
|
+
disposers.forEach(fn => fn());
|
|
39741
|
+
}
|
|
39742
|
+
});
|
|
39743
|
+
};
|
|
39744
|
+
disposers.push(onChannelUnreadUpdatedLocal(realtimeRouter));
|
|
39745
|
+
onFetch();
|
|
39746
|
+
return () => {
|
|
39747
|
+
disposers.forEach(fn => fn());
|
|
39748
|
+
};
|
|
39749
|
+
};
|
|
39750
|
+
|
|
39751
|
+
class ArchivedChannelPaginationController extends PaginationController {
|
|
39752
|
+
async getRequest(queryParams, token) {
|
|
39753
|
+
var _a, _b;
|
|
39754
|
+
const limit = (_a = queryParams.limit) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
39755
|
+
const pageIndex = token ? Number.parseInt(token, 10) : 0;
|
|
39756
|
+
if (pageIndex === 0) {
|
|
39757
|
+
await getArchivedChannelIds();
|
|
39758
|
+
}
|
|
39759
|
+
const cached = (_b = queryCache(['archivedChannel', 'get'])) !== null && _b !== void 0 ? _b : [];
|
|
39760
|
+
const archives = cached
|
|
39761
|
+
.map(entry => entry.data)
|
|
39762
|
+
.slice()
|
|
39763
|
+
.sort((a, b) => Number(new Date(b.archivedAt)) - Number(new Date(a.archivedAt)));
|
|
39764
|
+
const start = pageIndex * limit;
|
|
39765
|
+
const end = start + limit;
|
|
39766
|
+
const slice = archives.slice(start, end);
|
|
39767
|
+
const hasMore = end < archives.length;
|
|
39768
|
+
if (slice.length > 0) {
|
|
39769
|
+
await getChannelByIds$1(slice.map(archive => archive.channelId));
|
|
39770
|
+
}
|
|
39771
|
+
return {
|
|
39772
|
+
archives: slice,
|
|
39773
|
+
paging: {
|
|
39774
|
+
next: hasMore ? String(pageIndex + 1) : undefined,
|
|
39775
|
+
previous: undefined,
|
|
39776
|
+
},
|
|
39777
|
+
};
|
|
39778
|
+
}
|
|
39779
|
+
}
|
|
39780
|
+
|
|
39781
|
+
class ArchivedChannelQueryStreamController extends QueryStreamController {
|
|
39782
|
+
constructor(query, cacheKey, notifyChange) {
|
|
39783
|
+
super(query, cacheKey);
|
|
39784
|
+
this.notifyChange = notifyChange;
|
|
39785
|
+
}
|
|
39786
|
+
async saveToMainDB(_response) {
|
|
39787
|
+
//
|
|
39788
|
+
}
|
|
39789
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
39790
|
+
var _a, _b;
|
|
39791
|
+
const channelIds = response.archives.map(archive => archive.channelId);
|
|
39792
|
+
if (refresh) {
|
|
39793
|
+
pushToCache(this.cacheKey, {
|
|
39794
|
+
data: channelIds,
|
|
39795
|
+
params: {},
|
|
39796
|
+
});
|
|
39797
|
+
return;
|
|
39798
|
+
}
|
|
39799
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39800
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
39801
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
39802
|
+
? [...new Set([...channelIds, ...existing])]
|
|
39803
|
+
: [...new Set([...existing, ...channelIds])] }));
|
|
39804
|
+
}
|
|
39805
|
+
reactor(action) {
|
|
39806
|
+
return (channelIds) => {
|
|
39807
|
+
var _a;
|
|
39808
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39809
|
+
if (!collection)
|
|
39810
|
+
return;
|
|
39811
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
39812
|
+
const filtered = collection.data.filter(id => !channelIds.includes(id));
|
|
39813
|
+
collection.data = [...channelIds, ...filtered];
|
|
39814
|
+
}
|
|
39815
|
+
if (action === "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */ ||
|
|
39816
|
+
action === "onDelete" /* Amity.ChannelActionType.OnDelete */) {
|
|
39817
|
+
collection.data = collection.data.filter(id => !channelIds.includes(id));
|
|
39818
|
+
}
|
|
39819
|
+
pushToCache(this.cacheKey, collection);
|
|
39820
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
39821
|
+
};
|
|
39822
|
+
}
|
|
39823
|
+
subscribeRTE(createSubscriber) {
|
|
39824
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
39825
|
+
}
|
|
39826
|
+
}
|
|
39827
|
+
|
|
39828
|
+
class ArchivedChannelLiveCollectionController extends LiveCollectionController {
|
|
39829
|
+
constructor(query, callback) {
|
|
39830
|
+
const queryStreamId = hash(query);
|
|
39831
|
+
const cacheKey = ['archivedChannel', 'collection', queryStreamId];
|
|
39832
|
+
const paginationController = new ArchivedChannelPaginationController(query);
|
|
39833
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
39834
|
+
this.queryStreamController = new ArchivedChannelQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
39835
|
+
this.callback = callback.bind(this);
|
|
39836
|
+
this.loadPage({ initial: true });
|
|
39837
|
+
}
|
|
39838
|
+
setup() {
|
|
39839
|
+
var _a;
|
|
39840
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39841
|
+
if (!collection) {
|
|
39842
|
+
pushToCache(this.cacheKey, {
|
|
39843
|
+
data: [],
|
|
39844
|
+
params: {},
|
|
39845
|
+
});
|
|
39846
|
+
}
|
|
39847
|
+
}
|
|
39848
|
+
async persistModel(response) {
|
|
39849
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
39850
|
+
}
|
|
39851
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
39852
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
39853
|
+
}
|
|
39854
|
+
startSubscription() {
|
|
39855
|
+
return this.queryStreamController.subscribeRTE([
|
|
39856
|
+
{
|
|
39857
|
+
fn: reactor => onChannelArchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
39858
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
39859
|
+
},
|
|
39860
|
+
{
|
|
39861
|
+
fn: reactor => onChannelUnarchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
39862
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
39863
|
+
},
|
|
39864
|
+
{
|
|
39865
|
+
fn: reactor => onChannelUpdated(channel => reactor([channel.channelId])),
|
|
39866
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
39867
|
+
},
|
|
39868
|
+
{
|
|
39869
|
+
fn: reactor => onChannelDeleted(channel => reactor([channel.channelId])),
|
|
39870
|
+
action: "onDelete" /* Amity.ChannelActionType.OnDelete */,
|
|
39871
|
+
},
|
|
39872
|
+
]);
|
|
39873
|
+
}
|
|
39874
|
+
notifyChange({ origin, loading, error }) {
|
|
39875
|
+
var _a, _b;
|
|
39876
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39877
|
+
if (!collection)
|
|
39878
|
+
return;
|
|
39879
|
+
const data = (_b = collection.data
|
|
39880
|
+
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
39881
|
+
.filter((entry) => Boolean(entry))
|
|
39882
|
+
.map(({ data: channel }) => channel)
|
|
39883
|
+
.map(constructChannelObject)) !== null && _b !== void 0 ? _b : [];
|
|
39884
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
39885
|
+
return;
|
|
39886
|
+
this.callback({
|
|
39887
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
39888
|
+
data,
|
|
39889
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
39890
|
+
loading,
|
|
39891
|
+
error,
|
|
39892
|
+
});
|
|
39893
|
+
}
|
|
39894
|
+
}
|
|
39895
|
+
|
|
39896
|
+
/* begin_public_function
|
|
39897
|
+
id: channel.archive.collection
|
|
39898
|
+
*/
|
|
39899
|
+
/**
|
|
39900
|
+
* ```js
|
|
39901
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
39902
|
+
*
|
|
39903
|
+
* let channels = []
|
|
39904
|
+
* const unsub = ChannelRepository.getArchivedChannels(params, response => merge(channels, response.data))
|
|
39905
|
+
* ```
|
|
39906
|
+
*
|
|
39907
|
+
* Live collection of {@link Amity.Channel}s archived by the active user.
|
|
39908
|
+
*
|
|
39909
|
+
* @param params Live collection parameters (only `limit` is honored; the
|
|
39910
|
+
* archive list takes no other filters).
|
|
39911
|
+
* @param callback the function to call when new data are available
|
|
39912
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to
|
|
39913
|
+
* stop observing.
|
|
39914
|
+
*
|
|
39915
|
+
* @category Channel Live Collection
|
|
39916
|
+
*/
|
|
39917
|
+
const getArchivedChannels = (params, callback) => {
|
|
39918
|
+
const { log, cache } = getActiveClient();
|
|
39919
|
+
if (!cache) {
|
|
39920
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
39921
|
+
}
|
|
39922
|
+
const timestamp = Date.now();
|
|
39923
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > listen`);
|
|
39924
|
+
const controller = new ArchivedChannelLiveCollectionController(params, callback);
|
|
39925
|
+
const disposers = controller.startSubscription();
|
|
39926
|
+
const cacheKey = controller.getCacheKey();
|
|
39927
|
+
disposers.push(() => {
|
|
39928
|
+
dropFromCache(cacheKey);
|
|
39929
|
+
});
|
|
39930
|
+
return () => {
|
|
39931
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > dispose`);
|
|
39932
|
+
disposers.forEach(fn => fn());
|
|
39933
|
+
};
|
|
39934
|
+
};
|
|
39935
|
+
/* end_public_function */
|
|
39936
|
+
|
|
39937
|
+
class SearchChannelPaginationController extends PaginationController {
|
|
39938
|
+
async getRequest(queryParams, token) {
|
|
39939
|
+
const { query, exactMatch, isMemberOnly, types, tags, sortBy, orderBy, limit = COLLECTION_DEFAULT_PAGINATION_SIZE, } = queryParams;
|
|
39940
|
+
const options = token ? { token } : { limit: Math.min(100, Math.max(1, limit)) };
|
|
39941
|
+
const { data: queryResponse } = await this.http.get(`/api/v2/search/channels`, {
|
|
39942
|
+
params: {
|
|
39943
|
+
query,
|
|
39944
|
+
exactMatch,
|
|
39945
|
+
isMemberOnly,
|
|
39946
|
+
types,
|
|
39947
|
+
tags,
|
|
39948
|
+
sortBy,
|
|
39949
|
+
orderBy,
|
|
39950
|
+
options,
|
|
39951
|
+
},
|
|
39952
|
+
});
|
|
39953
|
+
return queryResponse;
|
|
39954
|
+
}
|
|
39955
|
+
}
|
|
39956
|
+
|
|
39957
|
+
class SearchChannelQueryStreamController extends QueryStreamController {
|
|
39958
|
+
constructor(query, cacheKey, notifyChange) {
|
|
39959
|
+
super(query, cacheKey);
|
|
39960
|
+
this.notifyChange = notifyChange;
|
|
39961
|
+
}
|
|
39962
|
+
async saveToMainDB(response) {
|
|
39963
|
+
const processedPayload = await prepareChannelPayload(response);
|
|
39964
|
+
const client = getActiveClient();
|
|
39965
|
+
const cachedAt = client.cache && Date.now();
|
|
39966
|
+
if (client.cache) {
|
|
39967
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
39968
|
+
}
|
|
39969
|
+
}
|
|
39970
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
39971
|
+
var _a, _b;
|
|
39972
|
+
if (refresh) {
|
|
39973
|
+
pushToCache(this.cacheKey, {
|
|
39974
|
+
data: response.channels.map(getResolver('channel')),
|
|
39975
|
+
});
|
|
39976
|
+
return;
|
|
39977
|
+
}
|
|
39978
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39979
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
39980
|
+
const incoming = response.channels.map(getResolver('channel'));
|
|
39981
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
39982
|
+
? [...new Set([...incoming, ...existing])]
|
|
39983
|
+
: [...new Set([...existing, ...incoming])] }));
|
|
39984
|
+
}
|
|
39985
|
+
reactor() {
|
|
39986
|
+
return () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
39987
|
+
}
|
|
39988
|
+
subscribeRTE(createSubscriber) {
|
|
39989
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor()));
|
|
39990
|
+
}
|
|
39991
|
+
}
|
|
39992
|
+
|
|
39993
|
+
/* eslint-disable no-use-before-define */
|
|
39994
|
+
const getMessagePreviewSetting = () => {
|
|
39995
|
+
const client = getActiveClient();
|
|
39996
|
+
return client.getMessagePreviewSetting(false);
|
|
39997
|
+
};
|
|
39998
|
+
class SearchChannelLiveCollectionController extends LiveCollectionController {
|
|
39999
|
+
constructor(query, callback) {
|
|
40000
|
+
const queryStreamId = hash(query);
|
|
40001
|
+
const cacheKey = ['channel', 'search', queryStreamId];
|
|
40002
|
+
const paginationController = new SearchChannelPaginationController(query);
|
|
40003
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40004
|
+
this.queryStreamController = new SearchChannelQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
40005
|
+
this.callback = callback.bind(this);
|
|
40006
|
+
this.loadPage({ initial: true });
|
|
40007
|
+
}
|
|
40008
|
+
startSubscription() {
|
|
40009
|
+
return this.queryStreamController.subscribeRTE(this.getSubscriptions());
|
|
40010
|
+
}
|
|
40011
|
+
notifyChange({ origin, loading, error }) {
|
|
40012
|
+
var _a, _b;
|
|
40013
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40014
|
+
if (!collection)
|
|
40015
|
+
return;
|
|
40016
|
+
const data = (_b = collection.data
|
|
40017
|
+
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
40018
|
+
.filter(Boolean)
|
|
40019
|
+
.map(cached => constructChannelObject(cached.data))) !== null && _b !== void 0 ? _b : [];
|
|
40020
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40021
|
+
return;
|
|
40022
|
+
this.callback({
|
|
40023
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40024
|
+
data,
|
|
40025
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40026
|
+
loading,
|
|
40027
|
+
error,
|
|
40028
|
+
});
|
|
40029
|
+
}
|
|
40030
|
+
setup() {
|
|
40031
|
+
var _a;
|
|
40032
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40033
|
+
if (!collection) {
|
|
40034
|
+
pushToCache(this.cacheKey, {
|
|
40035
|
+
data: [],
|
|
40036
|
+
params: {},
|
|
40037
|
+
});
|
|
40038
|
+
}
|
|
40039
|
+
}
|
|
40040
|
+
async persistModel(response) {
|
|
40041
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
40042
|
+
}
|
|
40043
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40044
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40045
|
+
}
|
|
40046
|
+
shouldAbort(targetChannelId) {
|
|
40047
|
+
var _a;
|
|
40048
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40049
|
+
if (!collection)
|
|
40050
|
+
return true;
|
|
40051
|
+
return !collection.data.find(channelId => channelId === targetChannelId);
|
|
40052
|
+
}
|
|
40053
|
+
getSubscriptions() {
|
|
40054
|
+
return [
|
|
40055
|
+
{
|
|
40056
|
+
fn: convertEventPayload((callback) => {
|
|
40057
|
+
return onMessageCreatedMqtt(message => {
|
|
40058
|
+
var _a;
|
|
40059
|
+
const cacheData = (_a = pullFromCache([
|
|
40060
|
+
'channel',
|
|
40061
|
+
'get',
|
|
40062
|
+
message.channelId,
|
|
40063
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40064
|
+
if (!cacheData)
|
|
40065
|
+
return;
|
|
40066
|
+
updateChannelCache(cacheData, {
|
|
40067
|
+
lastActivity: message.createdAt,
|
|
40068
|
+
});
|
|
40069
|
+
callback(message);
|
|
40070
|
+
});
|
|
40071
|
+
}, 'channelId', 'channel'),
|
|
40072
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40073
|
+
},
|
|
40074
|
+
{
|
|
40075
|
+
fn: convertEventPayload((callback) => {
|
|
40076
|
+
return onMessageCreatedLocal(message => {
|
|
40077
|
+
var _a;
|
|
40078
|
+
const cacheData = (_a = pullFromCache([
|
|
40079
|
+
'channel',
|
|
40080
|
+
'get',
|
|
40081
|
+
message.channelId,
|
|
40082
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40083
|
+
if (!cacheData)
|
|
40084
|
+
return;
|
|
40085
|
+
updateChannelCache(cacheData, {
|
|
40086
|
+
lastActivity: message.createdAt,
|
|
40087
|
+
});
|
|
40088
|
+
callback(message);
|
|
40089
|
+
});
|
|
40090
|
+
}, 'channelId', 'channel'),
|
|
40091
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40092
|
+
},
|
|
40093
|
+
{ fn: onChannelDeleted, action: "onDelete" /* Amity.ChannelActionType.OnDelete */ },
|
|
40094
|
+
{ fn: onChannelUpdated, action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */ },
|
|
40095
|
+
{ fn: onChannelSetMuted, action: "onMute" /* Amity.ChannelActionType.OnMute */ },
|
|
40096
|
+
{
|
|
40097
|
+
fn: (reactor) => onChannelArchived(payload => {
|
|
40098
|
+
const channels = payload.archives
|
|
40099
|
+
.map(archive => {
|
|
40100
|
+
var _a;
|
|
40101
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40102
|
+
})
|
|
40103
|
+
.filter((c) => Boolean(c));
|
|
40104
|
+
if (channels.length > 0)
|
|
40105
|
+
reactor(channels);
|
|
40106
|
+
}),
|
|
40107
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
40108
|
+
},
|
|
40109
|
+
{
|
|
40110
|
+
fn: (reactor) => onChannelUnarchived(payload => {
|
|
40111
|
+
const channels = payload.archives
|
|
40112
|
+
.map(archive => {
|
|
40113
|
+
var _a;
|
|
40114
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40115
|
+
})
|
|
40116
|
+
.filter((c) => Boolean(c));
|
|
40117
|
+
if (channels.length > 0)
|
|
40118
|
+
reactor(channels);
|
|
40119
|
+
}),
|
|
40120
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
40121
|
+
},
|
|
40122
|
+
{
|
|
40123
|
+
fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
40124
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40125
|
+
},
|
|
40126
|
+
{
|
|
40127
|
+
fn: convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
|
|
40128
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40129
|
+
},
|
|
40130
|
+
{
|
|
40131
|
+
fn: convertEventPayload((callback) => {
|
|
40132
|
+
const updateMessagePreview = async (message) => {
|
|
40133
|
+
var _a;
|
|
40134
|
+
const messagePreviewSetting = await getMessagePreviewSetting();
|
|
40135
|
+
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
40136
|
+
return;
|
|
40137
|
+
handleMessageCreated(message);
|
|
40138
|
+
if (this.shouldAbort(message.channelId))
|
|
40139
|
+
return;
|
|
40140
|
+
const channel = (_a = pullFromCache([
|
|
40141
|
+
'channel',
|
|
40142
|
+
'get',
|
|
40143
|
+
message.channelId,
|
|
40144
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40145
|
+
if (!channel)
|
|
40146
|
+
return;
|
|
40147
|
+
updateChannelCache(channel, {
|
|
40148
|
+
messagePreviewId: message.messageId,
|
|
40149
|
+
});
|
|
40150
|
+
callback(message);
|
|
40151
|
+
};
|
|
40152
|
+
return onMessageCreatedMqtt(updateMessagePreview);
|
|
40153
|
+
}, 'channelId', 'channel'),
|
|
40154
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40155
|
+
},
|
|
40156
|
+
{
|
|
40157
|
+
fn: convertEventPayload((callback) => {
|
|
40158
|
+
const updateMessagePreview = async (message) => {
|
|
40159
|
+
var _a;
|
|
40160
|
+
const messagePreviewSetting = await getMessagePreviewSetting();
|
|
40161
|
+
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
40162
|
+
return;
|
|
40163
|
+
handleMessageCreated(message);
|
|
40164
|
+
if (this.shouldAbort(message.channelId))
|
|
40165
|
+
return;
|
|
40166
|
+
const channel = (_a = pullFromCache([
|
|
40167
|
+
'channel',
|
|
40168
|
+
'get',
|
|
40169
|
+
message.channelId,
|
|
40170
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40171
|
+
if (!channel)
|
|
40172
|
+
return;
|
|
40173
|
+
updateChannelCache(channel, {
|
|
40174
|
+
messagePreviewId: message.messageId,
|
|
40175
|
+
});
|
|
40176
|
+
callback(message);
|
|
40177
|
+
};
|
|
40178
|
+
return onMessageCreatedLocal(updateMessagePreview);
|
|
40179
|
+
}, 'channelId', 'channel'),
|
|
40180
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40181
|
+
},
|
|
40182
|
+
{
|
|
40183
|
+
fn: convertEventPayload((callback) => {
|
|
40184
|
+
const updateMessagePreview = async (message) => {
|
|
40185
|
+
const messagePreviewSetting = await getMessagePreviewSetting();
|
|
40186
|
+
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
40187
|
+
return;
|
|
40188
|
+
handleMessageUpdated(message);
|
|
40189
|
+
if (this.shouldAbort(message.channelId))
|
|
40190
|
+
return;
|
|
40191
|
+
callback(message);
|
|
40192
|
+
};
|
|
40193
|
+
return onMessageUpdated(updateMessagePreview);
|
|
40194
|
+
}, 'channelId', 'channel'),
|
|
40195
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40196
|
+
},
|
|
40197
|
+
{
|
|
40198
|
+
fn: convertEventPayload((callback) => {
|
|
40199
|
+
const updateMessagePreview = async (message) => {
|
|
40200
|
+
const messagePreviewSetting = await getMessagePreviewSetting();
|
|
40201
|
+
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
40202
|
+
return;
|
|
40203
|
+
if (messagePreviewSetting ===
|
|
40204
|
+
"message-preview-include-deleted" /* Amity.MessagePreviewSetting.MESSAGE_PREVIEW_INCLUDE_DELETED */)
|
|
40205
|
+
await handleMessageUpdated(message);
|
|
40206
|
+
if (this.shouldAbort(message.channelId))
|
|
40207
|
+
return;
|
|
40208
|
+
if (messagePreviewSetting ===
|
|
40209
|
+
"message-preview-not-include-deleted" /* Amity.MessagePreviewSetting.MESSAGE_PREVIEW_NOT_INCLUDE_DELETED */) {
|
|
40210
|
+
await getChannel$1(message.channelId);
|
|
40211
|
+
}
|
|
40212
|
+
callback(message);
|
|
40213
|
+
};
|
|
40214
|
+
return onMessageDeleted(updateMessagePreview);
|
|
40215
|
+
}, 'channelId', 'channel'),
|
|
40216
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40217
|
+
},
|
|
40218
|
+
{
|
|
40219
|
+
fn: convertEventPayload((callback) => {
|
|
40220
|
+
const updateMessagePreview = async (subChannel) => {
|
|
40221
|
+
var _a;
|
|
40222
|
+
const collections = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40223
|
+
if (!collections)
|
|
40224
|
+
return;
|
|
40225
|
+
const channelId = collections.data.find(channel => {
|
|
40226
|
+
const messagePreviewCache = getChannelMessagePreview(channel);
|
|
40227
|
+
return (messagePreviewCache === null || messagePreviewCache === void 0 ? void 0 : messagePreviewCache.subChannelId) === subChannel.subChannelId;
|
|
40228
|
+
});
|
|
40229
|
+
if (!channelId)
|
|
40230
|
+
return;
|
|
40231
|
+
await getChannel$1(subChannel.channelId);
|
|
40232
|
+
callback(subChannel);
|
|
40233
|
+
};
|
|
40234
|
+
return onSubChannelDeleted(updateMessagePreview);
|
|
40235
|
+
}, 'channelId', 'channel'),
|
|
40236
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40237
|
+
},
|
|
40238
|
+
{
|
|
40239
|
+
fn: convertEventPayload((callback) => {
|
|
40240
|
+
const updateMessagePreview = async (subChannel) => {
|
|
40241
|
+
var _a;
|
|
40242
|
+
const messagePreviewSetting = await getMessagePreviewSetting();
|
|
40243
|
+
if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
|
|
40244
|
+
return;
|
|
40245
|
+
const collections = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40246
|
+
if (!collections)
|
|
40247
|
+
return;
|
|
40248
|
+
await handleSubChannelUpdated(subChannel);
|
|
40249
|
+
if (this.shouldAbort(subChannel.channelId))
|
|
40250
|
+
return;
|
|
40251
|
+
callback(subChannel);
|
|
40252
|
+
};
|
|
40253
|
+
return onSubChannelUpdated(updateMessagePreview);
|
|
40254
|
+
}, 'channelId', 'channel'),
|
|
40255
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40256
|
+
},
|
|
40257
|
+
{
|
|
40258
|
+
fn: (callback) => {
|
|
40259
|
+
const handleUserFeedMarkerResolved = async (marker) => {
|
|
40260
|
+
if (marker.feedMarkers) {
|
|
40261
|
+
const channels = marker.feedMarkers
|
|
40262
|
+
.map(feedMarker => {
|
|
40263
|
+
var _a;
|
|
40264
|
+
return (_a = pullFromCache([
|
|
40265
|
+
'channel',
|
|
40266
|
+
'get',
|
|
40267
|
+
feedMarker.entityId,
|
|
40268
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
40269
|
+
})
|
|
40270
|
+
.filter(Boolean);
|
|
40271
|
+
callback(channels);
|
|
40272
|
+
}
|
|
40273
|
+
};
|
|
40274
|
+
return onUserMessageFeedMarkerResolved(handleUserFeedMarkerResolved);
|
|
40275
|
+
},
|
|
40276
|
+
action: "OnResolveUnread" /* Amity.ChannelActionType.OnResolveUnread */,
|
|
40277
|
+
},
|
|
40278
|
+
{
|
|
40279
|
+
fn: convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
40280
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40281
|
+
},
|
|
40282
|
+
{
|
|
40283
|
+
fn: convertEventPayload((callback) => {
|
|
40284
|
+
const processPayload = (payloads) => {
|
|
40285
|
+
payloads.forEach(callback);
|
|
40286
|
+
};
|
|
40287
|
+
return onChannelUnreadUpdatedLocal(processPayload);
|
|
40288
|
+
}, 'channelId', 'channel'),
|
|
40289
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
40290
|
+
},
|
|
40291
|
+
];
|
|
38193
40292
|
}
|
|
38194
40293
|
}
|
|
38195
40294
|
|
|
38196
|
-
/* eslint-disable no-use-before-define */
|
|
38197
40295
|
/* begin_public_function
|
|
38198
|
-
id: channel.
|
|
40296
|
+
id: channel.search
|
|
38199
40297
|
*/
|
|
38200
40298
|
/**
|
|
38201
40299
|
* ```js
|
|
38202
|
-
* import {
|
|
40300
|
+
* import { ChannelRepository } from '@amityco/ts-sdk';
|
|
38203
40301
|
*
|
|
38204
|
-
*
|
|
38205
|
-
*
|
|
38206
|
-
*
|
|
38207
|
-
*
|
|
40302
|
+
* const unsubscribe = ChannelRepository.searchChannels(
|
|
40303
|
+
* { query: 'hello' },
|
|
40304
|
+
* response => response.data,
|
|
40305
|
+
* );
|
|
38208
40306
|
* ```
|
|
38209
40307
|
*
|
|
38210
|
-
*
|
|
40308
|
+
* Live collection of {@link Amity.Channel}s matching the search query. Backed by
|
|
40309
|
+
* `GET /api/v2/search/channels`.
|
|
38211
40310
|
*
|
|
38212
|
-
* @param params
|
|
38213
|
-
* @param callback
|
|
38214
|
-
* @returns An {@link Amity.Unsubscriber} function to
|
|
40311
|
+
* @param params Search parameters.
|
|
40312
|
+
* @param callback Called whenever new data are available.
|
|
40313
|
+
* @returns An {@link Amity.Unsubscriber} function to stop observing.
|
|
38215
40314
|
*
|
|
38216
40315
|
* @category Channel Live Collection
|
|
38217
40316
|
*/
|
|
38218
|
-
const
|
|
38219
|
-
const { log, cache
|
|
38220
|
-
if (!cache)
|
|
40317
|
+
const searchChannels = (params, callback) => {
|
|
40318
|
+
const { log, cache } = getActiveClient();
|
|
40319
|
+
if (!cache)
|
|
38221
40320
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
38222
|
-
}
|
|
38223
40321
|
const timestamp = Date.now();
|
|
38224
|
-
log(`
|
|
38225
|
-
const
|
|
38226
|
-
const disposers =
|
|
38227
|
-
const cacheKey =
|
|
40322
|
+
log(`searchChannels(tmpid: ${timestamp}) > listen`);
|
|
40323
|
+
const searchChannelLiveCollection = new SearchChannelLiveCollectionController(params, callback);
|
|
40324
|
+
const disposers = searchChannelLiveCollection.startSubscription();
|
|
40325
|
+
const cacheKey = searchChannelLiveCollection.getCacheKey();
|
|
38228
40326
|
disposers.push(() => {
|
|
38229
40327
|
dropFromCache(cacheKey);
|
|
38230
40328
|
});
|
|
38231
40329
|
return () => {
|
|
38232
|
-
log(`
|
|
40330
|
+
log(`searchChannels(tmpid: ${timestamp}) > dispose`);
|
|
38233
40331
|
disposers.forEach(fn => fn());
|
|
38234
40332
|
};
|
|
38235
40333
|
};
|
|
38236
40334
|
/* end_public_function */
|
|
38237
40335
|
|
|
38238
|
-
/**
|
|
38239
|
-
*
|
|
38240
|
-
* Calculate user unread from {@link Amity.ChannelUnread} objects
|
|
38241
|
-
*
|
|
38242
|
-
* @returns the {@link Amity.UserUnread} objects
|
|
38243
|
-
*
|
|
38244
|
-
* @category Channel API
|
|
38245
|
-
* @async
|
|
38246
|
-
*/
|
|
38247
|
-
const getTotalChannelsUnread$1 = () => {
|
|
38248
|
-
var _a;
|
|
38249
|
-
const client = getActiveClient();
|
|
38250
|
-
client.log('channel/getTotalChannelsUnread.locally');
|
|
38251
|
-
const cachedChannelsUnread = ((_a = queryCache(['channelUnread', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
|
|
38252
|
-
return !data.isDeleted;
|
|
38253
|
-
})) || [];
|
|
38254
|
-
const totalChannelsUnread = (cachedChannelsUnread === null || cachedChannelsUnread === void 0 ? void 0 : cachedChannelsUnread.reduce((acc, { data }) => {
|
|
38255
|
-
acc.unreadCount += data.unreadCount;
|
|
38256
|
-
acc.isMentioned = acc.isMentioned || data.isMentioned;
|
|
38257
|
-
return acc;
|
|
38258
|
-
}, { unreadCount: 0, isMentioned: false })) || { unreadCount: 0, isMentioned: false };
|
|
38259
|
-
const cachedAt = client.cache && Date.now();
|
|
38260
|
-
return {
|
|
38261
|
-
data: totalChannelsUnread,
|
|
38262
|
-
cachedAt,
|
|
38263
|
-
};
|
|
38264
|
-
};
|
|
38265
|
-
|
|
38266
|
-
/* begin_public_function
|
|
38267
|
-
id: totalChannelsUnread.get
|
|
38268
|
-
*/
|
|
38269
|
-
/**
|
|
38270
|
-
* ```js
|
|
38271
|
-
* import { ChannelRepository } from '@amityco/ts-sdk';
|
|
38272
|
-
*
|
|
38273
|
-
* let totalChannelsUnread;
|
|
38274
|
-
*
|
|
38275
|
-
* const unsubscribe = ChannelRepository.getTotalChannelsUnread(response => {
|
|
38276
|
-
* unread = response.data;
|
|
38277
|
-
* });
|
|
38278
|
-
* ```
|
|
38279
|
-
*
|
|
38280
|
-
* Observe all mutation on a given {@link Amity.UserUnread}
|
|
38281
|
-
*
|
|
38282
|
-
* @returns An {@link Amity.UserUnread} function to run when willing to stop observing the message
|
|
38283
|
-
*
|
|
38284
|
-
* @category User Unread Live Object
|
|
38285
|
-
*
|
|
38286
|
-
*/
|
|
38287
|
-
const getTotalChannelsUnread = (callback) => {
|
|
38288
|
-
const { _id: userId } = getActiveUser();
|
|
38289
|
-
if (!userId)
|
|
38290
|
-
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
38291
|
-
const { log, cache } = getActiveClient();
|
|
38292
|
-
if (!cache) {
|
|
38293
|
-
console.log('For using Live Object feature you need to enable Cache!');
|
|
38294
|
-
}
|
|
38295
|
-
const timestamp = Date.now();
|
|
38296
|
-
log(`liveTotalChannelsUnread(tmpid: ${timestamp}) > listen`);
|
|
38297
|
-
const disposers = [];
|
|
38298
|
-
let isUnsyncedModel = false; // for messages
|
|
38299
|
-
let model;
|
|
38300
|
-
const dispatcher = (data) => {
|
|
38301
|
-
const { data: userUnread } = data;
|
|
38302
|
-
const callbackModel = userUnread
|
|
38303
|
-
? {
|
|
38304
|
-
unreadCount: userUnread.unreadCount,
|
|
38305
|
-
isMentioned: userUnread.isMentioned,
|
|
38306
|
-
}
|
|
38307
|
-
: undefined;
|
|
38308
|
-
model = callbackModel ? convertGetterPropsToStatic(callbackModel) : callbackModel;
|
|
38309
|
-
callback({
|
|
38310
|
-
data: callbackModel
|
|
38311
|
-
? Object.assign(Object.assign({}, callbackModel), { isMentioned: callbackModel.isMentioned }) : callbackModel,
|
|
38312
|
-
loading: data.loading,
|
|
38313
|
-
error: data.error,
|
|
38314
|
-
});
|
|
38315
|
-
};
|
|
38316
|
-
const realtimeRouter = (_) => {
|
|
38317
|
-
const { data: userUnread } = getTotalChannelsUnread$1();
|
|
38318
|
-
if (isEqual(model, userUnread))
|
|
38319
|
-
return;
|
|
38320
|
-
dispatcher({
|
|
38321
|
-
loading: false,
|
|
38322
|
-
data: userUnread,
|
|
38323
|
-
});
|
|
38324
|
-
};
|
|
38325
|
-
const onFetch = () => {
|
|
38326
|
-
const query = createQuery(async () => getTotalChannelsUnread$1());
|
|
38327
|
-
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
38328
|
-
if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
|
|
38329
|
-
dispatcher({
|
|
38330
|
-
data,
|
|
38331
|
-
origin,
|
|
38332
|
-
loading: false,
|
|
38333
|
-
error: new ASCApiError(UNSYNCED_OBJECT_CACHED_AT_MESSAGE, 800800 /* Amity.ClientError.DISALOOW_UNSYNCED_OBJECT */, "error" /* Amity.ErrorLevel.ERROR */),
|
|
38334
|
-
});
|
|
38335
|
-
isUnsyncedModel = true;
|
|
38336
|
-
disposers.forEach(fn => fn());
|
|
38337
|
-
}
|
|
38338
|
-
else if (!isUnsyncedModel) {
|
|
38339
|
-
dispatcher({ loading, data, origin, error });
|
|
38340
|
-
}
|
|
38341
|
-
if (error) {
|
|
38342
|
-
disposers.forEach(fn => fn());
|
|
38343
|
-
}
|
|
38344
|
-
});
|
|
38345
|
-
};
|
|
38346
|
-
disposers.push(onChannelUnreadUpdatedLocal(realtimeRouter));
|
|
38347
|
-
onFetch();
|
|
38348
|
-
return () => {
|
|
38349
|
-
disposers.forEach(fn => fn());
|
|
38350
|
-
};
|
|
38351
|
-
};
|
|
38352
|
-
|
|
38353
40336
|
/* begin_public_function
|
|
38354
40337
|
id: channel.member.add
|
|
38355
40338
|
*/
|
|
@@ -38481,7 +40464,9 @@ class ChannelMemberQueryStreamController extends QueryStreamController {
|
|
|
38481
40464
|
channelId: this.query.channelId,
|
|
38482
40465
|
userId: channelMember.userId,
|
|
38483
40466
|
});
|
|
38484
|
-
|
|
40467
|
+
const membershipFilter = this.query.memberships;
|
|
40468
|
+
const isInFilter = !membershipFilter || membershipFilter.includes(channelMember.membership);
|
|
40469
|
+
if (channelMember.membership === 'none' || !isInFilter) {
|
|
38485
40470
|
collection.data = collection.data.filter(m => m !== channelMemberCacheId);
|
|
38486
40471
|
}
|
|
38487
40472
|
else if (!collection.data.includes(channelMemberCacheId)) {
|
|
@@ -38817,6 +40802,7 @@ const banMembers$1 = async (channelId, userIds) => {
|
|
|
38817
40802
|
const cachedAt = client.cache && Date.now();
|
|
38818
40803
|
if (client.cache)
|
|
38819
40804
|
ingestInCache(preparedPayload, { cachedAt });
|
|
40805
|
+
fireEvent('channel.banned', payload);
|
|
38820
40806
|
return {
|
|
38821
40807
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'banned'),
|
|
38822
40808
|
cachedAt,
|
|
@@ -38851,6 +40837,7 @@ const unbanMembers$1 = async (channelId, userIds) => {
|
|
|
38851
40837
|
const cachedAt = client.cache && Date.now();
|
|
38852
40838
|
if (client.cache)
|
|
38853
40839
|
ingestInCache(preparedPayload, { cachedAt });
|
|
40840
|
+
fireEvent('channel.unbanned', payload);
|
|
38854
40841
|
const { channelUsers } = preparedPayload;
|
|
38855
40842
|
return {
|
|
38856
40843
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'member'),
|
|
@@ -38879,6 +40866,7 @@ const MUTE_FOREVER = -1;
|
|
|
38879
40866
|
* @async
|
|
38880
40867
|
* */
|
|
38881
40868
|
const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
40869
|
+
var _a;
|
|
38882
40870
|
const client = getActiveClient();
|
|
38883
40871
|
client.log('channel/muteMembers', { userIds, channelId, mutePeriod });
|
|
38884
40872
|
const { data } = await client.http.put(`/api/v2/channel/${channelId}/users/mute`, {
|
|
@@ -38886,6 +40874,15 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
38886
40874
|
mutePeriod: mutePeriod === MUTE_FOREVER ? mutePeriod : mutePeriod * 1000,
|
|
38887
40875
|
});
|
|
38888
40876
|
const { success } = data;
|
|
40877
|
+
const muteTimeout = mutePeriod === MUTE_FOREVER
|
|
40878
|
+
? new Date('9999-12-31T23:59:59.999Z').toISOString()
|
|
40879
|
+
: new Date(Date.now() + mutePeriod * 1000).toISOString();
|
|
40880
|
+
fireEvent('channel.setMutedUsers', {
|
|
40881
|
+
channelId,
|
|
40882
|
+
userIds,
|
|
40883
|
+
muteTimeout,
|
|
40884
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
40885
|
+
});
|
|
38889
40886
|
return success;
|
|
38890
40887
|
};
|
|
38891
40888
|
/* end_public_function */
|
|
@@ -38908,6 +40905,7 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
38908
40905
|
* @async
|
|
38909
40906
|
* */
|
|
38910
40907
|
const unmuteMembers = async (channelId, userIds) => {
|
|
40908
|
+
var _a;
|
|
38911
40909
|
const client = getActiveClient();
|
|
38912
40910
|
client.log('channel/unmuteMembers', { userIds, channelId });
|
|
38913
40911
|
const { data } = await client.http.put(`/api/v2/channel/${encodeURIComponent(channelId)}/users/mute`, {
|
|
@@ -38915,6 +40913,12 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
38915
40913
|
mutePeriod: 0,
|
|
38916
40914
|
});
|
|
38917
40915
|
const { success } = data;
|
|
40916
|
+
fireEvent('channel.setMutedUsers', {
|
|
40917
|
+
channelId,
|
|
40918
|
+
userIds,
|
|
40919
|
+
muteTimeout: new Date(0).toISOString(),
|
|
40920
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
40921
|
+
});
|
|
38918
40922
|
return success;
|
|
38919
40923
|
};
|
|
38920
40924
|
/* end_public_function */
|
|
@@ -38941,6 +40945,9 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38941
40945
|
leaveChannel: leaveChannel,
|
|
38942
40946
|
muteChannel: muteChannel,
|
|
38943
40947
|
unmuteChannel: unmuteChannel,
|
|
40948
|
+
archiveChannel: archiveChannel,
|
|
40949
|
+
unarchiveChannel: unarchiveChannel,
|
|
40950
|
+
getArchivedChannelIds: getArchivedChannelIds,
|
|
38944
40951
|
onChannelCreated: onChannelCreated,
|
|
38945
40952
|
onChannelUpdated: onChannelUpdated,
|
|
38946
40953
|
onChannelDeleted: onChannelDeleted,
|
|
@@ -38953,9 +40960,13 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38953
40960
|
onChannelMemberUnbanned: onChannelMemberUnbanned,
|
|
38954
40961
|
onChannelMemberRoleAdded: onChannelMemberRoleAdded,
|
|
38955
40962
|
onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
|
|
40963
|
+
onChannelArchived: onChannelArchived,
|
|
40964
|
+
onChannelUnarchived: onChannelUnarchived,
|
|
38956
40965
|
getChannel: getChannel,
|
|
38957
40966
|
getChannels: getChannels,
|
|
38958
40967
|
getTotalChannelsUnread: getTotalChannelsUnread,
|
|
40968
|
+
getArchivedChannels: getArchivedChannels,
|
|
40969
|
+
searchChannels: searchChannels,
|
|
38959
40970
|
MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
|
|
38960
40971
|
isUnreadCountSupport: isUnreadCountSupport,
|
|
38961
40972
|
convertFromRaw: convertFromRaw,
|
|
@@ -42851,7 +44862,7 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
42851
44862
|
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
42852
44863
|
}
|
|
42853
44864
|
startSubscription() {
|
|
42854
|
-
|
|
44865
|
+
const disposers = this.queryStreamController.subscribeRTE([
|
|
42855
44866
|
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
42856
44867
|
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
42857
44868
|
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
@@ -42864,6 +44875,11 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
42864
44875
|
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
42865
44876
|
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
42866
44877
|
]);
|
|
44878
|
+
if (this.query.excludeBlockUserComments) {
|
|
44879
|
+
const refresh = () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
44880
|
+
disposers.push(onUserDidBlock(refresh), onUserDidUnblock(refresh));
|
|
44881
|
+
}
|
|
44882
|
+
return disposers;
|
|
42867
44883
|
}
|
|
42868
44884
|
notifyChange({ origin, loading, error }) {
|
|
42869
44885
|
var _a, _b;
|
|
@@ -42916,6 +44932,9 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
42916
44932
|
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
42917
44933
|
}
|
|
42918
44934
|
}
|
|
44935
|
+
if (this.query.excludeBlockUserComments) {
|
|
44936
|
+
comments = filterCommentsByBlockUsers(comments);
|
|
44937
|
+
}
|
|
42919
44938
|
switch (this.query.sortBy) {
|
|
42920
44939
|
case 'firstCreated':
|
|
42921
44940
|
comments = comments.sort(sortByFirstCreated);
|
|
@@ -44001,13 +46020,253 @@ const getCommunityFeed = (params, callback, config) => {
|
|
|
44001
46020
|
};
|
|
44002
46021
|
/* end_public_function */
|
|
44003
46022
|
|
|
46023
|
+
/**
|
|
46024
|
+
* Thrown by `getForYouFeed` when the network has the For You feature
|
|
46025
|
+
* disabled. Mapped from HTTP 404 NOT_FOUND. Distinct from a generic
|
|
46026
|
+
* not-found so consumers can hide the For You tab without retrying.
|
|
46027
|
+
*
|
|
46028
|
+
* @category Errors
|
|
46029
|
+
*/
|
|
46030
|
+
class AmityForYouFeedDisabledError extends ASCApiError {
|
|
46031
|
+
constructor(message = 'For You feed is not enabled for this network') {
|
|
46032
|
+
super(message, 400400 /* Amity.ServerError.ITEM_NOT_FOUND */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
46033
|
+
this.type = 'AmityForYouFeedDisabledError';
|
|
46034
|
+
}
|
|
46035
|
+
}
|
|
46036
|
+
|
|
46037
|
+
class ForYouFeedPaginationController extends PaginationController {
|
|
46038
|
+
constructor(query) {
|
|
46039
|
+
super(query);
|
|
46040
|
+
this.checkedDisk = false;
|
|
46041
|
+
this.hasDeliveredPost = false;
|
|
46042
|
+
this.cursor = CursorController.current();
|
|
46043
|
+
}
|
|
46044
|
+
async getRequest(_queryParams, token) {
|
|
46045
|
+
var _a, _b, _c, _d, _e;
|
|
46046
|
+
const isFirstPage = token === undefined;
|
|
46047
|
+
let stored = null;
|
|
46048
|
+
// On the first page of a fresh collection, load the saved cursor from disk once.
|
|
46049
|
+
// Drop it if the snapshot has already expired so we start fresh.
|
|
46050
|
+
if (isFirstPage && !this.checkedDisk && this.cursor) {
|
|
46051
|
+
this.checkedDisk = true;
|
|
46052
|
+
stored = await this.cursor.get();
|
|
46053
|
+
if (stored && CursorController.isExpired(stored.expiredAt)) {
|
|
46054
|
+
await this.cursor.clear();
|
|
46055
|
+
stored = null;
|
|
46056
|
+
}
|
|
46057
|
+
}
|
|
46058
|
+
// Already paged to the end before. Ask the BE fresh (no cursor) and check if it's
|
|
46059
|
+
// still the same snapshot the user finished.
|
|
46060
|
+
if (isFirstPage && (stored === null || stored === void 0 ? void 0 : stored.reachedEndOfFeed)) {
|
|
46061
|
+
const fresh = await this.fetch();
|
|
46062
|
+
const freshExpiredAt = Date.parse((_b = (_a = fresh.paging) === null || _a === void 0 ? void 0 : _a.expiredAt) !== null && _b !== void 0 ? _b : '');
|
|
46063
|
+
const rolledOver = !Number.isNaN(freshExpiredAt) && freshExpiredAt !== stored.expiredAt;
|
|
46064
|
+
// New snapshot → serve it. Same snapshot → user has seen it all, show empty.
|
|
46065
|
+
if (rolledOver) {
|
|
46066
|
+
await this.persistCursor(fresh);
|
|
46067
|
+
if (fresh.posts.length > 0)
|
|
46068
|
+
this.hasDeliveredPost = true;
|
|
46069
|
+
return fresh;
|
|
46070
|
+
}
|
|
46071
|
+
return Object.assign(Object.assign({}, fresh), { posts: [], paging: {} });
|
|
46072
|
+
}
|
|
46073
|
+
// Resume from the saved cursor on re-entry; otherwise use the live-collection token.
|
|
46074
|
+
const effectiveToken = isFirstPage && stored ? stored.cursor : token;
|
|
46075
|
+
const response = await this.fetch(effectiveToken);
|
|
46076
|
+
if (response.posts.length > 0)
|
|
46077
|
+
this.hasDeliveredPost = true;
|
|
46078
|
+
if ((_c = response.paging) === null || _c === void 0 ? void 0 : _c.next) {
|
|
46079
|
+
// More pages left → advance the saved cursor.
|
|
46080
|
+
await this.persistCursor(response);
|
|
46081
|
+
}
|
|
46082
|
+
else if (this.hasDeliveredPost && this.cursor) {
|
|
46083
|
+
// Reached the end and mark end of feed
|
|
46084
|
+
const expiredAt = Date.parse((_e = (_d = response.paging) === null || _d === void 0 ? void 0 : _d.expiredAt) !== null && _e !== void 0 ? _e : '');
|
|
46085
|
+
if (!Number.isNaN(expiredAt))
|
|
46086
|
+
await this.cursor.markReachedEndOfFeed(expiredAt);
|
|
46087
|
+
}
|
|
46088
|
+
return response;
|
|
46089
|
+
}
|
|
46090
|
+
async fetch(token) {
|
|
46091
|
+
const options = { limit: COLLECTION_DEFAULT_PAGINATION_SIZE };
|
|
46092
|
+
if (token)
|
|
46093
|
+
options.token = token;
|
|
46094
|
+
try {
|
|
46095
|
+
const { data } = await this.http.get(API_ENDPOINTS.forYouFeed, {
|
|
46096
|
+
params: { options },
|
|
46097
|
+
});
|
|
46098
|
+
return data;
|
|
46099
|
+
}
|
|
46100
|
+
catch (error) {
|
|
46101
|
+
if (error instanceof ASCApiError && error.code === 400300 /* Amity.ServerError.FORBIDDEN */) {
|
|
46102
|
+
throw new AmityForYouFeedDisabledError();
|
|
46103
|
+
}
|
|
46104
|
+
const recoverable = error instanceof ASCApiError && error.code === 400322 /* Amity.ServerError.FEED_SNAPSHOT_EXPIRED */;
|
|
46105
|
+
if (recoverable && token !== undefined) {
|
|
46106
|
+
if (this.cursor)
|
|
46107
|
+
await this.cursor.clear();
|
|
46108
|
+
const { data } = await this.http.get(API_ENDPOINTS.forYouFeed, {
|
|
46109
|
+
params: { options: { limit: COLLECTION_DEFAULT_PAGINATION_SIZE } },
|
|
46110
|
+
});
|
|
46111
|
+
return data;
|
|
46112
|
+
}
|
|
46113
|
+
throw error;
|
|
46114
|
+
}
|
|
46115
|
+
}
|
|
46116
|
+
async persistCursor(response) {
|
|
46117
|
+
var _a, _b;
|
|
46118
|
+
if (!this.cursor)
|
|
46119
|
+
return;
|
|
46120
|
+
const cursor = (_a = response.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
46121
|
+
const expiredAtIso = (_b = response.paging) === null || _b === void 0 ? void 0 : _b.expiredAt;
|
|
46122
|
+
if (!cursor || !expiredAtIso)
|
|
46123
|
+
return;
|
|
46124
|
+
const expiredAt = Date.parse(expiredAtIso);
|
|
46125
|
+
if (Number.isNaN(expiredAt))
|
|
46126
|
+
return;
|
|
46127
|
+
await this.cursor.set({ cursor, expiredAt });
|
|
46128
|
+
}
|
|
46129
|
+
}
|
|
46130
|
+
|
|
46131
|
+
class ForYouFeedQueryStreamController extends QueryStreamController {
|
|
46132
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
46133
|
+
super(query, cacheKey);
|
|
46134
|
+
this.notifyChange = notifyChange;
|
|
46135
|
+
this.preparePayload = preparePayload;
|
|
46136
|
+
}
|
|
46137
|
+
async saveToMainDB(response) {
|
|
46138
|
+
const processedPayload = await this.preparePayload(response);
|
|
46139
|
+
const client = getActiveClient();
|
|
46140
|
+
const cachedAt = client.cache && Date.now();
|
|
46141
|
+
if (client.cache)
|
|
46142
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
46143
|
+
}
|
|
46144
|
+
appendToQueryStream(response, _direction, refresh = false) {
|
|
46145
|
+
var _a, _b;
|
|
46146
|
+
if (refresh) {
|
|
46147
|
+
pushToCache(this.cacheKey, {
|
|
46148
|
+
data: response.posts.map(getResolver('post')),
|
|
46149
|
+
});
|
|
46150
|
+
}
|
|
46151
|
+
else {
|
|
46152
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46153
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
46154
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
46155
|
+
}
|
|
46156
|
+
}
|
|
46157
|
+
reactor(action) {
|
|
46158
|
+
return (post) => {
|
|
46159
|
+
var _a;
|
|
46160
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46161
|
+
if (!collection)
|
|
46162
|
+
return;
|
|
46163
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
46164
|
+
return;
|
|
46165
|
+
if (action === EnumPostActions.OnPostDeleted || action === EnumPostActions.OnPostDeclined) {
|
|
46166
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
46167
|
+
}
|
|
46168
|
+
pushToCache(this.cacheKey, collection);
|
|
46169
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
46170
|
+
};
|
|
46171
|
+
}
|
|
46172
|
+
subscribeRTE(createSubscriber) {
|
|
46173
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
46174
|
+
}
|
|
46175
|
+
}
|
|
46176
|
+
|
|
46177
|
+
const FOR_YOU_FEED_CACHE_KEY = ['forYouFeed', 'collection'];
|
|
46178
|
+
class ForYouFeedLiveCollectionController extends LiveCollectionController {
|
|
46179
|
+
constructor(callback) {
|
|
46180
|
+
const queryStreamId = `for-you-feed-${getActiveClient().userId}`;
|
|
46181
|
+
const query = {};
|
|
46182
|
+
const paginationController = new ForYouFeedPaginationController(query);
|
|
46183
|
+
super(paginationController, queryStreamId, FOR_YOU_FEED_CACHE_KEY, callback);
|
|
46184
|
+
this.queryStreamController = new ForYouFeedQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
46185
|
+
this.callback = callback.bind(this);
|
|
46186
|
+
this.loadPage({ initial: true });
|
|
46187
|
+
}
|
|
46188
|
+
setup() {
|
|
46189
|
+
var _a;
|
|
46190
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46191
|
+
if (!collection)
|
|
46192
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
46193
|
+
}
|
|
46194
|
+
async persistModel(payload) {
|
|
46195
|
+
await this.queryStreamController.saveToMainDB(payload);
|
|
46196
|
+
}
|
|
46197
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
46198
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
46199
|
+
}
|
|
46200
|
+
startSubscription() {
|
|
46201
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
46202
|
+
}
|
|
46203
|
+
notifyChange({ origin, loading, error }) {
|
|
46204
|
+
var _a, _b;
|
|
46205
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46206
|
+
if (!collection)
|
|
46207
|
+
return;
|
|
46208
|
+
const data = ((_b = collection.data
|
|
46209
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
46210
|
+
.filter(isNonNullable)
|
|
46211
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
46212
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
46213
|
+
return;
|
|
46214
|
+
this.callback({
|
|
46215
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
46216
|
+
data,
|
|
46217
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
46218
|
+
loading,
|
|
46219
|
+
error,
|
|
46220
|
+
});
|
|
46221
|
+
}
|
|
46222
|
+
}
|
|
46223
|
+
|
|
46224
|
+
/* begin_public_function
|
|
46225
|
+
id: feed.query.for_you_feed
|
|
46226
|
+
*/
|
|
46227
|
+
/**
|
|
46228
|
+
* ```js
|
|
46229
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
46230
|
+
*
|
|
46231
|
+
* const unsub = FeedRepository.getForYouFeed(({ data, loading, error, hasNextPage, onNextPage }) => {
|
|
46232
|
+
* // render posts; call onNextPage() to load the next page (20 posts)
|
|
46233
|
+
* })
|
|
46234
|
+
* ```
|
|
46235
|
+
*
|
|
46236
|
+
* Observe the For You feed — a personalized, server-ranked
|
|
46237
|
+
* {@link Amity.LiveCollection} of {@link Amity.Post}.
|
|
46238
|
+
*
|
|
46239
|
+
* @param callback the function to call when new data is available
|
|
46240
|
+
* @returns an {@link Amity.Unsubscriber} function to stop observing
|
|
46241
|
+
*
|
|
46242
|
+
* @category Posts Live Collection
|
|
46243
|
+
*/
|
|
46244
|
+
const getForYouFeed = (callback) => {
|
|
46245
|
+
const { log, cache } = getActiveClient();
|
|
46246
|
+
if (!cache)
|
|
46247
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
46248
|
+
const timestamp = Date.now();
|
|
46249
|
+
log(`getForYouFeed(tmpid: ${timestamp}) > listen`);
|
|
46250
|
+
const forYouFeedLiveCollection = new ForYouFeedLiveCollectionController(callback);
|
|
46251
|
+
const disposers = forYouFeedLiveCollection.startSubscription();
|
|
46252
|
+
const cacheKey = forYouFeedLiveCollection.getCacheKey();
|
|
46253
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
46254
|
+
return () => {
|
|
46255
|
+
log(`getForYouFeed(tmpid: ${timestamp}) > dispose`);
|
|
46256
|
+
disposers.forEach(fn => fn());
|
|
46257
|
+
};
|
|
46258
|
+
};
|
|
46259
|
+
/* end_public_function */
|
|
46260
|
+
|
|
44004
46261
|
var index$d = /*#__PURE__*/Object.freeze({
|
|
44005
46262
|
__proto__: null,
|
|
44006
46263
|
queryGlobalFeed: queryGlobalFeed,
|
|
44007
46264
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
44008
46265
|
getGlobalFeed: getGlobalFeed,
|
|
44009
46266
|
getUserFeed: getUserFeed,
|
|
44010
|
-
getCommunityFeed: getCommunityFeed
|
|
46267
|
+
getCommunityFeed: getCommunityFeed,
|
|
46268
|
+
getForYouFeed: getForYouFeed,
|
|
46269
|
+
AmityForYouFeedDisabledError: AmityForYouFeedDisabledError
|
|
44011
46270
|
});
|
|
44012
46271
|
|
|
44013
46272
|
/* begin_public_function
|
|
@@ -45020,7 +47279,12 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
45020
47279
|
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
45021
47280
|
}
|
|
45022
47281
|
startSubscription() {
|
|
45023
|
-
|
|
47282
|
+
const disposers = this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
|
|
47283
|
+
if (this.query.excludeBlockUserPosts) {
|
|
47284
|
+
const refresh = () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
47285
|
+
disposers.push(onUserDidBlock(refresh), onUserDidUnblock(refresh));
|
|
47286
|
+
}
|
|
47287
|
+
return disposers;
|
|
45024
47288
|
}
|
|
45025
47289
|
notifyChange({ origin, loading, error }) {
|
|
45026
47290
|
var _a, _b;
|
|
@@ -45066,6 +47330,9 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
45066
47330
|
const sortBy = this.query.sortBy || 'lastCreated';
|
|
45067
47331
|
posts = posts.filter(post => !exceedsUntilAtBoundary(post.createdAt, validatedUntilAt, sortBy));
|
|
45068
47332
|
}
|
|
47333
|
+
if (this.query.excludeBlockUserPosts) {
|
|
47334
|
+
posts = filterPostsByBlockUsers(posts);
|
|
47335
|
+
}
|
|
45069
47336
|
switch (this.query.sortBy) {
|
|
45070
47337
|
case 'firstCreated':
|
|
45071
47338
|
posts = posts.sort(sortByFirstCreated);
|
|
@@ -51731,4 +53998,4 @@ class AmityAttachmentProductTags {
|
|
|
51731
53998
|
}
|
|
51732
53999
|
}
|
|
51733
54000
|
|
|
51734
|
-
export { API_REGIONS, index$5 as AdRepository, AmityAttachmentProductTags, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AnalyticsSourceTypeEnum, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$p as FileRepository, FileType, GET_WATCHER_URLS, index$3 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$2 as LiveReactionRepository, index$7 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$n as MessageRepository, index$8 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index as ProductRepository, index$o as ReactionRepository, index$9 as RoomPresenceRepository, index$c as RoomRepository, SearchUsersByEnum, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, index$q as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$4 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
|
|
54001
|
+
export { API_REGIONS, index$5 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmitySharableContentType, AnalyticsSourceTypeEnum, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$p as FileRepository, FileType, GET_WATCHER_URLS, index$3 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$2 as LiveReactionRepository, index$7 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$n as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$8 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index as ProductRepository, index$o as ReactionRepository, index$9 as RoomPresenceRepository, index$c as RoomRepository, SearchUsersByEnum, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, index$q as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$4 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
|