@amityco/ts-sdk 7.22.0 → 7.22.1-002438d.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 +2 -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 +16 -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 +20 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +25 -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 +1 -0
- package/dist/channelRepository/observers/index.d.ts.map +1 -1
- 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/getShareableLinkConfiguration.d.ts +2 -2
- package/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -1
- package/dist/client/api/index.d.ts +4 -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 +17 -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 +12 -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 +2149 -355
- package/dist/index.esm.js +2146 -356
- 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,10 +22153,6 @@ getSubChannel$1.locally = (subChannelId) => {
|
|
|
21879
22153
|
};
|
|
21880
22154
|
};
|
|
21881
22155
|
|
|
21882
|
-
const convertDateStringToTimestamp = (dateString) => {
|
|
21883
|
-
return new Date(dateString).getTime();
|
|
21884
|
-
};
|
|
21885
|
-
|
|
21886
22156
|
const getMessagePreviewSetting$1 = async () => {
|
|
21887
22157
|
const client = getActiveClient();
|
|
21888
22158
|
return client.getMessagePreviewSetting(false);
|
|
@@ -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);
|
|
@@ -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
|
*/
|
|
@@ -23876,7 +24181,7 @@ class AnalyticsEventSyncer {
|
|
|
23876
24181
|
|
|
23877
24182
|
class AnalyticsEventCapturer {
|
|
23878
24183
|
constructor() {
|
|
23879
|
-
this._expireTime = 5 *
|
|
24184
|
+
this._expireTime = 5 * SECOND$1;
|
|
23880
24185
|
this._poolLimit = 1000;
|
|
23881
24186
|
this._recentViewed = {};
|
|
23882
24187
|
this._recentHighPriorityViewed = {};
|
|
@@ -23930,12 +24235,36 @@ class AnalyticsEventCapturer {
|
|
|
23930
24235
|
}
|
|
23931
24236
|
markPostAsViewed(postId) {
|
|
23932
24237
|
this.markAs({
|
|
23933
|
-
uniqueId: postId
|
|
24238
|
+
uniqueId: `post.${postId}`,
|
|
23934
24239
|
contentId: postId,
|
|
23935
24240
|
contentType: "post" /* Amity.AnalyticEventContentType.Post */,
|
|
23936
24241
|
activityType: "view" /* Amity.AnalyticEventActivityType.View */,
|
|
23937
24242
|
});
|
|
23938
24243
|
}
|
|
24244
|
+
markPostAsMeaningfullyViewed(postId, feedRenderPosition) {
|
|
24245
|
+
var _a;
|
|
24246
|
+
const cached = (_a = pullFromCache(['feedMetadata', 'get', postId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
24247
|
+
const metadata = {};
|
|
24248
|
+
if (feedRenderPosition !== undefined)
|
|
24249
|
+
metadata.feedRenderPosition = feedRenderPosition;
|
|
24250
|
+
if (cached) {
|
|
24251
|
+
metadata.feedSnapshotPosition = cached.feedSnapshotPosition;
|
|
24252
|
+
metadata.feedInjectionType = cached.feedInjectionType;
|
|
24253
|
+
metadata.feedRelevanceScore = cached.feedRelevanceScore;
|
|
24254
|
+
metadata.feedPopularityScore = cached.feedPopularityScore;
|
|
24255
|
+
metadata.feedFreshnessScore = cached.feedFreshnessScore;
|
|
24256
|
+
metadata.feedAffinityScore = cached.feedAffinityScore;
|
|
24257
|
+
metadata.feedFinalScore = cached.feedFinalScore;
|
|
24258
|
+
metadata.feedMmrPenalty = cached.feedMmrPenalty;
|
|
24259
|
+
}
|
|
24260
|
+
this.markAs({
|
|
24261
|
+
uniqueId: `post.${postId}.meaningfulView`,
|
|
24262
|
+
contentId: postId,
|
|
24263
|
+
contentType: "post" /* Amity.AnalyticEventContentType.Post */,
|
|
24264
|
+
activityType: "meaningfulView" /* Amity.AnalyticEventActivityType.MeaningfulView */,
|
|
24265
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
|
|
24266
|
+
});
|
|
24267
|
+
}
|
|
23939
24268
|
markStory(story, activityType) {
|
|
23940
24269
|
if (!story.expiresAt)
|
|
23941
24270
|
return;
|
|
@@ -24075,6 +24404,12 @@ class AnalyticsEngine {
|
|
|
24075
24404
|
this._eventCapturer.markPostAsViewed(postId);
|
|
24076
24405
|
}
|
|
24077
24406
|
}
|
|
24407
|
+
markPostAsMeaningfullyViewed(postId, feedRenderPosition) {
|
|
24408
|
+
if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
|
|
24409
|
+
this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
24410
|
+
this._eventCapturer.markPostAsMeaningfullyViewed(postId, feedRenderPosition);
|
|
24411
|
+
}
|
|
24412
|
+
}
|
|
24078
24413
|
markStoryAsViewed(story) {
|
|
24079
24414
|
if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
|
|
24080
24415
|
this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */ // For case token_expired, we assume token is expired and gonna re-connect soon
|
|
@@ -24126,13 +24461,13 @@ class AnalyticsEngine {
|
|
|
24126
24461
|
this._eventCapturer.resetAllBuckets();
|
|
24127
24462
|
}
|
|
24128
24463
|
}
|
|
24129
|
-
let instance$
|
|
24464
|
+
let instance$8;
|
|
24130
24465
|
var AnalyticsEngine$1 = {
|
|
24131
24466
|
getInstance: () => {
|
|
24132
|
-
if (!instance$
|
|
24133
|
-
instance$
|
|
24467
|
+
if (!instance$8) {
|
|
24468
|
+
instance$8 = new AnalyticsEngine();
|
|
24134
24469
|
}
|
|
24135
|
-
return instance$
|
|
24470
|
+
return instance$8;
|
|
24136
24471
|
},
|
|
24137
24472
|
};
|
|
24138
24473
|
|
|
@@ -24299,9 +24634,8 @@ class MessageReadReceiptSyncEngine {
|
|
|
24299
24634
|
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
24300
24635
|
const cacheKey = ['channelUnread', 'get', channelId];
|
|
24301
24636
|
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24302
|
-
if (
|
|
24303
|
-
channelUnread
|
|
24304
|
-
segment > channelUnread.readToSegment) {
|
|
24637
|
+
if (channelUnread &&
|
|
24638
|
+
(typeof channelUnread.readToSegment !== 'number' || segment > channelUnread.readToSegment)) {
|
|
24305
24639
|
channelUnread.readToSegment = segment;
|
|
24306
24640
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
24307
24641
|
pushToCache(cacheKey, channelUnread);
|
|
@@ -24360,12 +24694,12 @@ class MessageReadReceiptSyncEngine {
|
|
|
24360
24694
|
}
|
|
24361
24695
|
}
|
|
24362
24696
|
}
|
|
24363
|
-
let instance$
|
|
24697
|
+
let instance$7 = null;
|
|
24364
24698
|
var ReadReceiptSyncEngine = {
|
|
24365
24699
|
getInstance: () => {
|
|
24366
|
-
if (!instance$
|
|
24367
|
-
instance$
|
|
24368
|
-
return instance$
|
|
24700
|
+
if (!instance$7)
|
|
24701
|
+
instance$7 = new MessageReadReceiptSyncEngine();
|
|
24702
|
+
return instance$7;
|
|
24369
24703
|
},
|
|
24370
24704
|
};
|
|
24371
24705
|
|
|
@@ -24619,12 +24953,12 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
24619
24953
|
}
|
|
24620
24954
|
}
|
|
24621
24955
|
}
|
|
24622
|
-
let instance$
|
|
24956
|
+
let instance$6 = null;
|
|
24623
24957
|
var LegacyReadReceiptSyncEngine = {
|
|
24624
24958
|
getInstance: () => {
|
|
24625
|
-
if (!instance$
|
|
24626
|
-
instance$
|
|
24627
|
-
return instance$
|
|
24959
|
+
if (!instance$6)
|
|
24960
|
+
instance$6 = new LegacyMessageReadReceiptSyncEngine();
|
|
24961
|
+
return instance$6;
|
|
24628
24962
|
},
|
|
24629
24963
|
};
|
|
24630
24964
|
|
|
@@ -24870,12 +25204,12 @@ class ObjectResolverEngine {
|
|
|
24870
25204
|
this.stopResolver();
|
|
24871
25205
|
}
|
|
24872
25206
|
}
|
|
24873
|
-
let instance$
|
|
25207
|
+
let instance$5 = null;
|
|
24874
25208
|
var ObjectResolverEngine$1 = {
|
|
24875
25209
|
getInstance: () => {
|
|
24876
|
-
if (!instance$
|
|
24877
|
-
instance$
|
|
24878
|
-
return instance$
|
|
25210
|
+
if (!instance$5)
|
|
25211
|
+
instance$5 = new ObjectResolverEngine();
|
|
25212
|
+
return instance$5;
|
|
24879
25213
|
},
|
|
24880
25214
|
};
|
|
24881
25215
|
|
|
@@ -25025,13 +25359,13 @@ class LiveReactionSyncEngine {
|
|
|
25025
25359
|
this.stopReactionsSync();
|
|
25026
25360
|
}
|
|
25027
25361
|
}
|
|
25028
|
-
let instance$
|
|
25362
|
+
let instance$4;
|
|
25029
25363
|
var ReactionSyncEngine = {
|
|
25030
25364
|
getInstance: () => {
|
|
25031
|
-
if (!instance$
|
|
25032
|
-
instance$
|
|
25365
|
+
if (!instance$4) {
|
|
25366
|
+
instance$4 = new LiveReactionSyncEngine();
|
|
25033
25367
|
}
|
|
25034
|
-
return instance$
|
|
25368
|
+
return instance$4;
|
|
25035
25369
|
},
|
|
25036
25370
|
};
|
|
25037
25371
|
|
|
@@ -25061,19 +25395,20 @@ function prepareBlockedUserPayload(response) {
|
|
|
25061
25395
|
}), users: users.map(convertRawUserToInternalUser) });
|
|
25062
25396
|
}
|
|
25063
25397
|
|
|
25064
|
-
const BLOCK_LIST_LIMIT = 100;
|
|
25065
|
-
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
25398
|
+
const BLOCK_LIST_LIMIT$1 = 100;
|
|
25399
|
+
const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
|
|
25066
25400
|
/**
|
|
25067
25401
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
25068
25402
|
* of blocked users. Provides a lazy `ensureFetched()` gate for the
|
|
25069
25403
|
* `getAllBlockedUsers()` API.
|
|
25070
25404
|
*
|
|
25071
25405
|
* Key behaviours:
|
|
25072
|
-
* - `
|
|
25073
|
-
* - `
|
|
25406
|
+
* - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
|
|
25407
|
+
* - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
|
|
25074
25408
|
* - `ensureFetched()` fetches from server only when cache is expired or never fetched
|
|
25075
25409
|
* - `lastFetchedAt` is only updated on successful fetch
|
|
25076
|
-
* -
|
|
25410
|
+
* - reads query the follow cache live, so block/unblock changes are reflected
|
|
25411
|
+
* even within the TTL window
|
|
25077
25412
|
*
|
|
25078
25413
|
* @internal
|
|
25079
25414
|
*/
|
|
@@ -25081,12 +25416,7 @@ class BlockedUserSyncEngine {
|
|
|
25081
25416
|
constructor() {
|
|
25082
25417
|
/** Epoch ms of last successful fetch. null = never fetched in this session. */
|
|
25083
25418
|
this.lastFetchedAt = null;
|
|
25084
|
-
/** Ordered list of userId strings from the most recent successful fetch. */
|
|
25085
|
-
this.blockedUserIds = [];
|
|
25086
25419
|
}
|
|
25087
|
-
// ---------------------------------------------------------------------------
|
|
25088
|
-
// SessionComponent lifecycle
|
|
25089
|
-
// ---------------------------------------------------------------------------
|
|
25090
25420
|
/** No-op — fetch is lazy, triggered by consumer calling getAllBlockedUsers(). */
|
|
25091
25421
|
// eslint-disable-next-line class-methods-use-this
|
|
25092
25422
|
onSessionEstablished() {
|
|
@@ -25095,24 +25425,17 @@ class BlockedUserSyncEngine {
|
|
|
25095
25425
|
/** Resets state so the next session starts with a cold cache. */
|
|
25096
25426
|
onSessionDestroyed() {
|
|
25097
25427
|
this.lastFetchedAt = null;
|
|
25098
|
-
this.blockedUserIds = [];
|
|
25099
25428
|
}
|
|
25100
25429
|
/** No-op for this engine. */
|
|
25101
25430
|
// eslint-disable-next-line class-methods-use-this
|
|
25102
25431
|
onTokenExpired() {
|
|
25103
25432
|
// intentionally empty
|
|
25104
25433
|
}
|
|
25105
|
-
// ---------------------------------------------------------------------------
|
|
25106
|
-
// Cache helpers
|
|
25107
|
-
// ---------------------------------------------------------------------------
|
|
25108
25434
|
isCacheExpired() {
|
|
25109
25435
|
if (this.lastFetchedAt === null)
|
|
25110
25436
|
return true;
|
|
25111
|
-
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
25437
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$1;
|
|
25112
25438
|
}
|
|
25113
|
-
// ---------------------------------------------------------------------------
|
|
25114
|
-
// Core fetch gate
|
|
25115
|
-
// ---------------------------------------------------------------------------
|
|
25116
25439
|
/**
|
|
25117
25440
|
* Ensures the local store is populated with fresh blocked-user data.
|
|
25118
25441
|
*
|
|
@@ -25128,52 +25451,50 @@ class BlockedUserSyncEngine {
|
|
|
25128
25451
|
if (!this.isCacheExpired())
|
|
25129
25452
|
return;
|
|
25130
25453
|
const client = getActiveClient();
|
|
25131
|
-
const { data } = await client.http.get('/api/v4/me/user-blocks', { params: { options: { limit: BLOCK_LIST_LIMIT }, isDeleted: false } });
|
|
25454
|
+
const { data } = await client.http.get('/api/v4/me/user-blocks', { params: { options: { limit: BLOCK_LIST_LIMIT$1 }, isDeleted: false } });
|
|
25132
25455
|
const cachedAt = client.cache && Date.now();
|
|
25133
25456
|
const payload = prepareBlockedUserPayload(data);
|
|
25134
25457
|
if (client.cache) {
|
|
25135
25458
|
ingestInCache(payload, { cachedAt });
|
|
25136
25459
|
}
|
|
25137
|
-
// Keep the ordered list of blocked user IDs for getCachedUsers()
|
|
25138
|
-
this.blockedUserIds = payload.users.map(u => u.userId);
|
|
25139
25460
|
// Only update timestamp on success — failure leaves it unchanged so the
|
|
25140
25461
|
// next call retries.
|
|
25141
25462
|
this.lastFetchedAt = Date.now();
|
|
25142
25463
|
}
|
|
25143
|
-
// ---------------------------------------------------------------------------
|
|
25144
|
-
// Local store read
|
|
25145
|
-
// ---------------------------------------------------------------------------
|
|
25146
25464
|
/**
|
|
25147
|
-
* Returns blocked
|
|
25148
|
-
*
|
|
25149
|
-
*
|
|
25150
|
-
*
|
|
25151
|
-
* - Hard limit of 100 results
|
|
25465
|
+
* Returns the blocked users by querying the follow cache live — the outgoing
|
|
25466
|
+
* direction (`from === me`, `status === 'blocked'`). Reading the cache (not a
|
|
25467
|
+
* fetched snapshot) means `blockUser()` / `unblockUser()` changes are reflected
|
|
25468
|
+
* even within the TTL window.
|
|
25152
25469
|
*
|
|
25153
|
-
*
|
|
25154
|
-
*
|
|
25470
|
+
* Applies the spec-mandated query:
|
|
25471
|
+
* - filter `from === currentUserId`, `status === 'blocked'`, blocked user not deleted
|
|
25472
|
+
* - sort by `updatedAt` DESC
|
|
25473
|
+
* - hard limit of 100 results
|
|
25155
25474
|
*/
|
|
25475
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25156
25476
|
getCachedUsers() {
|
|
25477
|
+
var _a;
|
|
25157
25478
|
const client = getActiveClient();
|
|
25158
|
-
if (!client.cache)
|
|
25159
|
-
// No cache available — fall back to the in-memory list from the last fetch
|
|
25479
|
+
if (!client.cache)
|
|
25160
25480
|
return [];
|
|
25161
|
-
}
|
|
25162
|
-
return
|
|
25163
|
-
.map(
|
|
25481
|
+
const { userId } = client;
|
|
25482
|
+
return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
|
|
25483
|
+
.map(entry => entry.data)
|
|
25484
|
+
.filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && follow.from === userId)
|
|
25485
|
+
.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); })
|
|
25486
|
+
.map(follow => { var _a; return (_a = pullFromCache(['user', 'get', follow.to])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
25164
25487
|
.filter((user) => user != null && user.isDeleted !== true)
|
|
25165
|
-
.slice(0, BLOCK_LIST_LIMIT)
|
|
25488
|
+
.slice(0, BLOCK_LIST_LIMIT$1)
|
|
25489
|
+
.map(userLinkedObject);
|
|
25166
25490
|
}
|
|
25167
25491
|
}
|
|
25168
|
-
|
|
25169
|
-
// Module-level singleton
|
|
25170
|
-
// ---------------------------------------------------------------------------
|
|
25171
|
-
let instance$2 = null;
|
|
25492
|
+
let instance$3 = null;
|
|
25172
25493
|
var BlockedUserSyncEngine$1 = {
|
|
25173
25494
|
getInstance: () => {
|
|
25174
|
-
if (!instance$
|
|
25175
|
-
instance$
|
|
25176
|
-
return instance$
|
|
25495
|
+
if (!instance$3)
|
|
25496
|
+
instance$3 = new BlockedUserSyncEngine();
|
|
25497
|
+
return instance$3;
|
|
25177
25498
|
},
|
|
25178
25499
|
};
|
|
25179
25500
|
|
|
@@ -25195,6 +25516,277 @@ var blockedUserSyncEngineOnLoginHandler = () => {
|
|
|
25195
25516
|
};
|
|
25196
25517
|
};
|
|
25197
25518
|
|
|
25519
|
+
function prepareBlockingUserPayload(response) {
|
|
25520
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
25521
|
+
return Object.assign(Object.assign({}, rest), { follows: follows.map(follow => {
|
|
25522
|
+
const followUser = users.find(user => user.userId === follow.from);
|
|
25523
|
+
return Object.assign(Object.assign({}, follow), { user: convertRawUserToInternalUser(followUser) });
|
|
25524
|
+
}), users: users.map(convertRawUserToInternalUser) });
|
|
25525
|
+
}
|
|
25526
|
+
|
|
25527
|
+
const BLOCK_LIST_LIMIT = 100;
|
|
25528
|
+
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
25529
|
+
/**
|
|
25530
|
+
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
25531
|
+
* of blocking users (the "blocked-by" list — users who blocked the current
|
|
25532
|
+
* user). Provides a lazy `ensureFetched()` gate for the `getAllBlockingUsers()`
|
|
25533
|
+
* API. Directional inverse of {@link BlockedUserSyncEngine}.
|
|
25534
|
+
*
|
|
25535
|
+
* Key behaviours:
|
|
25536
|
+
* - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
|
|
25537
|
+
* - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
|
|
25538
|
+
* - `ensureFetched()` fetches from server only when cache is expired or never fetched
|
|
25539
|
+
* - `lastFetchedAt` is only updated on successful fetch
|
|
25540
|
+
* - reads query the follow cache live, so block/unblock changes are reflected
|
|
25541
|
+
* even within the TTL window
|
|
25542
|
+
*
|
|
25543
|
+
* @internal
|
|
25544
|
+
*/
|
|
25545
|
+
class BlockingUserSyncEngine {
|
|
25546
|
+
constructor() {
|
|
25547
|
+
/** Epoch ms of last successful fetch. null = never fetched in this session. */
|
|
25548
|
+
this.lastFetchedAt = null;
|
|
25549
|
+
}
|
|
25550
|
+
/** No-op — fetch is lazy, triggered by consumer calling getAllBlockingUsers(). */
|
|
25551
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25552
|
+
onSessionEstablished() {
|
|
25553
|
+
// intentionally empty
|
|
25554
|
+
}
|
|
25555
|
+
/** Resets state so the next session starts with a cold cache. */
|
|
25556
|
+
onSessionDestroyed() {
|
|
25557
|
+
this.lastFetchedAt = null;
|
|
25558
|
+
}
|
|
25559
|
+
/** No-op for this engine. */
|
|
25560
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25561
|
+
onTokenExpired() {
|
|
25562
|
+
// intentionally empty
|
|
25563
|
+
}
|
|
25564
|
+
isCacheExpired() {
|
|
25565
|
+
if (this.lastFetchedAt === null)
|
|
25566
|
+
return true;
|
|
25567
|
+
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
25568
|
+
}
|
|
25569
|
+
/**
|
|
25570
|
+
* Ensures the local store is populated with fresh blocking-user data.
|
|
25571
|
+
*
|
|
25572
|
+
* - If the cache is still within the 5-minute TTL window: resolves immediately
|
|
25573
|
+
* (no server call).
|
|
25574
|
+
* - If the cache is expired (or never fetched): fetches from the server,
|
|
25575
|
+
* persists the payload to the cache, and updates `lastFetchedAt`.
|
|
25576
|
+
*
|
|
25577
|
+
* On failure the error propagates to the caller and `lastFetchedAt` is NOT
|
|
25578
|
+
* updated, so the next call will retry.
|
|
25579
|
+
*/
|
|
25580
|
+
async ensureFetched() {
|
|
25581
|
+
if (!this.isCacheExpired())
|
|
25582
|
+
return;
|
|
25583
|
+
const client = getActiveClient();
|
|
25584
|
+
const { data } = await client.http.get('/api/v4/me/blockers', { params: { options: { limit: BLOCK_LIST_LIMIT }, isDeleted: false } });
|
|
25585
|
+
const cachedAt = client.cache && Date.now();
|
|
25586
|
+
const payload = prepareBlockingUserPayload(data);
|
|
25587
|
+
if (client.cache) {
|
|
25588
|
+
ingestInCache(payload, { cachedAt });
|
|
25589
|
+
}
|
|
25590
|
+
// Only update timestamp on success — failure leaves it unchanged so the
|
|
25591
|
+
// next call retries.
|
|
25592
|
+
this.lastFetchedAt = Date.now();
|
|
25593
|
+
}
|
|
25594
|
+
/**
|
|
25595
|
+
* Returns the "blocked-by" users by querying the follow cache live — the
|
|
25596
|
+
* incoming direction (`to === me`, `status === 'blocked'`). Reading the cache
|
|
25597
|
+
* (not a fetched snapshot) means RTE `user.didBlock` / `user.didUnblock`
|
|
25598
|
+
* changes are reflected even within the TTL window.
|
|
25599
|
+
*
|
|
25600
|
+
* Applies the spec-mandated query (REQ-012/013/014):
|
|
25601
|
+
* - filter `to === currentUserId`, `status === 'blocked'`, blocker not deleted
|
|
25602
|
+
* - sort by `updatedAt` DESC
|
|
25603
|
+
* - hard limit of 100 results
|
|
25604
|
+
*/
|
|
25605
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25606
|
+
getCachedUsers() {
|
|
25607
|
+
var _a;
|
|
25608
|
+
const client = getActiveClient();
|
|
25609
|
+
if (!client.cache)
|
|
25610
|
+
return [];
|
|
25611
|
+
const { userId } = client;
|
|
25612
|
+
return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
|
|
25613
|
+
.map(entry => entry.data)
|
|
25614
|
+
.filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && follow.to === userId)
|
|
25615
|
+
.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); })
|
|
25616
|
+
.map(follow => { var _a; return (_a = pullFromCache(['user', 'get', follow.from])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
25617
|
+
.filter((user) => user != null && user.isDeleted !== true)
|
|
25618
|
+
.slice(0, BLOCK_LIST_LIMIT)
|
|
25619
|
+
.map(userLinkedObject);
|
|
25620
|
+
}
|
|
25621
|
+
}
|
|
25622
|
+
let instance$2 = null;
|
|
25623
|
+
var BlockingUserSyncEngine$1 = {
|
|
25624
|
+
getInstance: () => {
|
|
25625
|
+
if (!instance$2)
|
|
25626
|
+
instance$2 = new BlockingUserSyncEngine();
|
|
25627
|
+
return instance$2;
|
|
25628
|
+
},
|
|
25629
|
+
};
|
|
25630
|
+
|
|
25631
|
+
var blockingUserSyncEngineOnLoginHandler = () => {
|
|
25632
|
+
const blockingUserSyncEngine = BlockingUserSyncEngine$1.getInstance();
|
|
25633
|
+
onSessionStateChange(state => {
|
|
25634
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
25635
|
+
blockingUserSyncEngine.onSessionEstablished();
|
|
25636
|
+
}
|
|
25637
|
+
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
25638
|
+
blockingUserSyncEngine.onTokenExpired();
|
|
25639
|
+
}
|
|
25640
|
+
else {
|
|
25641
|
+
blockingUserSyncEngine.onSessionDestroyed();
|
|
25642
|
+
}
|
|
25643
|
+
});
|
|
25644
|
+
return () => {
|
|
25645
|
+
blockingUserSyncEngine.onSessionDestroyed();
|
|
25646
|
+
};
|
|
25647
|
+
};
|
|
25648
|
+
|
|
25649
|
+
function prepareFollowersPayload(response) {
|
|
25650
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
25651
|
+
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
25652
|
+
}
|
|
25653
|
+
function prepareFollowingsPayload(response) {
|
|
25654
|
+
const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
|
|
25655
|
+
return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
|
|
25656
|
+
}
|
|
25657
|
+
function prepareFollowStatusPayload(response) {
|
|
25658
|
+
const { follows } = response, rest = __rest(response, ["follows"]);
|
|
25659
|
+
return Object.assign(Object.assign({}, rest), { follows });
|
|
25660
|
+
}
|
|
25661
|
+
|
|
25662
|
+
/**
|
|
25663
|
+
* Subscribes to a block MQTT event (`user.didBlock` / `user.didUnblock`),
|
|
25664
|
+
* ingests the carried `FollowersPayload` (follows + users) into the cache so
|
|
25665
|
+
* the block-relationship rows (`['follow', 'get', from#to]`) and user rows are
|
|
25666
|
+
* kept current, then forwards the affected {@link Amity.FollowStatus} to the
|
|
25667
|
+
* caller.
|
|
25668
|
+
*
|
|
25669
|
+
* @hidden
|
|
25670
|
+
*/
|
|
25671
|
+
const createBlockEventSubscriber = (event, callback) => {
|
|
25672
|
+
const client = getActiveClient();
|
|
25673
|
+
const filter = (data) => {
|
|
25674
|
+
const payload = prepareFollowersPayload(data);
|
|
25675
|
+
if (client.cache) {
|
|
25676
|
+
ingestInCache(payload);
|
|
25677
|
+
}
|
|
25678
|
+
callback(payload.follows[0]);
|
|
25679
|
+
};
|
|
25680
|
+
return createEventSubscriber(client, event, event, filter);
|
|
25681
|
+
};
|
|
25682
|
+
|
|
25683
|
+
/**
|
|
25684
|
+
* ```js
|
|
25685
|
+
* import { onUserDidBlock } from '@amityco/ts-sdk'
|
|
25686
|
+
* const dispose = onUserDidBlock(status => {
|
|
25687
|
+
* // ...
|
|
25688
|
+
* })
|
|
25689
|
+
* ```
|
|
25690
|
+
*
|
|
25691
|
+
* Fired when a block relationship is created in real time — either a user
|
|
25692
|
+
* blocks the current user (incoming) or the current user blocks someone on
|
|
25693
|
+
* another device (outgoing). The local block-relationship store is updated
|
|
25694
|
+
* before the callback runs.
|
|
25695
|
+
*
|
|
25696
|
+
* @param callback The function to call when the event was fired
|
|
25697
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
25698
|
+
*
|
|
25699
|
+
* @category Block Events
|
|
25700
|
+
*/
|
|
25701
|
+
const onUserDidBlock = (callback) => createBlockEventSubscriber('user.didBlock', callback);
|
|
25702
|
+
|
|
25703
|
+
/**
|
|
25704
|
+
* ```js
|
|
25705
|
+
* import { onUserDidUnblock } from '@amityco/ts-sdk'
|
|
25706
|
+
* const dispose = onUserDidUnblock(status => {
|
|
25707
|
+
* // ...
|
|
25708
|
+
* })
|
|
25709
|
+
* ```
|
|
25710
|
+
*
|
|
25711
|
+
* Fired when a block relationship is removed in real time — either a user
|
|
25712
|
+
* unblocks the current user (incoming) or the current user unblocks someone on
|
|
25713
|
+
* another device (outgoing). The local block-relationship store is updated
|
|
25714
|
+
* before the callback runs.
|
|
25715
|
+
*
|
|
25716
|
+
* @param callback The function to call when the event was fired
|
|
25717
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
25718
|
+
*
|
|
25719
|
+
* @category Block Events
|
|
25720
|
+
*/
|
|
25721
|
+
const onUserDidUnblock = (callback) => createBlockEventSubscriber('user.didUnblock', callback);
|
|
25722
|
+
|
|
25723
|
+
/**
|
|
25724
|
+
* Keeps the follow cache current for incoming/outgoing block changes for the
|
|
25725
|
+
* whole session — the ingest happens as a side effect inside
|
|
25726
|
+
* createBlockEventSubscriber, so the one-shot `getAllBlockedUsers()` /
|
|
25727
|
+
* `getAllBlockingUsers()` reflect RTE block/unblock within the TTL window.
|
|
25728
|
+
*
|
|
25729
|
+
* Registered via `setupLoginSubscriptions`; the returned unsubscriber is torn
|
|
25730
|
+
* down on logout.
|
|
25731
|
+
*/
|
|
25732
|
+
var blockRealtimeOnLoginHandler = () => {
|
|
25733
|
+
const disposers = [onUserDidBlock(() => { }), onUserDidUnblock(() => { })];
|
|
25734
|
+
return () => disposers.forEach(dispose => dispose());
|
|
25735
|
+
};
|
|
25736
|
+
|
|
25737
|
+
class CursorController {
|
|
25738
|
+
constructor(networkId, userId) {
|
|
25739
|
+
this.networkId = networkId;
|
|
25740
|
+
this.userId = userId;
|
|
25741
|
+
}
|
|
25742
|
+
static current() {
|
|
25743
|
+
try {
|
|
25744
|
+
const user = getCurrentUser();
|
|
25745
|
+
if (!user)
|
|
25746
|
+
return null;
|
|
25747
|
+
const networkId = getNetworkId(user);
|
|
25748
|
+
const { userId } = user;
|
|
25749
|
+
return networkId && userId ? new CursorController(networkId, userId) : null;
|
|
25750
|
+
}
|
|
25751
|
+
catch (_a) {
|
|
25752
|
+
return null;
|
|
25753
|
+
}
|
|
25754
|
+
}
|
|
25755
|
+
static isExpired(expiredAt) {
|
|
25756
|
+
return Date.now() >= expiredAt;
|
|
25757
|
+
}
|
|
25758
|
+
static clearOnLogout() {
|
|
25759
|
+
return onSessionStateChange(state => {
|
|
25760
|
+
var _a;
|
|
25761
|
+
if (state === "terminated" /* Amity.SessionStates.TERMINATED */)
|
|
25762
|
+
(_a = CursorController.current()) === null || _a === void 0 ? void 0 : _a.clear();
|
|
25763
|
+
});
|
|
25764
|
+
}
|
|
25765
|
+
get key() {
|
|
25766
|
+
return `amity:forYouFeed:cursor:${this.networkId}:${this.userId}`;
|
|
25767
|
+
}
|
|
25768
|
+
async get() {
|
|
25769
|
+
const raw = await getItem(this.key);
|
|
25770
|
+
if (!raw)
|
|
25771
|
+
return null;
|
|
25772
|
+
try {
|
|
25773
|
+
const parsed = JSON.parse(raw);
|
|
25774
|
+
if (typeof (parsed === null || parsed === void 0 ? void 0 : parsed.cursor) !== 'string' || typeof (parsed === null || parsed === void 0 ? void 0 : parsed.expiredAt) !== 'number')
|
|
25775
|
+
return null;
|
|
25776
|
+
return { cursor: parsed.cursor, expiredAt: parsed.expiredAt };
|
|
25777
|
+
}
|
|
25778
|
+
catch (_a) {
|
|
25779
|
+
return null;
|
|
25780
|
+
}
|
|
25781
|
+
}
|
|
25782
|
+
async set(value) {
|
|
25783
|
+
await setItem(this.key, JSON.stringify(value));
|
|
25784
|
+
}
|
|
25785
|
+
async clear() {
|
|
25786
|
+
await setItem(this.key, '');
|
|
25787
|
+
}
|
|
25788
|
+
}
|
|
25789
|
+
|
|
25198
25790
|
const EVENTS = [
|
|
25199
25791
|
'disconnected',
|
|
25200
25792
|
'error',
|
|
@@ -25384,7 +25976,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
|
|
|
25384
25976
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
25385
25977
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
25386
25978
|
// 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());
|
|
25979
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout());
|
|
25388
25980
|
if (client.useLegacyUnreadCount) {
|
|
25389
25981
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
25390
25982
|
}
|
|
@@ -26083,16 +26675,13 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
26083
26675
|
}
|
|
26084
26676
|
if (client.useLegacyUnreadCount) {
|
|
26085
26677
|
rawPayload.messages.forEach(message => {
|
|
26086
|
-
var _a, _b;
|
|
26678
|
+
var _a, _b, _c;
|
|
26087
26679
|
const channelUnread = (_a = pullFromCache([
|
|
26088
26680
|
'channelUnread',
|
|
26089
26681
|
'get',
|
|
26090
26682
|
message.channelId,
|
|
26091
26683
|
])) === 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')
|
|
26684
|
+
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
26096
26685
|
return;
|
|
26097
26686
|
const lastSegment = message.segment;
|
|
26098
26687
|
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
@@ -26104,7 +26693,8 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
26104
26693
|
const lastMentionedSegment = isMentionedInMessage
|
|
26105
26694
|
? message.segment
|
|
26106
26695
|
: channelUnread.lastMentionedSegment;
|
|
26107
|
-
const
|
|
26696
|
+
const readToSegment = (_c = channelUnread.readToSegment) !== null && _c !== void 0 ? _c : 0;
|
|
26697
|
+
const updatedChannelUnread = Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: Math.max(lastSegment - readToSegment, 0), lastMentionedSegment, isMentioned: typeof lastMentionedSegment === 'number' && readToSegment < lastMentionedSegment });
|
|
26108
26698
|
pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
|
|
26109
26699
|
fireEvent('local.channelUnread.updated', [updatedChannelUnread]);
|
|
26110
26700
|
});
|
|
@@ -26467,7 +27057,9 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
26467
27057
|
validateUrls,
|
|
26468
27058
|
validateTexts,
|
|
26469
27059
|
getFeedSettings,
|
|
27060
|
+
getCoreUserSettings,
|
|
26470
27061
|
getSocialSettings,
|
|
27062
|
+
getChatSettings,
|
|
26471
27063
|
getVisitorDeviceId: getDeviceId,
|
|
26472
27064
|
getMessagePreviewSetting,
|
|
26473
27065
|
use: () => setActiveClient(client),
|
|
@@ -26742,11 +27334,18 @@ const getLinkPreviewMetadata = async (url) => {
|
|
|
26742
27334
|
return data;
|
|
26743
27335
|
};
|
|
26744
27336
|
|
|
27337
|
+
const CONTENT_TYPE_CONFIG = {
|
|
27338
|
+
[AmitySharableContentType.POST]: { key: 'posts', placeholder: 'postId' },
|
|
27339
|
+
[AmitySharableContentType.COMMUNITY]: { key: 'communities', placeholder: 'communityId' },
|
|
27340
|
+
[AmitySharableContentType.USER]: { key: 'users', placeholder: 'userId' },
|
|
27341
|
+
[AmitySharableContentType.LIVESTREAM]: { key: 'livestream', placeholder: 'livestream' },
|
|
27342
|
+
[AmitySharableContentType.EVENT]: { key: 'events', placeholder: 'eventId' },
|
|
27343
|
+
};
|
|
26745
27344
|
/**
|
|
26746
27345
|
* ```js
|
|
26747
27346
|
* import Client from '@amityco/ts-sdk'
|
|
26748
|
-
* const
|
|
26749
|
-
* const
|
|
27347
|
+
* const config = await Client.getShareableLinkConfiguration()
|
|
27348
|
+
* const link = config.generateLink(AmitySharableContentType.EVENT, eventId)
|
|
26750
27349
|
* ```
|
|
26751
27350
|
*
|
|
26752
27351
|
* Fetches a {@link Amity.ShareableLinkConfiguration} object
|
|
@@ -26757,9 +27356,29 @@ const getLinkPreviewMetadata = async (url) => {
|
|
|
26757
27356
|
* @async
|
|
26758
27357
|
*/
|
|
26759
27358
|
const getShareableLinkConfiguration = async () => {
|
|
27359
|
+
var _a, _b;
|
|
26760
27360
|
const client = getActiveClient();
|
|
26761
27361
|
const { data } = await client.http.get(`/api/v3/network-settings/shareable-deep-links`);
|
|
26762
|
-
|
|
27362
|
+
const domain = (_a = data.domain) !== null && _a !== void 0 ? _a : '';
|
|
27363
|
+
const patterns = (_b = data.patterns) !== null && _b !== void 0 ? _b : {};
|
|
27364
|
+
return {
|
|
27365
|
+
domain,
|
|
27366
|
+
patterns,
|
|
27367
|
+
isEnabled(contentType) {
|
|
27368
|
+
const { key } = CONTENT_TYPE_CONFIG[contentType];
|
|
27369
|
+
return !!domain && !!patterns[key];
|
|
27370
|
+
},
|
|
27371
|
+
getPattern(contentType) {
|
|
27372
|
+
const { key } = CONTENT_TYPE_CONFIG[contentType];
|
|
27373
|
+
return patterns[key] || null;
|
|
27374
|
+
},
|
|
27375
|
+
generateLink(contentType, referenceId) {
|
|
27376
|
+
const { key, placeholder } = CONTENT_TYPE_CONFIG[contentType];
|
|
27377
|
+
if (!domain || !patterns[key])
|
|
27378
|
+
return null;
|
|
27379
|
+
return domain + patterns[key].replace(`{${placeholder}}`, referenceId);
|
|
27380
|
+
},
|
|
27381
|
+
};
|
|
26763
27382
|
};
|
|
26764
27383
|
|
|
26765
27384
|
/**
|
|
@@ -26950,6 +27569,205 @@ const setAccessTokenHandler = (accessTokenHandler) => {
|
|
|
26950
27569
|
client.accessTokenHandler = accessTokenHandler;
|
|
26951
27570
|
};
|
|
26952
27571
|
|
|
27572
|
+
function parseRolesFilter(listenFromRoleIds, ignoreFromRoleIds) {
|
|
27573
|
+
if (ignoreFromRoleIds && ignoreFromRoleIds.length > 0) {
|
|
27574
|
+
return { type: 'not', roleIds: ignoreFromRoleIds };
|
|
27575
|
+
}
|
|
27576
|
+
if (listenFromRoleIds && listenFromRoleIds.length > 0) {
|
|
27577
|
+
return { type: NotificationRolesFilterTypeEnum.ONLY, roleIds: listenFromRoleIds };
|
|
27578
|
+
}
|
|
27579
|
+
return { type: NotificationRolesFilterTypeEnum.ALL };
|
|
27580
|
+
}
|
|
27581
|
+
function serializeRolesFilter(rolesFilter) {
|
|
27582
|
+
if ((rolesFilter === null || rolesFilter === void 0 ? void 0 : rolesFilter.type) === NotificationRolesFilterTypeEnum.ONLY) {
|
|
27583
|
+
return { listenFromRoleIds: rolesFilter.roleIds };
|
|
27584
|
+
}
|
|
27585
|
+
return { listenFromRoleIds: [] };
|
|
27586
|
+
}
|
|
27587
|
+
class ChannelNotifications {
|
|
27588
|
+
constructor(channelId) {
|
|
27589
|
+
this.channelId = channelId;
|
|
27590
|
+
}
|
|
27591
|
+
async enable() {
|
|
27592
|
+
const client = getActiveClient();
|
|
27593
|
+
const body = {
|
|
27594
|
+
level: NotificationSettingsLevelEnum.CHANNEL,
|
|
27595
|
+
channelId: this.channelId,
|
|
27596
|
+
isPushNotifiable: true,
|
|
27597
|
+
};
|
|
27598
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27599
|
+
}
|
|
27600
|
+
async disable() {
|
|
27601
|
+
const client = getActiveClient();
|
|
27602
|
+
const body = {
|
|
27603
|
+
level: NotificationSettingsLevelEnum.CHANNEL,
|
|
27604
|
+
channelId: this.channelId,
|
|
27605
|
+
isPushNotifiable: false,
|
|
27606
|
+
};
|
|
27607
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27608
|
+
}
|
|
27609
|
+
async getSettings() {
|
|
27610
|
+
const client = getActiveClient();
|
|
27611
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.CHANNEL}&channelId=${encodeURIComponent(this.channelId)}`);
|
|
27612
|
+
return { isEnabled: data.isPushNotifiable };
|
|
27613
|
+
}
|
|
27614
|
+
}
|
|
27615
|
+
class UserNotifications {
|
|
27616
|
+
async enable(modules) {
|
|
27617
|
+
var _a;
|
|
27618
|
+
const client = getActiveClient();
|
|
27619
|
+
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 : [];
|
|
27620
|
+
const body = {
|
|
27621
|
+
level: NotificationSettingsLevelEnum.USER,
|
|
27622
|
+
isPushNotifiable: true,
|
|
27623
|
+
notifiableEvents,
|
|
27624
|
+
};
|
|
27625
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27626
|
+
}
|
|
27627
|
+
async disableAllNotifications() {
|
|
27628
|
+
const client = getActiveClient();
|
|
27629
|
+
const body = {
|
|
27630
|
+
level: NotificationSettingsLevelEnum.USER,
|
|
27631
|
+
isPushNotifiable: false,
|
|
27632
|
+
notifiableEvents: [],
|
|
27633
|
+
};
|
|
27634
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27635
|
+
}
|
|
27636
|
+
async getSettings() {
|
|
27637
|
+
var _a;
|
|
27638
|
+
const client = getActiveClient();
|
|
27639
|
+
const { data } = await client.http.get(`/api/v3/notification/setting?level=${NotificationSettingsLevelEnum.USER}`);
|
|
27640
|
+
const validModuleNames = Object.values(UserNotificationModuleNameEnum);
|
|
27641
|
+
const modules = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
27642
|
+
.filter(e => e.moduleName != null && validModuleNames.includes(e.moduleName))
|
|
27643
|
+
.map(e => ({
|
|
27644
|
+
moduleName: e.moduleName,
|
|
27645
|
+
isEnabled: e.isPushNotifiable,
|
|
27646
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
27647
|
+
}));
|
|
27648
|
+
return { isEnabled: data.isPushNotifiable, modules };
|
|
27649
|
+
}
|
|
27650
|
+
}
|
|
27651
|
+
class CommunityNotifications {
|
|
27652
|
+
constructor(communityId) {
|
|
27653
|
+
this.communityId = communityId;
|
|
27654
|
+
}
|
|
27655
|
+
async enable(events) {
|
|
27656
|
+
var _a;
|
|
27657
|
+
const client = getActiveClient();
|
|
27658
|
+
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 : [];
|
|
27659
|
+
const body = {
|
|
27660
|
+
level: NotificationSettingsLevelEnum.COMMUNITY,
|
|
27661
|
+
communityId: this.communityId,
|
|
27662
|
+
isPushNotifiable: true,
|
|
27663
|
+
notifiableEvents,
|
|
27664
|
+
};
|
|
27665
|
+
await client.http.post('/api/v3/notification/setting', body);
|
|
27666
|
+
}
|
|
27667
|
+
async disable() {
|
|
27668
|
+
const client = getActiveClient();
|
|
27669
|
+
const body = {
|
|
27670
|
+
level: NotificationSettingsLevelEnum.COMMUNITY,
|
|
27671
|
+
communityId: this.communityId,
|
|
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.COMMUNITY}&communityId=${encodeURIComponent(this.communityId)}`);
|
|
27681
|
+
const validEventNames = Object.values(CommunityNotificationEventNameEnum);
|
|
27682
|
+
const events = ((_a = data.notifiableEvents) !== null && _a !== void 0 ? _a : [])
|
|
27683
|
+
.filter(e => e.name != null && validEventNames.includes(e.name))
|
|
27684
|
+
.map(e => ({
|
|
27685
|
+
eventName: e.name,
|
|
27686
|
+
isEnabled: e.isPushNotifiable,
|
|
27687
|
+
isNetworkEnabled: e.isNetworkEnabled,
|
|
27688
|
+
rolesFilter: parseRolesFilter(e.listenFromRoleIds, e.ignoreFromRoleIds),
|
|
27689
|
+
}));
|
|
27690
|
+
return { isEnabled: data.isPushNotifiable, events };
|
|
27691
|
+
}
|
|
27692
|
+
}
|
|
27693
|
+
class Notifications {
|
|
27694
|
+
user() {
|
|
27695
|
+
return new UserNotifications();
|
|
27696
|
+
}
|
|
27697
|
+
community(communityId) {
|
|
27698
|
+
return new CommunityNotifications(communityId);
|
|
27699
|
+
}
|
|
27700
|
+
channel(channelId) {
|
|
27701
|
+
return new ChannelNotifications(channelId);
|
|
27702
|
+
}
|
|
27703
|
+
}
|
|
27704
|
+
const notifications = () => new Notifications();
|
|
27705
|
+
|
|
27706
|
+
/* begin_public_function
|
|
27707
|
+
id: client.enable_auto_subscriptions
|
|
27708
|
+
*/
|
|
27709
|
+
/**
|
|
27710
|
+
* ```js
|
|
27711
|
+
* import { Client, AmityAutoSubscription } from '@amityco/ts-sdk'
|
|
27712
|
+
* Client.enableAutoSubscriptions([AmityAutoSubscription.BLOCK])
|
|
27713
|
+
* ```
|
|
27714
|
+
*
|
|
27715
|
+
* Enables one or more managed auto-subscription handles. Managed handles are
|
|
27716
|
+
* re-applied on every (re)connect and ref-counted. All handles are on by
|
|
27717
|
+
* default; use this to re-enable handles previously turned off via
|
|
27718
|
+
* {@link disableAutoSubscriptions}. Synchronous fire-and-forget — the registry
|
|
27719
|
+
* updates immediately and the broker subscribe is retried on reconnect.
|
|
27720
|
+
*
|
|
27721
|
+
* @param features the {@link AmityAutoSubscription} handles to enable
|
|
27722
|
+
*
|
|
27723
|
+
* @category Client API
|
|
27724
|
+
*/
|
|
27725
|
+
const enableAutoSubscriptions = (features) => {
|
|
27726
|
+
const manager = getAutoSubscriptionManager();
|
|
27727
|
+
features.forEach(feature => manager.subscribe(feature));
|
|
27728
|
+
};
|
|
27729
|
+
/* end_public_function */
|
|
27730
|
+
/* begin_public_function
|
|
27731
|
+
id: client.disable_auto_subscriptions
|
|
27732
|
+
*/
|
|
27733
|
+
/**
|
|
27734
|
+
* ```js
|
|
27735
|
+
* import { Client, AmityAutoSubscription } from '@amityco/ts-sdk'
|
|
27736
|
+
* Client.disableAutoSubscriptions([AmityAutoSubscription.LIVESTREAM])
|
|
27737
|
+
* ```
|
|
27738
|
+
*
|
|
27739
|
+
* Disables one or more managed auto-subscription handles. The change persists
|
|
27740
|
+
* across reconnect (it is not silently re-enabled) until
|
|
27741
|
+
* {@link enableAutoSubscriptions} is called again. Synchronous fire-and-forget.
|
|
27742
|
+
*
|
|
27743
|
+
* @param features the {@link AmityAutoSubscription} handles to disable
|
|
27744
|
+
*
|
|
27745
|
+
* @category Client API
|
|
27746
|
+
*/
|
|
27747
|
+
const disableAutoSubscriptions = (features) => {
|
|
27748
|
+
const manager = getAutoSubscriptionManager();
|
|
27749
|
+
features.forEach(feature => manager.unsubscribe(feature));
|
|
27750
|
+
};
|
|
27751
|
+
/* end_public_function */
|
|
27752
|
+
/* begin_public_function
|
|
27753
|
+
id: client.auto_subscriptions
|
|
27754
|
+
*/
|
|
27755
|
+
/**
|
|
27756
|
+
* ```js
|
|
27757
|
+
* import { Client } from '@amityco/ts-sdk'
|
|
27758
|
+
* Client.autoSubscriptions().forEach(s => console.log(s.feature, s.isActive, s.topicCount))
|
|
27759
|
+
* ```
|
|
27760
|
+
*
|
|
27761
|
+
* Inspects the managed auto-subscription registry — each handle's `isActive`,
|
|
27762
|
+
* `isSystem`, and `topicCount`.
|
|
27763
|
+
*
|
|
27764
|
+
* @returns a snapshot of the managed subscription registry
|
|
27765
|
+
*
|
|
27766
|
+
* @category Client API
|
|
27767
|
+
*/
|
|
27768
|
+
const autoSubscriptions = () => getAutoSubscriptionManager().subscriptions();
|
|
27769
|
+
/* end_public_function */
|
|
27770
|
+
|
|
26953
27771
|
/**
|
|
26954
27772
|
* ```js
|
|
26955
27773
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk'
|
|
@@ -27330,6 +28148,12 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
27330
28148
|
getCurrentUserType: getCurrentUserType,
|
|
27331
28149
|
setCurrentUserType: setCurrentUserType,
|
|
27332
28150
|
setAccessTokenHandler: setAccessTokenHandler,
|
|
28151
|
+
getChatSettings: getChatSettings,
|
|
28152
|
+
getCoreUserSettings: getCoreUserSettings,
|
|
28153
|
+
notifications: notifications,
|
|
28154
|
+
enableAutoSubscriptions: enableAutoSubscriptions,
|
|
28155
|
+
disableAutoSubscriptions: disableAutoSubscriptions,
|
|
28156
|
+
autoSubscriptions: autoSubscriptions,
|
|
27333
28157
|
onConnectionError: onConnectionError,
|
|
27334
28158
|
onClientDisconnected: onClientDisconnected,
|
|
27335
28159
|
onClientBanned: onClientBanned,
|
|
@@ -27347,19 +28171,6 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
27347
28171
|
getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
|
|
27348
28172
|
});
|
|
27349
28173
|
|
|
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
28174
|
/* begin_public_function
|
|
27364
28175
|
id: user.relationship.block
|
|
27365
28176
|
*/
|
|
@@ -28537,6 +29348,8 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
28537
29348
|
__proto__: null,
|
|
28538
29349
|
blockUser: blockUser,
|
|
28539
29350
|
unBlockUser: unBlockUser,
|
|
29351
|
+
onUserDidBlock: onUserDidBlock,
|
|
29352
|
+
onUserDidUnblock: onUserDidUnblock,
|
|
28540
29353
|
follow: follow,
|
|
28541
29354
|
unfollow: unfollow,
|
|
28542
29355
|
acceptMyFollower: acceptMyFollower,
|
|
@@ -29366,7 +30179,7 @@ const getWatchSessionStorage = () => {
|
|
|
29366
30179
|
return storageInstance;
|
|
29367
30180
|
};
|
|
29368
30181
|
|
|
29369
|
-
const privateKey = "
|
|
30182
|
+
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
30183
|
/*
|
|
29371
30184
|
* The crypto algorithm used for importing key and signing string
|
|
29372
30185
|
*/
|
|
@@ -30688,6 +31501,10 @@ const postLinkedObject = (post) => {
|
|
|
30688
31501
|
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
30689
31502
|
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
30690
31503
|
},
|
|
31504
|
+
markAsMeaningfullyViewed: (feedRenderPosition) => {
|
|
31505
|
+
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
31506
|
+
analyticsEngineInstance.markPostAsMeaningfullyViewed(post.postId, feedRenderPosition);
|
|
31507
|
+
},
|
|
30691
31508
|
},
|
|
30692
31509
|
get productTags() {
|
|
30693
31510
|
var _a, _b;
|
|
@@ -30877,6 +31694,11 @@ const addReaction$1 = async (referenceType, referenceId, reactionName, reference
|
|
|
30877
31694
|
});
|
|
30878
31695
|
return true;
|
|
30879
31696
|
}
|
|
31697
|
+
if (referenceType === 'message') {
|
|
31698
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
31699
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
31700
|
+
return true;
|
|
31701
|
+
}
|
|
30880
31702
|
}
|
|
30881
31703
|
return true;
|
|
30882
31704
|
};
|
|
@@ -30955,7 +31777,7 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
30955
31777
|
return true;
|
|
30956
31778
|
}
|
|
30957
31779
|
if (referenceType === 'story') {
|
|
30958
|
-
fireEvent('local.story.
|
|
31780
|
+
fireEvent('local.story.reactionRemoved', {
|
|
30959
31781
|
story: updatedModel,
|
|
30960
31782
|
reactor: {
|
|
30961
31783
|
userId: client.userId,
|
|
@@ -30965,6 +31787,11 @@ const removeReaction$1 = async (referenceType, referenceId, reactionName, refere
|
|
|
30965
31787
|
});
|
|
30966
31788
|
return true;
|
|
30967
31789
|
}
|
|
31790
|
+
if (referenceType === 'message') {
|
|
31791
|
+
upsertInCache(['message', 'get', referenceId], updatedModel);
|
|
31792
|
+
fireEvent('local.message.updated', { messages: [updatedModel] });
|
|
31793
|
+
return true;
|
|
31794
|
+
}
|
|
30968
31795
|
}
|
|
30969
31796
|
return true;
|
|
30970
31797
|
};
|
|
@@ -31237,7 +32064,7 @@ const createEventResponseSubscriber = (event, callback) => {
|
|
|
31237
32064
|
const eventResponse = pullFromCache([
|
|
31238
32065
|
'eventResponse',
|
|
31239
32066
|
'get',
|
|
31240
|
-
|
|
32067
|
+
unpackedPayload.eventResponses[0].userId,
|
|
31241
32068
|
]);
|
|
31242
32069
|
callback(eventResponse.data);
|
|
31243
32070
|
}
|
|
@@ -31901,7 +32728,38 @@ const getAllBlockedUsers = async () => {
|
|
|
31901
32728
|
const engine = BlockedUserSyncEngine$1.getInstance();
|
|
31902
32729
|
// Ensure data is fetched (no-op if cache is fresh)
|
|
31903
32730
|
await engine.ensureFetched();
|
|
31904
|
-
|
|
32731
|
+
return engine.getCachedUsers();
|
|
32732
|
+
};
|
|
32733
|
+
/* end_public_function */
|
|
32734
|
+
|
|
32735
|
+
/* begin_public_function
|
|
32736
|
+
id: user.get_all_blocking_users
|
|
32737
|
+
*/
|
|
32738
|
+
/**
|
|
32739
|
+
* ```js
|
|
32740
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
32741
|
+
* const blockingUsers = await UserRepository.getAllBlockingUsers()
|
|
32742
|
+
* ```
|
|
32743
|
+
*
|
|
32744
|
+
* Returns all users who have blocked the current user
|
|
32745
|
+
* non-paginated list (limit 100) with TTL-based caching (5-minute window). Within the
|
|
32746
|
+
* TTL window, subsequent calls resolve instantly from the local store without any
|
|
32747
|
+
* server call. After the TTL expires, the next call triggers a fresh server fetch.
|
|
32748
|
+
*
|
|
32749
|
+
* The directional inverse of {@link getAllBlockedUsers}.
|
|
32750
|
+
*
|
|
32751
|
+
* @returns A promise that resolves to an array of blocking {@link Amity.User} objects
|
|
32752
|
+
*
|
|
32753
|
+
* @category Block API
|
|
32754
|
+
* @async
|
|
32755
|
+
*/
|
|
32756
|
+
const getAllBlockingUsers = async () => {
|
|
32757
|
+
const client = getActiveClient();
|
|
32758
|
+
client.log('user/getAllBlockingUsers');
|
|
32759
|
+
const engine = BlockingUserSyncEngine$1.getInstance();
|
|
32760
|
+
// Ensure data is fetched (no-op if cache is fresh)
|
|
32761
|
+
await engine.ensureFetched();
|
|
32762
|
+
// Read from the engine's bounded ID list — O(blocking users) not O(cache size)
|
|
31905
32763
|
return engine.getCachedUsers();
|
|
31906
32764
|
};
|
|
31907
32765
|
/* end_public_function */
|
|
@@ -32216,75 +33074,271 @@ class UserLiveCollectionController extends LiveCollectionController {
|
|
|
32216
33074
|
}
|
|
32217
33075
|
applyFilter(data) {
|
|
32218
33076
|
let users = data;
|
|
32219
|
-
const sortFn = (() => {
|
|
32220
|
-
switch (this.query.sortBy) {
|
|
32221
|
-
case 'firstCreated':
|
|
32222
|
-
return sortByFirstCreated;
|
|
32223
|
-
case 'lastCreated':
|
|
32224
|
-
return sortByLastCreated;
|
|
32225
|
-
default:
|
|
32226
|
-
return sortByLastCreated;
|
|
32227
|
-
}
|
|
32228
|
-
})();
|
|
32229
|
-
users = users.sort(sortFn);
|
|
32230
|
-
if (this.query.filter === 'flagged') {
|
|
32231
|
-
users = users.filter(user => !!user.hashFlag);
|
|
32232
|
-
}
|
|
33077
|
+
const sortFn = (() => {
|
|
33078
|
+
switch (this.query.sortBy) {
|
|
33079
|
+
case 'firstCreated':
|
|
33080
|
+
return sortByFirstCreated;
|
|
33081
|
+
case 'lastCreated':
|
|
33082
|
+
return sortByLastCreated;
|
|
33083
|
+
default:
|
|
33084
|
+
return sortByLastCreated;
|
|
33085
|
+
}
|
|
33086
|
+
})();
|
|
33087
|
+
users = users.sort(sortFn);
|
|
33088
|
+
if (this.query.filter === 'flagged') {
|
|
33089
|
+
users = users.filter(user => !!user.hashFlag);
|
|
33090
|
+
}
|
|
33091
|
+
users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
|
|
33092
|
+
return users;
|
|
33093
|
+
}
|
|
33094
|
+
}
|
|
33095
|
+
|
|
33096
|
+
/* begin_public_function
|
|
33097
|
+
id: user.query
|
|
33098
|
+
*/
|
|
33099
|
+
/**
|
|
33100
|
+
* ```js
|
|
33101
|
+
* import { liveUsers } from '@amityco/ts-sdk'
|
|
33102
|
+
*
|
|
33103
|
+
* let users = []
|
|
33104
|
+
* const unsub = liveUsers({}, response => merge(users, response.data))
|
|
33105
|
+
* ```
|
|
33106
|
+
*
|
|
33107
|
+
* Observe all mutations on a list of {@link Amity.User}s
|
|
33108
|
+
*
|
|
33109
|
+
* @param params for querying users
|
|
33110
|
+
* @param callback the function to call when new data are available
|
|
33111
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the users
|
|
33112
|
+
*
|
|
33113
|
+
* @category Category Live Collection
|
|
33114
|
+
*/
|
|
33115
|
+
const getUsers = (params, callback, config) => {
|
|
33116
|
+
const { log, cache } = getActiveClient();
|
|
33117
|
+
if (!cache) {
|
|
33118
|
+
// eslint-disable-next-line no-console
|
|
33119
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
33120
|
+
}
|
|
33121
|
+
const timestamp = Date.now();
|
|
33122
|
+
log(`liveUsers(tmpid: ${timestamp}) > listen`);
|
|
33123
|
+
const usersLiveCollection = new UserLiveCollectionController(params, callback);
|
|
33124
|
+
const disposers = usersLiveCollection.startSubscription();
|
|
33125
|
+
const cacheKey = usersLiveCollection.getCacheKey();
|
|
33126
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
33127
|
+
return () => {
|
|
33128
|
+
log(`liveUsers(tmpid: ${timestamp}) > dispose`);
|
|
33129
|
+
disposers.forEach(fn => fn());
|
|
33130
|
+
};
|
|
33131
|
+
};
|
|
33132
|
+
/* end_public_function */
|
|
33133
|
+
|
|
33134
|
+
class BlockedUserPaginationController extends PaginationController {
|
|
33135
|
+
async getRequest(queryParams, token) {
|
|
33136
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
33137
|
+
const options = token ? { token } : { limit };
|
|
33138
|
+
const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
|
|
33139
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
33140
|
+
});
|
|
33141
|
+
return queryResponse;
|
|
33142
|
+
}
|
|
33143
|
+
}
|
|
33144
|
+
|
|
33145
|
+
var EnumBlockActions;
|
|
33146
|
+
(function (EnumBlockActions) {
|
|
33147
|
+
EnumBlockActions["OnBlocked"] = "onBlocked";
|
|
33148
|
+
EnumBlockActions["OnUnblocked"] = "onUnblocked";
|
|
33149
|
+
})(EnumBlockActions || (EnumBlockActions = {}));
|
|
33150
|
+
|
|
33151
|
+
class BlockedUserQueryStreamController extends QueryStreamController {
|
|
33152
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
33153
|
+
super(query, cacheKey);
|
|
33154
|
+
this.notifyChange = notifyChange;
|
|
33155
|
+
this.preparePayload = preparePayload;
|
|
33156
|
+
}
|
|
33157
|
+
async saveToMainDB(response) {
|
|
33158
|
+
const processedPayload = await this.preparePayload(response);
|
|
33159
|
+
const client = getActiveClient();
|
|
33160
|
+
const cachedAt = client.cache && Date.now();
|
|
33161
|
+
if (client.cache) {
|
|
33162
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
33163
|
+
}
|
|
33164
|
+
}
|
|
33165
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
33166
|
+
var _a, _b;
|
|
33167
|
+
if (refresh) {
|
|
33168
|
+
pushToCache(this.cacheKey, {
|
|
33169
|
+
data: response.users.map(getResolver('user')),
|
|
33170
|
+
});
|
|
33171
|
+
}
|
|
33172
|
+
else {
|
|
33173
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33174
|
+
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
33175
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
|
|
33176
|
+
}
|
|
33177
|
+
}
|
|
33178
|
+
reactor(action) {
|
|
33179
|
+
return (targetUser) => {
|
|
33180
|
+
var _a, _b;
|
|
33181
|
+
const isRemoval = action === EnumFollowActions.OnFollowed || action === EnumBlockActions.OnUnblocked;
|
|
33182
|
+
const isAddition = action === EnumBlockActions.OnBlocked;
|
|
33183
|
+
if (isRemoval || isAddition) {
|
|
33184
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33185
|
+
const ids = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
33186
|
+
const data = isAddition
|
|
33187
|
+
? [...new Set([...ids, targetUser.userId])]
|
|
33188
|
+
: ids.filter(id => id !== targetUser.userId);
|
|
33189
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data }));
|
|
33190
|
+
}
|
|
33191
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
33192
|
+
};
|
|
33193
|
+
}
|
|
33194
|
+
subscribeRTE(createSubscriber) {
|
|
33195
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
33196
|
+
}
|
|
33197
|
+
}
|
|
33198
|
+
|
|
33199
|
+
const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
|
|
33200
|
+
var _a;
|
|
33201
|
+
if (!sourceModel) {
|
|
33202
|
+
return sourceModel;
|
|
33203
|
+
}
|
|
33204
|
+
const cacheKey = [destinationDomain, 'get', `${sourceModel[sourceModelProp]}`];
|
|
33205
|
+
const model = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33206
|
+
if (!model)
|
|
33207
|
+
return;
|
|
33208
|
+
return callback(model);
|
|
33209
|
+
});
|
|
33210
|
+
|
|
33211
|
+
class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
33212
|
+
constructor(query, callback) {
|
|
33213
|
+
const queryStreamId = hash(query);
|
|
33214
|
+
const cacheKey = ['blockedUsers', 'collection', queryStreamId];
|
|
33215
|
+
const paginationController = new BlockedUserPaginationController(query);
|
|
33216
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
33217
|
+
this.query = query;
|
|
33218
|
+
this.queryStreamController = new BlockedUserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareBlockedUserPayload);
|
|
33219
|
+
this.callback = callback.bind(this);
|
|
33220
|
+
this.loadPage({ initial: true });
|
|
33221
|
+
}
|
|
33222
|
+
setup() {
|
|
33223
|
+
var _a;
|
|
33224
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33225
|
+
if (!collection) {
|
|
33226
|
+
pushToCache(this.cacheKey, {
|
|
33227
|
+
data: [],
|
|
33228
|
+
params: {},
|
|
33229
|
+
});
|
|
33230
|
+
}
|
|
33231
|
+
}
|
|
33232
|
+
async persistModel(queryPayload) {
|
|
33233
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
33234
|
+
}
|
|
33235
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
33236
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
33237
|
+
}
|
|
33238
|
+
startSubscription() {
|
|
33239
|
+
return this.queryStreamController.subscribeRTE([
|
|
33240
|
+
{
|
|
33241
|
+
fn: onUserDeleted$2,
|
|
33242
|
+
action: EnumUserActions.OnUserDeleted,
|
|
33243
|
+
},
|
|
33244
|
+
{
|
|
33245
|
+
fn: convertEventPayload(onLocalUserFollowed, 'to', 'user'),
|
|
33246
|
+
action: EnumFollowActions.OnFollowed,
|
|
33247
|
+
},
|
|
33248
|
+
{
|
|
33249
|
+
fn: convertEventPayload(onUserFollowed, 'to', 'user'),
|
|
33250
|
+
action: EnumFollowActions.OnFollowed,
|
|
33251
|
+
},
|
|
33252
|
+
{
|
|
33253
|
+
fn: (reactor) => onUserDidBlock(status => {
|
|
33254
|
+
var _a;
|
|
33255
|
+
if (status.from !== getActiveClient().userId)
|
|
33256
|
+
return;
|
|
33257
|
+
const blocked = (_a = pullFromCache(['user', 'get', status.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33258
|
+
if (blocked)
|
|
33259
|
+
reactor(blocked);
|
|
33260
|
+
}),
|
|
33261
|
+
action: EnumBlockActions.OnBlocked,
|
|
33262
|
+
},
|
|
33263
|
+
{
|
|
33264
|
+
fn: (reactor) => onUserDidUnblock(status => {
|
|
33265
|
+
var _a;
|
|
33266
|
+
if (status.from !== getActiveClient().userId)
|
|
33267
|
+
return;
|
|
33268
|
+
const blocked = (_a = pullFromCache(['user', 'get', status.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33269
|
+
if (blocked)
|
|
33270
|
+
reactor(blocked);
|
|
33271
|
+
}),
|
|
33272
|
+
action: EnumBlockActions.OnUnblocked,
|
|
33273
|
+
},
|
|
33274
|
+
]);
|
|
33275
|
+
}
|
|
33276
|
+
notifyChange({ origin, loading, error }) {
|
|
33277
|
+
var _a, _b;
|
|
33278
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
33279
|
+
if (!collection)
|
|
33280
|
+
return;
|
|
33281
|
+
const data = this.applyFilter((_b = collection.data
|
|
33282
|
+
.map(id => pullFromCache(['user', 'get', id]))
|
|
33283
|
+
.filter(isNonNullable)
|
|
33284
|
+
.map(({ data }) => data)
|
|
33285
|
+
.map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
|
|
33286
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
33287
|
+
return;
|
|
33288
|
+
this.callback({
|
|
33289
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
33290
|
+
data,
|
|
33291
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
33292
|
+
loading,
|
|
33293
|
+
error,
|
|
33294
|
+
});
|
|
33295
|
+
}
|
|
33296
|
+
// eslint-disable-next-line class-methods-use-this
|
|
33297
|
+
applyFilter(data) {
|
|
33298
|
+
let users = data;
|
|
32233
33299
|
users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
|
|
32234
33300
|
return users;
|
|
32235
33301
|
}
|
|
32236
33302
|
}
|
|
32237
33303
|
|
|
32238
33304
|
/* begin_public_function
|
|
32239
|
-
id: user.
|
|
33305
|
+
id: user.get_blocked_users
|
|
32240
33306
|
*/
|
|
32241
33307
|
/**
|
|
32242
33308
|
* ```js
|
|
32243
|
-
* import {
|
|
32244
|
-
*
|
|
32245
|
-
* let users = []
|
|
32246
|
-
* const unsub = liveUsers({}, response => merge(users, response.data))
|
|
33309
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
33310
|
+
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
32247
33311
|
* ```
|
|
32248
33312
|
*
|
|
32249
|
-
*
|
|
33313
|
+
* Blocks a {@link Amity.User}
|
|
32250
33314
|
*
|
|
32251
|
-
* @param params
|
|
32252
|
-
* @param callback
|
|
32253
|
-
* @returns
|
|
33315
|
+
* @param params The params to get blocked {@link Amity.User}s
|
|
33316
|
+
* @param callback to recieve updates on unblocked {@link Amity.User}s
|
|
33317
|
+
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
32254
33318
|
*
|
|
32255
|
-
* @category
|
|
33319
|
+
* @category Post API
|
|
33320
|
+
* @async
|
|
32256
33321
|
*/
|
|
32257
|
-
const
|
|
33322
|
+
const getBlockedUsers = (params, callback, config) => {
|
|
32258
33323
|
const { log, cache } = getActiveClient();
|
|
32259
33324
|
if (!cache) {
|
|
32260
|
-
// eslint-disable-next-line no-console
|
|
32261
33325
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
32262
33326
|
}
|
|
32263
33327
|
const timestamp = Date.now();
|
|
32264
|
-
log(`
|
|
32265
|
-
const
|
|
32266
|
-
const disposers =
|
|
32267
|
-
const cacheKey =
|
|
33328
|
+
log(`getBlockedUsers(tmpid: ${timestamp}) > listen`);
|
|
33329
|
+
const blockedUserLiveCollection = new BlockedUserLiveCollectionController(params, callback);
|
|
33330
|
+
const disposers = blockedUserLiveCollection.startSubscription();
|
|
33331
|
+
const cacheKey = blockedUserLiveCollection.getCacheKey();
|
|
32268
33332
|
disposers.push(() => dropFromCache(cacheKey));
|
|
32269
33333
|
return () => {
|
|
32270
|
-
log(`
|
|
33334
|
+
log(`getBlockedUsers(tmpid: ${timestamp}) > dispose`);
|
|
32271
33335
|
disposers.forEach(fn => fn());
|
|
33336
|
+
dropFromCache(cacheKey);
|
|
32272
33337
|
};
|
|
32273
33338
|
};
|
|
32274
33339
|
/* end_public_function */
|
|
32275
33340
|
|
|
32276
|
-
class
|
|
32277
|
-
async getRequest(queryParams, token) {
|
|
32278
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
32279
|
-
const options = token ? { token } : { limit };
|
|
32280
|
-
const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
|
|
32281
|
-
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
32282
|
-
});
|
|
32283
|
-
return queryResponse;
|
|
32284
|
-
}
|
|
32285
|
-
}
|
|
32286
|
-
|
|
32287
|
-
class BlockedUserQueryStreamController extends QueryStreamController {
|
|
33341
|
+
class BlockingUserQueryStreamController extends QueryStreamController {
|
|
32288
33342
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
32289
33343
|
super(query, cacheKey);
|
|
32290
33344
|
this.notifyChange = notifyChange;
|
|
@@ -32312,12 +33366,16 @@ class BlockedUserQueryStreamController extends QueryStreamController {
|
|
|
32312
33366
|
}
|
|
32313
33367
|
}
|
|
32314
33368
|
reactor(action) {
|
|
32315
|
-
return (
|
|
32316
|
-
var _a;
|
|
32317
|
-
if (
|
|
33369
|
+
return (user) => {
|
|
33370
|
+
var _a, _b;
|
|
33371
|
+
if (user &&
|
|
33372
|
+
(action === EnumBlockActions.OnBlocked || action === EnumBlockActions.OnUnblocked)) {
|
|
32318
33373
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32319
|
-
const
|
|
32320
|
-
|
|
33374
|
+
const ids = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
33375
|
+
const data = action === EnumBlockActions.OnBlocked
|
|
33376
|
+
? [...new Set([...ids, user.userId])]
|
|
33377
|
+
: ids.filter(id => id !== user.userId);
|
|
33378
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data }));
|
|
32321
33379
|
}
|
|
32322
33380
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
32323
33381
|
};
|
|
@@ -32327,26 +33385,25 @@ class BlockedUserQueryStreamController extends QueryStreamController {
|
|
|
32327
33385
|
}
|
|
32328
33386
|
}
|
|
32329
33387
|
|
|
32330
|
-
|
|
32331
|
-
|
|
32332
|
-
|
|
32333
|
-
|
|
33388
|
+
class BlockingUserPaginationController extends PaginationController {
|
|
33389
|
+
async getRequest(queryParams, token) {
|
|
33390
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_SIZE } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
33391
|
+
const options = token ? { token } : { limit };
|
|
33392
|
+
const { data: queryResponse } = await this.http.get('/api/v4/me/blockers', {
|
|
33393
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
33394
|
+
});
|
|
33395
|
+
return queryResponse;
|
|
32334
33396
|
}
|
|
32335
|
-
|
|
32336
|
-
const model = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32337
|
-
if (!model)
|
|
32338
|
-
return;
|
|
32339
|
-
return callback(model);
|
|
32340
|
-
});
|
|
33397
|
+
}
|
|
32341
33398
|
|
|
32342
|
-
class
|
|
32343
|
-
constructor(
|
|
32344
|
-
const queryStreamId =
|
|
32345
|
-
const
|
|
32346
|
-
const
|
|
33399
|
+
class BlockingUserLiveCollectionController extends LiveCollectionController {
|
|
33400
|
+
constructor(callback) {
|
|
33401
|
+
const queryStreamId = `blocking-users-${getActiveClient().userId}`;
|
|
33402
|
+
const query = {};
|
|
33403
|
+
const cacheKey = ['blockingUsers', 'collection', queryStreamId];
|
|
33404
|
+
const paginationController = new BlockingUserPaginationController(query);
|
|
32347
33405
|
super(paginationController, queryStreamId, cacheKey, callback);
|
|
32348
|
-
this.
|
|
32349
|
-
this.queryStreamController = new BlockedUserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareBlockedUserPayload);
|
|
33406
|
+
this.queryStreamController = new BlockingUserQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this), prepareBlockingUserPayload);
|
|
32350
33407
|
this.callback = callback.bind(this);
|
|
32351
33408
|
this.loadPage({ initial: true });
|
|
32352
33409
|
}
|
|
@@ -32372,14 +33429,27 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
|
32372
33429
|
fn: onUserDeleted$2,
|
|
32373
33430
|
action: EnumUserActions.OnUserDeleted,
|
|
32374
33431
|
},
|
|
32375
|
-
// In the case of unblocking a user, we need to subscribe to the follow events
|
|
32376
33432
|
{
|
|
32377
|
-
fn:
|
|
32378
|
-
|
|
33433
|
+
fn: (reactor) => onUserDidBlock(status => {
|
|
33434
|
+
var _a;
|
|
33435
|
+
if (status.to !== getActiveClient().userId)
|
|
33436
|
+
return;
|
|
33437
|
+
const blocker = (_a = pullFromCache(['user', 'get', status.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33438
|
+
if (blocker)
|
|
33439
|
+
reactor(blocker);
|
|
33440
|
+
}),
|
|
33441
|
+
action: EnumBlockActions.OnBlocked,
|
|
32379
33442
|
},
|
|
32380
33443
|
{
|
|
32381
|
-
fn:
|
|
32382
|
-
|
|
33444
|
+
fn: (reactor) => onUserDidUnblock(status => {
|
|
33445
|
+
var _a;
|
|
33446
|
+
if (status.to !== getActiveClient().userId)
|
|
33447
|
+
return;
|
|
33448
|
+
const blocker = (_a = pullFromCache(['user', 'get', status.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
33449
|
+
if (blocker)
|
|
33450
|
+
reactor(blocker);
|
|
33451
|
+
}),
|
|
33452
|
+
action: EnumBlockActions.OnUnblocked,
|
|
32383
33453
|
},
|
|
32384
33454
|
]);
|
|
32385
33455
|
}
|
|
@@ -32403,7 +33473,6 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
|
32403
33473
|
error,
|
|
32404
33474
|
});
|
|
32405
33475
|
}
|
|
32406
|
-
// eslint-disable-next-line class-methods-use-this
|
|
32407
33476
|
applyFilter(data) {
|
|
32408
33477
|
let users = data;
|
|
32409
33478
|
users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
|
|
@@ -32412,36 +33481,35 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
|
32412
33481
|
}
|
|
32413
33482
|
|
|
32414
33483
|
/* begin_public_function
|
|
32415
|
-
id: user.
|
|
33484
|
+
id: user.get_blocking_users
|
|
32416
33485
|
*/
|
|
32417
33486
|
/**
|
|
32418
33487
|
* ```js
|
|
32419
33488
|
* import { UserRepository } from '@amityco/ts-sdk'
|
|
32420
|
-
* const
|
|
33489
|
+
* const unsubscribe = UserRepository.getBlockingUsers(({ data: users }) => {
|
|
33490
|
+
* console.log(users)
|
|
33491
|
+
* })
|
|
32421
33492
|
* ```
|
|
32422
33493
|
*
|
|
32423
|
-
*
|
|
33494
|
+
* Observe the {@link Amity.User}s who have blocked the current user
|
|
32424
33495
|
*
|
|
32425
|
-
* @param
|
|
32426
|
-
* @param callback to recieve updates on unblocked {@link Amity.User}s
|
|
33496
|
+
* @param callback to receive updates on the blocking {@link Amity.User}s
|
|
32427
33497
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
32428
33498
|
*
|
|
32429
|
-
* @category
|
|
32430
|
-
* @async
|
|
33499
|
+
* @category User API
|
|
32431
33500
|
*/
|
|
32432
|
-
const
|
|
33501
|
+
const getBlockingUsers = (callback) => {
|
|
32433
33502
|
const { log, cache } = getActiveClient();
|
|
32434
|
-
if (!cache)
|
|
33503
|
+
if (!cache)
|
|
32435
33504
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
32436
|
-
}
|
|
32437
33505
|
const timestamp = Date.now();
|
|
32438
|
-
log(`
|
|
32439
|
-
const
|
|
32440
|
-
const disposers =
|
|
32441
|
-
const cacheKey =
|
|
33506
|
+
log(`getBlockingUsers(tmpid: ${timestamp}) > listen`);
|
|
33507
|
+
const blockingUserLiveCollection = new BlockingUserLiveCollectionController(callback);
|
|
33508
|
+
const disposers = blockingUserLiveCollection.startSubscription();
|
|
33509
|
+
const cacheKey = blockingUserLiveCollection.getCacheKey();
|
|
32442
33510
|
disposers.push(() => dropFromCache(cacheKey));
|
|
32443
33511
|
return () => {
|
|
32444
|
-
log(`
|
|
33512
|
+
log(`getBlockingUsers(tmpid: ${timestamp}) > dispose`);
|
|
32445
33513
|
disposers.forEach(fn => fn());
|
|
32446
33514
|
dropFromCache(cacheKey);
|
|
32447
33515
|
};
|
|
@@ -32714,6 +33782,7 @@ var index$q = /*#__PURE__*/Object.freeze({
|
|
|
32714
33782
|
unflagUser: unflagUser,
|
|
32715
33783
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
32716
33784
|
getAllBlockedUsers: getAllBlockedUsers,
|
|
33785
|
+
getAllBlockingUsers: getAllBlockingUsers,
|
|
32717
33786
|
onUserUpdated: onUserUpdated,
|
|
32718
33787
|
onUserDeleted: onUserDeleted$2,
|
|
32719
33788
|
onUserFlagged: onUserFlagged,
|
|
@@ -32722,6 +33791,7 @@ var index$q = /*#__PURE__*/Object.freeze({
|
|
|
32722
33791
|
getUser: getUser,
|
|
32723
33792
|
getUsers: getUsers,
|
|
32724
33793
|
getBlockedUsers: getBlockedUsers,
|
|
33794
|
+
getBlockingUsers: getBlockingUsers,
|
|
32725
33795
|
searchUserByDisplayName: searchUserByDisplayName,
|
|
32726
33796
|
getReachedUsers: getReachedUsers,
|
|
32727
33797
|
get AmityUserSearchMatchType () { return AmityUserSearchMatchType; }
|
|
@@ -33888,7 +34958,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
33888
34958
|
return true;
|
|
33889
34959
|
}
|
|
33890
34960
|
if (referenceType === 'story') {
|
|
33891
|
-
fireEvent('local.story.
|
|
34961
|
+
fireEvent('local.story.reactionRemoved', {
|
|
33892
34962
|
story: updatedModel,
|
|
33893
34963
|
reactor: {
|
|
33894
34964
|
userId: client.userId,
|
|
@@ -35472,6 +36542,104 @@ const unmuteChannel = async (channelId) => {
|
|
|
35472
36542
|
};
|
|
35473
36543
|
/* end_public_function */
|
|
35474
36544
|
|
|
36545
|
+
/* begin_public_function
|
|
36546
|
+
id: channel.archive
|
|
36547
|
+
*/
|
|
36548
|
+
/**
|
|
36549
|
+
* ```js
|
|
36550
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
36551
|
+
* const success = await ChannelRepository.archiveChannel('foobar')
|
|
36552
|
+
* ```
|
|
36553
|
+
*
|
|
36554
|
+
* Archive a {@link Amity.Channel}.
|
|
36555
|
+
*
|
|
36556
|
+
* @param channelId The id of the {@link Amity.Channel} to archive
|
|
36557
|
+
* @returns A success boolean
|
|
36558
|
+
*
|
|
36559
|
+
* @category Channel API
|
|
36560
|
+
* @async
|
|
36561
|
+
*/
|
|
36562
|
+
const archiveChannel = async (channelId) => {
|
|
36563
|
+
const client = getActiveClient();
|
|
36564
|
+
client.log('channel/archiveChannel', channelId);
|
|
36565
|
+
await client.http.post(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
36566
|
+
const archive = {
|
|
36567
|
+
channelId,
|
|
36568
|
+
archivedAt: new Date().toISOString(),
|
|
36569
|
+
};
|
|
36570
|
+
if (client.cache) {
|
|
36571
|
+
pushToCache(['archivedChannel', 'get', getResolver('archivedChannel')(archive)], archive);
|
|
36572
|
+
}
|
|
36573
|
+
fireEvent('local.channel.archived', { archives: [archive] });
|
|
36574
|
+
};
|
|
36575
|
+
/* end_public_function */
|
|
36576
|
+
|
|
36577
|
+
/* begin_public_function
|
|
36578
|
+
id: channel.unarchive
|
|
36579
|
+
*/
|
|
36580
|
+
/**
|
|
36581
|
+
* ```js
|
|
36582
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
36583
|
+
* const success = await ChannelRepository.unarchiveChannel('foobar')
|
|
36584
|
+
* ```
|
|
36585
|
+
*
|
|
36586
|
+
* Unarchive a previously archived {@link Amity.Channel}.
|
|
36587
|
+
*
|
|
36588
|
+
* @param channelId The id of the {@link Amity.Channel} to unarchive
|
|
36589
|
+
* @returns A success boolean
|
|
36590
|
+
*
|
|
36591
|
+
* @category Channel API
|
|
36592
|
+
* @async
|
|
36593
|
+
*/
|
|
36594
|
+
const unarchiveChannel = async (channelId) => {
|
|
36595
|
+
var _a;
|
|
36596
|
+
const client = getActiveClient();
|
|
36597
|
+
client.log('channel/unarchiveChannel', channelId);
|
|
36598
|
+
await client.http.delete(`/api/v1/archives/channels/${encodeURIComponent(channelId)}`);
|
|
36599
|
+
const cached = (_a = pullFromCache(['archivedChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
36600
|
+
const archive = cached !== null && cached !== void 0 ? cached : {
|
|
36601
|
+
channelId,
|
|
36602
|
+
archivedAt: new Date().toISOString(),
|
|
36603
|
+
};
|
|
36604
|
+
if (client.cache) {
|
|
36605
|
+
dropFromCache(['archivedChannel', 'get', channelId], true);
|
|
36606
|
+
}
|
|
36607
|
+
fireEvent('local.channel.unarchived', { archives: [archive] });
|
|
36608
|
+
};
|
|
36609
|
+
/* end_public_function */
|
|
36610
|
+
|
|
36611
|
+
/* begin_public_function
|
|
36612
|
+
id: channel.archive.ids
|
|
36613
|
+
*/
|
|
36614
|
+
/**
|
|
36615
|
+
* ```js
|
|
36616
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
36617
|
+
* const ids = await ChannelRepository.getArchivedChannelIds()
|
|
36618
|
+
* ```
|
|
36619
|
+
*
|
|
36620
|
+
* @returns A list of archived channel ids sorted by `archivedAt` descending.
|
|
36621
|
+
*
|
|
36622
|
+
* @category Channel API
|
|
36623
|
+
* @async
|
|
36624
|
+
*/
|
|
36625
|
+
const getArchivedChannelIds = async () => {
|
|
36626
|
+
var _a;
|
|
36627
|
+
const client = getActiveClient();
|
|
36628
|
+
client.log('channel/getArchivedChannelIds');
|
|
36629
|
+
const { data: payload } = await client.http.get(`/api/v1/archives/channels`);
|
|
36630
|
+
const archives = (_a = payload.archives) !== null && _a !== void 0 ? _a : [];
|
|
36631
|
+
if (client.cache) {
|
|
36632
|
+
dropFromCache(['archivedChannel', 'get']);
|
|
36633
|
+
archives.forEach(archive => {
|
|
36634
|
+
if (!archive.channelId)
|
|
36635
|
+
return;
|
|
36636
|
+
pushToCache(['archivedChannel', 'get', archive.channelId], archive);
|
|
36637
|
+
});
|
|
36638
|
+
}
|
|
36639
|
+
return archives.map(entry => entry.channelId).filter(channelId => !!channelId);
|
|
36640
|
+
};
|
|
36641
|
+
/* end_public_function */
|
|
36642
|
+
|
|
35475
36643
|
/**
|
|
35476
36644
|
* ```js
|
|
35477
36645
|
* import { onMessageUpdated } from '@amityco/ts-sdk'
|
|
@@ -36850,6 +38018,160 @@ const getMessages = (params, callback, config) => {
|
|
|
36850
38018
|
};
|
|
36851
38019
|
/* end_public_function */
|
|
36852
38020
|
|
|
38021
|
+
class SearchMessagePaginationController extends PaginationController {
|
|
38022
|
+
async getRequest(queryParams, token) {
|
|
38023
|
+
const { query, exactMatch, channelId, messageFeedId, userIds, tags, types, sortBy, orderBy, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, } = queryParams;
|
|
38024
|
+
const options = token ? { token } : { limit, sortBy, orderBy };
|
|
38025
|
+
const { data: queryResponse } = await this.http.get(`/api/v2/search/messages`, {
|
|
38026
|
+
params: {
|
|
38027
|
+
query,
|
|
38028
|
+
exactMatch,
|
|
38029
|
+
channelId,
|
|
38030
|
+
messageFeedId,
|
|
38031
|
+
userIds,
|
|
38032
|
+
tags,
|
|
38033
|
+
types,
|
|
38034
|
+
options,
|
|
38035
|
+
},
|
|
38036
|
+
});
|
|
38037
|
+
return queryResponse;
|
|
38038
|
+
}
|
|
38039
|
+
}
|
|
38040
|
+
|
|
38041
|
+
class SearchMessageQueryStreamController extends QueryStreamController {
|
|
38042
|
+
constructor(query, cacheKey, notifyChange) {
|
|
38043
|
+
super(query, cacheKey);
|
|
38044
|
+
this.notifyChange = notifyChange;
|
|
38045
|
+
}
|
|
38046
|
+
async saveToMainDB(response) {
|
|
38047
|
+
var _a;
|
|
38048
|
+
const processedPayload = await prepareMessagePayload(response);
|
|
38049
|
+
const client = getActiveClient();
|
|
38050
|
+
const cachedAt = client.cache && Date.now();
|
|
38051
|
+
if (client.cache) {
|
|
38052
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
38053
|
+
if ((_a = response.channels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
38054
|
+
response.channels.forEach(channel => {
|
|
38055
|
+
pushToCache(['channel', 'get', channel.channelId], channel, { cachedAt });
|
|
38056
|
+
});
|
|
38057
|
+
}
|
|
38058
|
+
}
|
|
38059
|
+
}
|
|
38060
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
38061
|
+
var _a, _b;
|
|
38062
|
+
if (refresh) {
|
|
38063
|
+
pushToCache(this.cacheKey, {
|
|
38064
|
+
data: response.messages.map(getResolver('message')),
|
|
38065
|
+
});
|
|
38066
|
+
return;
|
|
38067
|
+
}
|
|
38068
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38069
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
38070
|
+
const incoming = response.messages.map(getResolver('message'));
|
|
38071
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
38072
|
+
? [...new Set([...incoming, ...existing])]
|
|
38073
|
+
: [...new Set([...existing, ...incoming])] }));
|
|
38074
|
+
}
|
|
38075
|
+
}
|
|
38076
|
+
|
|
38077
|
+
class SearchMessageLiveCollectionController extends LiveCollectionController {
|
|
38078
|
+
constructor(query, callback) {
|
|
38079
|
+
const queryStreamId = hash(query);
|
|
38080
|
+
const cacheKey = ['message', 'search', queryStreamId];
|
|
38081
|
+
const paginationController = new SearchMessagePaginationController(query);
|
|
38082
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
38083
|
+
this.queryStreamController = new SearchMessageQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
38084
|
+
this.callback = callback.bind(this);
|
|
38085
|
+
this.loadPage({ initial: true });
|
|
38086
|
+
}
|
|
38087
|
+
startSubscription() {
|
|
38088
|
+
return [];
|
|
38089
|
+
}
|
|
38090
|
+
notifyChange({ origin, loading, error }) {
|
|
38091
|
+
var _a, _b;
|
|
38092
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38093
|
+
if (!collection)
|
|
38094
|
+
return;
|
|
38095
|
+
const data = (_b = collection.data
|
|
38096
|
+
.map(messageId => getMessageFromMainDB(messageId))
|
|
38097
|
+
.filter(isNonNullable)
|
|
38098
|
+
.map(message => LinkedObject.message(message))) !== null && _b !== void 0 ? _b : [];
|
|
38099
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
38100
|
+
return;
|
|
38101
|
+
this.callback({
|
|
38102
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
38103
|
+
data,
|
|
38104
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
38105
|
+
loading,
|
|
38106
|
+
error,
|
|
38107
|
+
});
|
|
38108
|
+
}
|
|
38109
|
+
setup() {
|
|
38110
|
+
var _a;
|
|
38111
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38112
|
+
if (!collection) {
|
|
38113
|
+
pushToCache(this.cacheKey, {
|
|
38114
|
+
data: [],
|
|
38115
|
+
params: {},
|
|
38116
|
+
});
|
|
38117
|
+
}
|
|
38118
|
+
}
|
|
38119
|
+
async persistModel(response) {
|
|
38120
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
38121
|
+
}
|
|
38122
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
38123
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
38124
|
+
}
|
|
38125
|
+
}
|
|
38126
|
+
|
|
38127
|
+
/* begin_public_function
|
|
38128
|
+
id: message.search
|
|
38129
|
+
*/
|
|
38130
|
+
/**
|
|
38131
|
+
* ```js
|
|
38132
|
+
* import { MessageRepository } from '@amityco/ts-sdk';
|
|
38133
|
+
*
|
|
38134
|
+
* let messages = [];
|
|
38135
|
+
*
|
|
38136
|
+
* const unsubscribe = MessageRepository.searchMessage(
|
|
38137
|
+
* { query: 'hello' },
|
|
38138
|
+
* response => merge(messages, response.data),
|
|
38139
|
+
* );
|
|
38140
|
+
* ```
|
|
38141
|
+
*
|
|
38142
|
+
* Live collection of {@link Amity.Message}s matching the search query. Backed
|
|
38143
|
+
* by `GET /api/v2/search/messages`. The first emission delivers the first
|
|
38144
|
+
* page; pagination is driven by `response.onNextPage()`.
|
|
38145
|
+
*
|
|
38146
|
+
* @param params Search parameters. `query` is required.
|
|
38147
|
+
* @param callback Called whenever new data are available.
|
|
38148
|
+
* @returns An {@link Amity.Unsubscriber} function to stop observing.
|
|
38149
|
+
*
|
|
38150
|
+
* @category Message Live Collection
|
|
38151
|
+
*/
|
|
38152
|
+
const searchMessage = (params, callback) => {
|
|
38153
|
+
if (!params.query || params.query.trim().length === 0) {
|
|
38154
|
+
throw new Error('Query is required for message search');
|
|
38155
|
+
}
|
|
38156
|
+
const { log, cache } = getActiveClient();
|
|
38157
|
+
if (!cache) {
|
|
38158
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
38159
|
+
}
|
|
38160
|
+
const timestamp = Date.now();
|
|
38161
|
+
log(`searchMessage(tmpid: ${timestamp}) > listen`);
|
|
38162
|
+
const controller = new SearchMessageLiveCollectionController(params, callback);
|
|
38163
|
+
const disposers = controller.startSubscription();
|
|
38164
|
+
const cacheKey = controller.getCacheKey();
|
|
38165
|
+
disposers.push(() => {
|
|
38166
|
+
dropFromCache(cacheKey);
|
|
38167
|
+
});
|
|
38168
|
+
return () => {
|
|
38169
|
+
log(`searchMessage(tmpid: ${timestamp}) > dispose`);
|
|
38170
|
+
disposers.forEach(fn => fn());
|
|
38171
|
+
};
|
|
38172
|
+
};
|
|
38173
|
+
/* end_public_function */
|
|
38174
|
+
|
|
36853
38175
|
var index$n = /*#__PURE__*/Object.freeze({
|
|
36854
38176
|
__proto__: null,
|
|
36855
38177
|
createMessage: createMessage,
|
|
@@ -36875,6 +38197,7 @@ var index$n = /*#__PURE__*/Object.freeze({
|
|
|
36875
38197
|
onMessageFetched: onMessageFetched,
|
|
36876
38198
|
getMessage: getMessage,
|
|
36877
38199
|
getMessages: getMessages,
|
|
38200
|
+
searchMessage: searchMessage,
|
|
36878
38201
|
convertFromRaw: convertFromRaw$1,
|
|
36879
38202
|
prepareMessagePayload: prepareMessagePayload,
|
|
36880
38203
|
convertParams: convertParams,
|
|
@@ -37722,6 +39045,7 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
37722
39045
|
"onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
37723
39046
|
"onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
37724
39047
|
"onResolveChannel" /* Amity.ChannelActionType.OnResolveChannel */,
|
|
39048
|
+
"onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
37725
39049
|
].includes(action)) {
|
|
37726
39050
|
if (Array.isArray(payload)) {
|
|
37727
39051
|
collection.data = [
|
|
@@ -37731,6 +39055,12 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
37731
39055
|
else
|
|
37732
39056
|
collection.data = [...new Set([payload.channelInternalId, ...collection.data])];
|
|
37733
39057
|
}
|
|
39058
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
39059
|
+
const ids = Array.isArray(payload)
|
|
39060
|
+
? payload.map(getResolver('channel'))
|
|
39061
|
+
: [getResolver('channel')(payload)];
|
|
39062
|
+
collection.data = collection.data.filter(channelInternalId => !ids.includes(channelInternalId));
|
|
39063
|
+
}
|
|
37734
39064
|
pushToCache(this.cacheKey, collection);
|
|
37735
39065
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
37736
39066
|
};
|
|
@@ -37997,6 +39327,32 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
37997
39327
|
},
|
|
37998
39328
|
{ fn: onChannelMemberAdded, action: "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */ },
|
|
37999
39329
|
{ fn: onChannelMemberRemoved, action: "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */ },
|
|
39330
|
+
{
|
|
39331
|
+
fn: (reactor) => onChannelArchived(payload => {
|
|
39332
|
+
const channels = payload.archives
|
|
39333
|
+
.map(archive => {
|
|
39334
|
+
var _a;
|
|
39335
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39336
|
+
})
|
|
39337
|
+
.filter((c) => Boolean(c));
|
|
39338
|
+
if (channels.length > 0)
|
|
39339
|
+
reactor(channels);
|
|
39340
|
+
}),
|
|
39341
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
39342
|
+
},
|
|
39343
|
+
{
|
|
39344
|
+
fn: (reactor) => onChannelUnarchived(payload => {
|
|
39345
|
+
const channels = payload.archives
|
|
39346
|
+
.map(archive => {
|
|
39347
|
+
var _a;
|
|
39348
|
+
return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39349
|
+
})
|
|
39350
|
+
.filter((c) => Boolean(c));
|
|
39351
|
+
if (channels.length > 0)
|
|
39352
|
+
reactor(channels);
|
|
39353
|
+
}),
|
|
39354
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
39355
|
+
},
|
|
38000
39356
|
{
|
|
38001
39357
|
fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
38002
39358
|
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
@@ -38350,6 +39706,192 @@ const getTotalChannelsUnread = (callback) => {
|
|
|
38350
39706
|
};
|
|
38351
39707
|
};
|
|
38352
39708
|
|
|
39709
|
+
class ArchivedChannelPaginationController extends PaginationController {
|
|
39710
|
+
async getRequest(queryParams, token) {
|
|
39711
|
+
var _a, _b;
|
|
39712
|
+
const limit = (_a = queryParams.limit) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
39713
|
+
const pageIndex = token ? Number.parseInt(token, 10) : 0;
|
|
39714
|
+
if (pageIndex === 0) {
|
|
39715
|
+
await getArchivedChannelIds();
|
|
39716
|
+
}
|
|
39717
|
+
const cached = (_b = queryCache(['archivedChannel', 'get'])) !== null && _b !== void 0 ? _b : [];
|
|
39718
|
+
const archives = cached
|
|
39719
|
+
.map(entry => entry.data)
|
|
39720
|
+
.slice()
|
|
39721
|
+
.sort((a, b) => Number(new Date(b.archivedAt)) - Number(new Date(a.archivedAt)));
|
|
39722
|
+
const start = pageIndex * limit;
|
|
39723
|
+
const end = start + limit;
|
|
39724
|
+
const slice = archives.slice(start, end);
|
|
39725
|
+
const hasMore = end < archives.length;
|
|
39726
|
+
if (slice.length > 0) {
|
|
39727
|
+
await getChannelByIds$1(slice.map(archive => archive.channelId));
|
|
39728
|
+
}
|
|
39729
|
+
return {
|
|
39730
|
+
archives: slice,
|
|
39731
|
+
paging: {
|
|
39732
|
+
next: hasMore ? String(pageIndex + 1) : undefined,
|
|
39733
|
+
previous: undefined,
|
|
39734
|
+
},
|
|
39735
|
+
};
|
|
39736
|
+
}
|
|
39737
|
+
}
|
|
39738
|
+
|
|
39739
|
+
class ArchivedChannelQueryStreamController extends QueryStreamController {
|
|
39740
|
+
constructor(query, cacheKey, notifyChange) {
|
|
39741
|
+
super(query, cacheKey);
|
|
39742
|
+
this.notifyChange = notifyChange;
|
|
39743
|
+
}
|
|
39744
|
+
async saveToMainDB(_response) {
|
|
39745
|
+
//
|
|
39746
|
+
}
|
|
39747
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
39748
|
+
var _a, _b;
|
|
39749
|
+
const channelIds = response.archives.map(archive => archive.channelId);
|
|
39750
|
+
if (refresh) {
|
|
39751
|
+
pushToCache(this.cacheKey, {
|
|
39752
|
+
data: channelIds,
|
|
39753
|
+
params: {},
|
|
39754
|
+
});
|
|
39755
|
+
return;
|
|
39756
|
+
}
|
|
39757
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39758
|
+
const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
39759
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
|
|
39760
|
+
? [...new Set([...channelIds, ...existing])]
|
|
39761
|
+
: [...new Set([...existing, ...channelIds])] }));
|
|
39762
|
+
}
|
|
39763
|
+
reactor(action) {
|
|
39764
|
+
return (channelIds) => {
|
|
39765
|
+
var _a;
|
|
39766
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39767
|
+
if (!collection)
|
|
39768
|
+
return;
|
|
39769
|
+
if (action === "onArchived" /* Amity.ChannelActionType.OnArchived */) {
|
|
39770
|
+
const filtered = collection.data.filter(id => !channelIds.includes(id));
|
|
39771
|
+
collection.data = [...channelIds, ...filtered];
|
|
39772
|
+
}
|
|
39773
|
+
if (action === "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */ ||
|
|
39774
|
+
action === "onDelete" /* Amity.ChannelActionType.OnDelete */) {
|
|
39775
|
+
collection.data = collection.data.filter(id => !channelIds.includes(id));
|
|
39776
|
+
}
|
|
39777
|
+
pushToCache(this.cacheKey, collection);
|
|
39778
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
39779
|
+
};
|
|
39780
|
+
}
|
|
39781
|
+
subscribeRTE(createSubscriber) {
|
|
39782
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
39783
|
+
}
|
|
39784
|
+
}
|
|
39785
|
+
|
|
39786
|
+
class ArchivedChannelLiveCollectionController extends LiveCollectionController {
|
|
39787
|
+
constructor(query, callback) {
|
|
39788
|
+
const queryStreamId = hash(query);
|
|
39789
|
+
const cacheKey = ['archivedChannel', 'collection', queryStreamId];
|
|
39790
|
+
const paginationController = new ArchivedChannelPaginationController(query);
|
|
39791
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
39792
|
+
this.queryStreamController = new ArchivedChannelQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
|
|
39793
|
+
this.callback = callback.bind(this);
|
|
39794
|
+
this.loadPage({ initial: true });
|
|
39795
|
+
}
|
|
39796
|
+
setup() {
|
|
39797
|
+
var _a;
|
|
39798
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39799
|
+
if (!collection) {
|
|
39800
|
+
pushToCache(this.cacheKey, {
|
|
39801
|
+
data: [],
|
|
39802
|
+
params: {},
|
|
39803
|
+
});
|
|
39804
|
+
}
|
|
39805
|
+
}
|
|
39806
|
+
async persistModel(response) {
|
|
39807
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
39808
|
+
}
|
|
39809
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
39810
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
39811
|
+
}
|
|
39812
|
+
startSubscription() {
|
|
39813
|
+
return this.queryStreamController.subscribeRTE([
|
|
39814
|
+
{
|
|
39815
|
+
fn: reactor => onChannelArchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
39816
|
+
action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
|
|
39817
|
+
},
|
|
39818
|
+
{
|
|
39819
|
+
fn: reactor => onChannelUnarchived(payload => reactor(payload.archives.map(archive => archive.channelId))),
|
|
39820
|
+
action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
|
|
39821
|
+
},
|
|
39822
|
+
{
|
|
39823
|
+
fn: reactor => onChannelUpdated(channel => reactor([channel.channelId])),
|
|
39824
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
39825
|
+
},
|
|
39826
|
+
{
|
|
39827
|
+
fn: reactor => onChannelDeleted(channel => reactor([channel.channelId])),
|
|
39828
|
+
action: "onDelete" /* Amity.ChannelActionType.OnDelete */,
|
|
39829
|
+
},
|
|
39830
|
+
]);
|
|
39831
|
+
}
|
|
39832
|
+
notifyChange({ origin, loading, error }) {
|
|
39833
|
+
var _a, _b;
|
|
39834
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39835
|
+
if (!collection)
|
|
39836
|
+
return;
|
|
39837
|
+
const data = (_b = collection.data
|
|
39838
|
+
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
39839
|
+
.filter((entry) => Boolean(entry))
|
|
39840
|
+
.map(({ data: channel }) => channel)
|
|
39841
|
+
.map(constructChannelObject)) !== null && _b !== void 0 ? _b : [];
|
|
39842
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
39843
|
+
return;
|
|
39844
|
+
this.callback({
|
|
39845
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
39846
|
+
data,
|
|
39847
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
39848
|
+
loading,
|
|
39849
|
+
error,
|
|
39850
|
+
});
|
|
39851
|
+
}
|
|
39852
|
+
}
|
|
39853
|
+
|
|
39854
|
+
/* begin_public_function
|
|
39855
|
+
id: channel.archive.collection
|
|
39856
|
+
*/
|
|
39857
|
+
/**
|
|
39858
|
+
* ```js
|
|
39859
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
39860
|
+
*
|
|
39861
|
+
* let channels = []
|
|
39862
|
+
* const unsub = ChannelRepository.getArchivedChannels(params, response => merge(channels, response.data))
|
|
39863
|
+
* ```
|
|
39864
|
+
*
|
|
39865
|
+
* Live collection of {@link Amity.Channel}s archived by the active user.
|
|
39866
|
+
*
|
|
39867
|
+
* @param params Live collection parameters (only `limit` is honored; the
|
|
39868
|
+
* archive list takes no other filters).
|
|
39869
|
+
* @param callback the function to call when new data are available
|
|
39870
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to
|
|
39871
|
+
* stop observing.
|
|
39872
|
+
*
|
|
39873
|
+
* @category Channel Live Collection
|
|
39874
|
+
*/
|
|
39875
|
+
const getArchivedChannels = (params, callback) => {
|
|
39876
|
+
const { log, cache } = getActiveClient();
|
|
39877
|
+
if (!cache) {
|
|
39878
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
39879
|
+
}
|
|
39880
|
+
const timestamp = Date.now();
|
|
39881
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > listen`);
|
|
39882
|
+
const controller = new ArchivedChannelLiveCollectionController(params, callback);
|
|
39883
|
+
const disposers = controller.startSubscription();
|
|
39884
|
+
const cacheKey = controller.getCacheKey();
|
|
39885
|
+
disposers.push(() => {
|
|
39886
|
+
dropFromCache(cacheKey);
|
|
39887
|
+
});
|
|
39888
|
+
return () => {
|
|
39889
|
+
log(`getArchivedChannels(tmpid: ${timestamp}) > dispose`);
|
|
39890
|
+
disposers.forEach(fn => fn());
|
|
39891
|
+
};
|
|
39892
|
+
};
|
|
39893
|
+
/* end_public_function */
|
|
39894
|
+
|
|
38353
39895
|
/* begin_public_function
|
|
38354
39896
|
id: channel.member.add
|
|
38355
39897
|
*/
|
|
@@ -38481,7 +40023,9 @@ class ChannelMemberQueryStreamController extends QueryStreamController {
|
|
|
38481
40023
|
channelId: this.query.channelId,
|
|
38482
40024
|
userId: channelMember.userId,
|
|
38483
40025
|
});
|
|
38484
|
-
|
|
40026
|
+
const membershipFilter = this.query.memberships;
|
|
40027
|
+
const isInFilter = !membershipFilter || membershipFilter.includes(channelMember.membership);
|
|
40028
|
+
if (channelMember.membership === 'none' || !isInFilter) {
|
|
38485
40029
|
collection.data = collection.data.filter(m => m !== channelMemberCacheId);
|
|
38486
40030
|
}
|
|
38487
40031
|
else if (!collection.data.includes(channelMemberCacheId)) {
|
|
@@ -38817,6 +40361,7 @@ const banMembers$1 = async (channelId, userIds) => {
|
|
|
38817
40361
|
const cachedAt = client.cache && Date.now();
|
|
38818
40362
|
if (client.cache)
|
|
38819
40363
|
ingestInCache(preparedPayload, { cachedAt });
|
|
40364
|
+
fireEvent('channel.banned', payload);
|
|
38820
40365
|
return {
|
|
38821
40366
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'banned'),
|
|
38822
40367
|
cachedAt,
|
|
@@ -38851,6 +40396,7 @@ const unbanMembers$1 = async (channelId, userIds) => {
|
|
|
38851
40396
|
const cachedAt = client.cache && Date.now();
|
|
38852
40397
|
if (client.cache)
|
|
38853
40398
|
ingestInCache(preparedPayload, { cachedAt });
|
|
40399
|
+
fireEvent('channel.unbanned', payload);
|
|
38854
40400
|
const { channelUsers } = preparedPayload;
|
|
38855
40401
|
return {
|
|
38856
40402
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'member'),
|
|
@@ -38879,6 +40425,7 @@ const MUTE_FOREVER = -1;
|
|
|
38879
40425
|
* @async
|
|
38880
40426
|
* */
|
|
38881
40427
|
const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
40428
|
+
var _a;
|
|
38882
40429
|
const client = getActiveClient();
|
|
38883
40430
|
client.log('channel/muteMembers', { userIds, channelId, mutePeriod });
|
|
38884
40431
|
const { data } = await client.http.put(`/api/v2/channel/${channelId}/users/mute`, {
|
|
@@ -38886,6 +40433,15 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
38886
40433
|
mutePeriod: mutePeriod === MUTE_FOREVER ? mutePeriod : mutePeriod * 1000,
|
|
38887
40434
|
});
|
|
38888
40435
|
const { success } = data;
|
|
40436
|
+
const muteTimeout = mutePeriod === MUTE_FOREVER
|
|
40437
|
+
? new Date('9999-12-31T23:59:59.999Z').toISOString()
|
|
40438
|
+
: new Date(Date.now() + mutePeriod * 1000).toISOString();
|
|
40439
|
+
fireEvent('channel.setMutedUsers', {
|
|
40440
|
+
channelId,
|
|
40441
|
+
userIds,
|
|
40442
|
+
muteTimeout,
|
|
40443
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
40444
|
+
});
|
|
38889
40445
|
return success;
|
|
38890
40446
|
};
|
|
38891
40447
|
/* end_public_function */
|
|
@@ -38908,6 +40464,7 @@ const muteMembers = async (channelId, userIds, mutePeriod = MUTE_FOREVER) => {
|
|
|
38908
40464
|
* @async
|
|
38909
40465
|
* */
|
|
38910
40466
|
const unmuteMembers = async (channelId, userIds) => {
|
|
40467
|
+
var _a;
|
|
38911
40468
|
const client = getActiveClient();
|
|
38912
40469
|
client.log('channel/unmuteMembers', { userIds, channelId });
|
|
38913
40470
|
const { data } = await client.http.put(`/api/v2/channel/${encodeURIComponent(channelId)}/users/mute`, {
|
|
@@ -38915,6 +40472,12 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
38915
40472
|
mutePeriod: 0,
|
|
38916
40473
|
});
|
|
38917
40474
|
const { success } = data;
|
|
40475
|
+
fireEvent('channel.setMutedUsers', {
|
|
40476
|
+
channelId,
|
|
40477
|
+
userIds,
|
|
40478
|
+
muteTimeout: new Date(0).toISOString(),
|
|
40479
|
+
actor: (_a = client.userId) !== null && _a !== void 0 ? _a : '',
|
|
40480
|
+
});
|
|
38918
40481
|
return success;
|
|
38919
40482
|
};
|
|
38920
40483
|
/* end_public_function */
|
|
@@ -38941,6 +40504,9 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38941
40504
|
leaveChannel: leaveChannel,
|
|
38942
40505
|
muteChannel: muteChannel,
|
|
38943
40506
|
unmuteChannel: unmuteChannel,
|
|
40507
|
+
archiveChannel: archiveChannel,
|
|
40508
|
+
unarchiveChannel: unarchiveChannel,
|
|
40509
|
+
getArchivedChannelIds: getArchivedChannelIds,
|
|
38944
40510
|
onChannelCreated: onChannelCreated,
|
|
38945
40511
|
onChannelUpdated: onChannelUpdated,
|
|
38946
40512
|
onChannelDeleted: onChannelDeleted,
|
|
@@ -38953,9 +40519,12 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38953
40519
|
onChannelMemberUnbanned: onChannelMemberUnbanned,
|
|
38954
40520
|
onChannelMemberRoleAdded: onChannelMemberRoleAdded,
|
|
38955
40521
|
onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
|
|
40522
|
+
onChannelArchived: onChannelArchived,
|
|
40523
|
+
onChannelUnarchived: onChannelUnarchived,
|
|
38956
40524
|
getChannel: getChannel,
|
|
38957
40525
|
getChannels: getChannels,
|
|
38958
40526
|
getTotalChannelsUnread: getTotalChannelsUnread,
|
|
40527
|
+
getArchivedChannels: getArchivedChannels,
|
|
38959
40528
|
MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
|
|
38960
40529
|
isUnreadCountSupport: isUnreadCountSupport,
|
|
38961
40530
|
convertFromRaw: convertFromRaw,
|
|
@@ -42851,7 +44420,7 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
42851
44420
|
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
42852
44421
|
}
|
|
42853
44422
|
startSubscription() {
|
|
42854
|
-
|
|
44423
|
+
const disposers = this.queryStreamController.subscribeRTE([
|
|
42855
44424
|
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
42856
44425
|
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
42857
44426
|
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
@@ -42864,6 +44433,11 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
42864
44433
|
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
42865
44434
|
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
42866
44435
|
]);
|
|
44436
|
+
if (this.query.excludeBlockUserComments) {
|
|
44437
|
+
const refresh = () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
44438
|
+
disposers.push(onUserDidBlock(refresh), onUserDidUnblock(refresh));
|
|
44439
|
+
}
|
|
44440
|
+
return disposers;
|
|
42867
44441
|
}
|
|
42868
44442
|
notifyChange({ origin, loading, error }) {
|
|
42869
44443
|
var _a, _b;
|
|
@@ -42916,6 +44490,9 @@ class CommentLiveCollectionController extends LiveCollectionController {
|
|
|
42916
44490
|
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
44491
|
}
|
|
42918
44492
|
}
|
|
44493
|
+
if (this.query.excludeBlockUserComments) {
|
|
44494
|
+
comments = filterCommentsByBlockUsers(comments);
|
|
44495
|
+
}
|
|
42919
44496
|
switch (this.query.sortBy) {
|
|
42920
44497
|
case 'firstCreated':
|
|
42921
44498
|
comments = comments.sort(sortByFirstCreated);
|
|
@@ -44001,13 +45578,218 @@ const getCommunityFeed = (params, callback, config) => {
|
|
|
44001
45578
|
};
|
|
44002
45579
|
/* end_public_function */
|
|
44003
45580
|
|
|
45581
|
+
/**
|
|
45582
|
+
* Thrown by `getForYouFeed` when the network has the For You feature
|
|
45583
|
+
* disabled. Mapped from HTTP 404 NOT_FOUND. Distinct from a generic
|
|
45584
|
+
* not-found so consumers can hide the For You tab without retrying.
|
|
45585
|
+
*
|
|
45586
|
+
* @category Errors
|
|
45587
|
+
*/
|
|
45588
|
+
class AmityForYouFeedDisabledError extends ASCApiError {
|
|
45589
|
+
constructor(message = 'For You feed is not enabled for this network') {
|
|
45590
|
+
super(message, 400400 /* Amity.ServerError.ITEM_NOT_FOUND */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
45591
|
+
this.type = 'AmityForYouFeedDisabledError';
|
|
45592
|
+
}
|
|
45593
|
+
}
|
|
45594
|
+
|
|
45595
|
+
class ForYouFeedPaginationController extends PaginationController {
|
|
45596
|
+
constructor(query) {
|
|
45597
|
+
super(query);
|
|
45598
|
+
this.checkedDisk = false;
|
|
45599
|
+
this.cursor = CursorController.current();
|
|
45600
|
+
}
|
|
45601
|
+
async getRequest(_queryParams, token) {
|
|
45602
|
+
let effectiveToken = token;
|
|
45603
|
+
if (!effectiveToken && !this.checkedDisk && this.cursor) {
|
|
45604
|
+
this.checkedDisk = true;
|
|
45605
|
+
const stored = await this.cursor.get();
|
|
45606
|
+
if (stored && !CursorController.isExpired(stored.expiredAt)) {
|
|
45607
|
+
effectiveToken = stored.cursor;
|
|
45608
|
+
}
|
|
45609
|
+
else if (stored) {
|
|
45610
|
+
await this.cursor.clear();
|
|
45611
|
+
}
|
|
45612
|
+
}
|
|
45613
|
+
const options = {
|
|
45614
|
+
limit: COLLECTION_DEFAULT_PAGINATION_SIZE,
|
|
45615
|
+
};
|
|
45616
|
+
if (effectiveToken)
|
|
45617
|
+
options.token = effectiveToken;
|
|
45618
|
+
let queryResponse;
|
|
45619
|
+
try {
|
|
45620
|
+
({ data: queryResponse } = await this.http.get(API_ENDPOINTS.forYouFeed, { params: { options } }));
|
|
45621
|
+
}
|
|
45622
|
+
catch (error) {
|
|
45623
|
+
if (error instanceof ASCApiError && error.code === 400300 /* Amity.ServerError.FORBIDDEN */) {
|
|
45624
|
+
throw new AmityForYouFeedDisabledError();
|
|
45625
|
+
}
|
|
45626
|
+
const recoverable = error instanceof ASCApiError && error.code === 400322 /* Amity.ServerError.FEED_SNAPSHOT_EXPIRED */;
|
|
45627
|
+
if (recoverable && effectiveToken !== undefined) {
|
|
45628
|
+
if (this.cursor)
|
|
45629
|
+
await this.cursor.clear();
|
|
45630
|
+
({ data: queryResponse } = await this.http.get(API_ENDPOINTS.forYouFeed, { params: { options: { limit: COLLECTION_DEFAULT_PAGINATION_SIZE } } }));
|
|
45631
|
+
}
|
|
45632
|
+
else {
|
|
45633
|
+
throw error;
|
|
45634
|
+
}
|
|
45635
|
+
}
|
|
45636
|
+
await this.persistCursor(queryResponse);
|
|
45637
|
+
return queryResponse;
|
|
45638
|
+
}
|
|
45639
|
+
async persistCursor(response) {
|
|
45640
|
+
var _a, _b;
|
|
45641
|
+
if (!this.cursor)
|
|
45642
|
+
return;
|
|
45643
|
+
const cursor = (_a = response.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
45644
|
+
const expiredAtIso = (_b = response.paging) === null || _b === void 0 ? void 0 : _b.expiredAt;
|
|
45645
|
+
if (!cursor || !expiredAtIso)
|
|
45646
|
+
return;
|
|
45647
|
+
const expiredAt = Date.parse(expiredAtIso);
|
|
45648
|
+
if (Number.isNaN(expiredAt))
|
|
45649
|
+
return;
|
|
45650
|
+
await this.cursor.set({ cursor, expiredAt });
|
|
45651
|
+
}
|
|
45652
|
+
}
|
|
45653
|
+
|
|
45654
|
+
class ForYouFeedQueryStreamController extends QueryStreamController {
|
|
45655
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
45656
|
+
super(query, cacheKey);
|
|
45657
|
+
this.notifyChange = notifyChange;
|
|
45658
|
+
this.preparePayload = preparePayload;
|
|
45659
|
+
}
|
|
45660
|
+
async saveToMainDB(response) {
|
|
45661
|
+
const processedPayload = await this.preparePayload(response);
|
|
45662
|
+
const client = getActiveClient();
|
|
45663
|
+
const cachedAt = client.cache && Date.now();
|
|
45664
|
+
if (client.cache)
|
|
45665
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
45666
|
+
}
|
|
45667
|
+
appendToQueryStream(response, _direction, refresh = false) {
|
|
45668
|
+
var _a, _b;
|
|
45669
|
+
if (refresh) {
|
|
45670
|
+
pushToCache(this.cacheKey, {
|
|
45671
|
+
data: response.posts.map(getResolver('post')),
|
|
45672
|
+
});
|
|
45673
|
+
}
|
|
45674
|
+
else {
|
|
45675
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45676
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
45677
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
45678
|
+
}
|
|
45679
|
+
}
|
|
45680
|
+
reactor(action) {
|
|
45681
|
+
return (post) => {
|
|
45682
|
+
var _a;
|
|
45683
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45684
|
+
if (!collection)
|
|
45685
|
+
return;
|
|
45686
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
45687
|
+
return;
|
|
45688
|
+
if (action === EnumPostActions.OnPostDeleted || action === EnumPostActions.OnPostDeclined) {
|
|
45689
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
45690
|
+
}
|
|
45691
|
+
pushToCache(this.cacheKey, collection);
|
|
45692
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
45693
|
+
};
|
|
45694
|
+
}
|
|
45695
|
+
subscribeRTE(createSubscriber) {
|
|
45696
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
45697
|
+
}
|
|
45698
|
+
}
|
|
45699
|
+
|
|
45700
|
+
const FOR_YOU_FEED_CACHE_KEY = ['forYouFeed', 'collection'];
|
|
45701
|
+
class ForYouFeedLiveCollectionController extends LiveCollectionController {
|
|
45702
|
+
constructor(callback) {
|
|
45703
|
+
const queryStreamId = `for-you-feed-${getActiveClient().userId}`;
|
|
45704
|
+
const query = {};
|
|
45705
|
+
const paginationController = new ForYouFeedPaginationController(query);
|
|
45706
|
+
super(paginationController, queryStreamId, FOR_YOU_FEED_CACHE_KEY, callback);
|
|
45707
|
+
this.queryStreamController = new ForYouFeedQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
45708
|
+
this.callback = callback.bind(this);
|
|
45709
|
+
this.loadPage({ initial: true });
|
|
45710
|
+
}
|
|
45711
|
+
setup() {
|
|
45712
|
+
var _a;
|
|
45713
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45714
|
+
if (!collection)
|
|
45715
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
45716
|
+
}
|
|
45717
|
+
async persistModel(payload) {
|
|
45718
|
+
await this.queryStreamController.saveToMainDB(payload);
|
|
45719
|
+
}
|
|
45720
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
45721
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
45722
|
+
}
|
|
45723
|
+
startSubscription() {
|
|
45724
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
45725
|
+
}
|
|
45726
|
+
notifyChange({ origin, loading, error }) {
|
|
45727
|
+
var _a, _b;
|
|
45728
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45729
|
+
if (!collection)
|
|
45730
|
+
return;
|
|
45731
|
+
const data = ((_b = collection.data
|
|
45732
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
45733
|
+
.filter(isNonNullable)
|
|
45734
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
45735
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
45736
|
+
return;
|
|
45737
|
+
this.callback({
|
|
45738
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
45739
|
+
data,
|
|
45740
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
45741
|
+
loading,
|
|
45742
|
+
error,
|
|
45743
|
+
});
|
|
45744
|
+
}
|
|
45745
|
+
}
|
|
45746
|
+
|
|
45747
|
+
/* begin_public_function
|
|
45748
|
+
id: feed.query.for_you_feed
|
|
45749
|
+
*/
|
|
45750
|
+
/**
|
|
45751
|
+
* ```js
|
|
45752
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
45753
|
+
*
|
|
45754
|
+
* const unsub = FeedRepository.getForYouFeed(({ data, loading, error, hasNextPage, onNextPage }) => {
|
|
45755
|
+
* // render posts; call onNextPage() to load the next page (20 posts)
|
|
45756
|
+
* })
|
|
45757
|
+
* ```
|
|
45758
|
+
*
|
|
45759
|
+
* Observe the For You feed — a personalized, server-ranked
|
|
45760
|
+
* {@link Amity.LiveCollection} of {@link Amity.Post}.
|
|
45761
|
+
*
|
|
45762
|
+
* @param callback the function to call when new data is available
|
|
45763
|
+
* @returns an {@link Amity.Unsubscriber} function to stop observing
|
|
45764
|
+
*
|
|
45765
|
+
* @category Posts Live Collection
|
|
45766
|
+
*/
|
|
45767
|
+
const getForYouFeed = (callback) => {
|
|
45768
|
+
const { log, cache } = getActiveClient();
|
|
45769
|
+
if (!cache)
|
|
45770
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
45771
|
+
const timestamp = Date.now();
|
|
45772
|
+
log(`getForYouFeed(tmpid: ${timestamp}) > listen`);
|
|
45773
|
+
const forYouFeedLiveCollection = new ForYouFeedLiveCollectionController(callback);
|
|
45774
|
+
const disposers = forYouFeedLiveCollection.startSubscription();
|
|
45775
|
+
const cacheKey = forYouFeedLiveCollection.getCacheKey();
|
|
45776
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
45777
|
+
return () => {
|
|
45778
|
+
log(`getForYouFeed(tmpid: ${timestamp}) > dispose`);
|
|
45779
|
+
disposers.forEach(fn => fn());
|
|
45780
|
+
};
|
|
45781
|
+
};
|
|
45782
|
+
/* end_public_function */
|
|
45783
|
+
|
|
44004
45784
|
var index$d = /*#__PURE__*/Object.freeze({
|
|
44005
45785
|
__proto__: null,
|
|
44006
45786
|
queryGlobalFeed: queryGlobalFeed,
|
|
44007
45787
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
44008
45788
|
getGlobalFeed: getGlobalFeed,
|
|
44009
45789
|
getUserFeed: getUserFeed,
|
|
44010
|
-
getCommunityFeed: getCommunityFeed
|
|
45790
|
+
getCommunityFeed: getCommunityFeed,
|
|
45791
|
+
getForYouFeed: getForYouFeed,
|
|
45792
|
+
AmityForYouFeedDisabledError: AmityForYouFeedDisabledError
|
|
44011
45793
|
});
|
|
44012
45794
|
|
|
44013
45795
|
/* begin_public_function
|
|
@@ -45020,7 +46802,12 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
45020
46802
|
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
45021
46803
|
}
|
|
45022
46804
|
startSubscription() {
|
|
45023
|
-
|
|
46805
|
+
const disposers = this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
|
|
46806
|
+
if (this.query.excludeBlockUserPosts) {
|
|
46807
|
+
const refresh = () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
46808
|
+
disposers.push(onUserDidBlock(refresh), onUserDidUnblock(refresh));
|
|
46809
|
+
}
|
|
46810
|
+
return disposers;
|
|
45024
46811
|
}
|
|
45025
46812
|
notifyChange({ origin, loading, error }) {
|
|
45026
46813
|
var _a, _b;
|
|
@@ -45066,6 +46853,9 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
45066
46853
|
const sortBy = this.query.sortBy || 'lastCreated';
|
|
45067
46854
|
posts = posts.filter(post => !exceedsUntilAtBoundary(post.createdAt, validatedUntilAt, sortBy));
|
|
45068
46855
|
}
|
|
46856
|
+
if (this.query.excludeBlockUserPosts) {
|
|
46857
|
+
posts = filterPostsByBlockUsers(posts);
|
|
46858
|
+
}
|
|
45069
46859
|
switch (this.query.sortBy) {
|
|
45070
46860
|
case 'firstCreated':
|
|
45071
46861
|
posts = posts.sort(sortByFirstCreated);
|
|
@@ -51731,4 +53521,4 @@ class AmityAttachmentProductTags {
|
|
|
51731
53521
|
}
|
|
51732
53522
|
}
|
|
51733
53523
|
|
|
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 };
|
|
53524
|
+
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 };
|