@amityco/ts-sdk 7.11.1-b4621cc1.0 → 7.11.1-b5436ec.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +25 -2
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/linkPreviewMetadata.d.ts +12 -0
- package/dist/@types/core/linkPreviewMetadata.d.ts.map +1 -0
- package/dist/@types/core/model.d.ts +5 -3
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +32 -9
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +1 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +13 -3
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +4 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +36 -17
- package/dist/@types/domains/event.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +2 -1
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/invitation.d.ts +7 -2
- package/dist/@types/domains/invitation.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +9 -4
- package/dist/@types/domains/notification.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +24 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/room.d.ts +99 -0
- package/dist/@types/domains/room.d.ts.map +1 -0
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +1 -0
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/client/api/fetchLinkPreview.d.ts +3 -0
- package/dist/client/api/fetchLinkPreview.d.ts.map +1 -1
- package/dist/client/api/getCurrentUser.d.ts +1 -1
- package/dist/client/api/getCurrentUser.d.ts.map +1 -1
- package/dist/client/api/getLinkPreviewMetadata.d.ts +14 -0
- package/dist/client/api/getLinkPreviewMetadata.d.ts.map +1 -0
- package/dist/client/api/getPresenceSetting.d.ts +2 -0
- package/dist/client/api/getPresenceSetting.d.ts.map +1 -0
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/resumeSession.d.ts.map +1 -1
- package/dist/client/events/onUserDeleted.d.ts +17 -0
- package/dist/client/events/onUserDeleted.d.ts.map +1 -0
- package/dist/client/services/ObjectResolver/objectResolverEngine.d.ts.map +1 -0
- package/dist/client/services/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/client/utils/setBotClientToken.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts.map +1 -1
- package/dist/client/utils/setCurrentUser.d.ts.map +1 -1
- package/dist/client/utils/setVisitorClientToken.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/subscription.d.ts +2 -0
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/eventRepository/events/onEventCreated.d.ts +1 -1
- package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +1 -1
- package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +1 -1
- package/dist/eventRepository/internalApi/createRSVP.d.ts +4 -3
- package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -1
- package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -1
- package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -1
- package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +4 -4
- package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -1
- package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +2 -2
- package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -1
- package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +6 -6
- package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -1
- package/dist/eventRepository/observers/getRSVPs.d.ts +1 -1
- package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -1
- package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts.map +1 -1
- package/dist/index.cjs.js +12131 -10138
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +3112 -1123
- package/dist/index.umd.js +3 -3
- package/dist/invitationRepository/api/cancelInvitation.d.ts +16 -0
- package/dist/invitationRepository/api/cancelInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/api/index.d.ts +2 -0
- package/dist/invitationRepository/api/index.d.ts.map +1 -0
- package/dist/invitationRepository/events/index.d.ts +1 -1
- package/dist/invitationRepository/events/index.d.ts.map +1 -1
- package/dist/invitationRepository/events/onLocalInvitationCanceled.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationCanceled.d.ts.map +1 -0
- package/dist/invitationRepository/index.d.ts +1 -0
- package/dist/invitationRepository/index.d.ts.map +1 -1
- package/dist/invitationRepository/internalApi/getInvitation.d.ts +1 -1
- package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +1 -1
- package/dist/invitationRepository/internalObservers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
- package/dist/invitationRepository/internalObservers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
- package/dist/invitationRepository/internalObservers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
- package/dist/invitationRepository/{observers → internalObservers}/getInvitations/enums.d.ts +1 -1
- package/dist/invitationRepository/internalObservers/getInvitations/enums.d.ts.map +1 -0
- package/dist/invitationRepository/internalObservers/getInvitations.d.ts +12 -0
- package/dist/invitationRepository/internalObservers/getInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations.d.ts +28 -6
- package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -1
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +1 -1
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -1
- package/dist/invitationRepository/observers/index.d.ts +1 -0
- package/dist/invitationRepository/observers/index.d.ts.map +1 -1
- package/dist/liveReactionRepository/api/createReaction.d.ts +2 -2
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +1 -1
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +1 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -0
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/postRepository/api/createPost.d.ts +1 -0
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/api/editPost.d.ts +1 -0
- package/dist/postRepository/api/editPost.d.ts.map +1 -1
- package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostLiveCollectionController.d.ts +14 -0
- package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostLiveCollectionController.d.ts.map +1 -0
- package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostPaginationController.d.ts +5 -0
- package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostPaginationController.d.ts.map +1 -0
- package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostQueryStreamController.d.ts +15 -0
- package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostQueryStreamController.d.ts.map +1 -0
- package/dist/postRepository/observers/getCommunityLiveRoomPosts.d.ts +22 -0
- package/dist/postRepository/observers/getCommunityLiveRoomPosts.d.ts.map +1 -0
- package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostLiveCollectionController.d.ts +14 -0
- package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostLiveCollectionController.d.ts.map +1 -0
- package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostPaginationController.d.ts +5 -0
- package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostPaginationController.d.ts.map +1 -0
- package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostQueryStreamController.d.ts +15 -0
- package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostQueryStreamController.d.ts.map +1 -0
- package/dist/postRepository/observers/getLiveRoomPosts.d.ts +23 -0
- package/dist/postRepository/observers/getLiveRoomPosts.d.ts.map +1 -0
- package/dist/postRepository/observers/index.d.ts +2 -0
- package/dist/postRepository/observers/index.d.ts.map +1 -1
- package/dist/postRepository/observers/utils.d.ts +1 -0
- package/dist/postRepository/observers/utils.d.ts.map +1 -1
- package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts +18 -0
- package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts +17 -0
- package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/index.d.ts +5 -0
- package/dist/roomPresenceRepository/api/index.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/startHeartbeat.d.ts +15 -0
- package/dist/roomPresenceRepository/api/startHeartbeat.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts +15 -0
- package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts.map +1 -0
- package/dist/roomPresenceRepository/index.d.ts +2 -0
- package/dist/roomPresenceRepository/index.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts +38 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts +2 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts +32 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/index.d.ts +2 -0
- package/dist/roomPresenceRepository/services/index.d.ts.map +1 -0
- package/dist/roomRepository/api/createRoom.d.ts +24 -0
- package/dist/roomRepository/api/createRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/deleteRoom.d.ts +16 -0
- package/dist/roomRepository/api/deleteRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/getBroadcasterData.d.ts +16 -0
- package/dist/roomRepository/api/getBroadcasterData.d.ts.map +1 -0
- package/dist/roomRepository/api/getRecordedUrl.d.ts +19 -0
- package/dist/roomRepository/api/getRecordedUrl.d.ts.map +1 -0
- package/dist/roomRepository/api/index.d.ts +9 -0
- package/dist/roomRepository/api/index.d.ts.map +1 -0
- package/dist/roomRepository/api/leaveRoom.d.ts +16 -0
- package/dist/roomRepository/api/leaveRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/removeParticipant.d.ts +17 -0
- package/dist/roomRepository/api/removeParticipant.d.ts.map +1 -0
- package/dist/roomRepository/api/stopRoom.d.ts +16 -0
- package/dist/roomRepository/api/stopRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/updateRoom.d.ts +24 -0
- package/dist/roomRepository/api/updateRoom.d.ts.map +1 -0
- package/dist/roomRepository/events/index.d.ts +20 -0
- package/dist/roomRepository/events/index.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCoHostInviteCanceled.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCoHostInviteCanceled.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCoHostInviteRejected.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCoHostInviteRejected.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCoHostInvited.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCoHostInvited.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCreated.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCreated.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomDeleted.d.ts +17 -0
- package/dist/roomRepository/events/onRoomDeleted.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +17 -0
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomLeft.d.ts +17 -0
- package/dist/roomRepository/events/onRoomLeft.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantStageJoined.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantStageJoined.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantStageLeft.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantStageLeft.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +17 -0
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +17 -0
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomStopped.d.ts +17 -0
- package/dist/roomRepository/events/onRoomStopped.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomTerminated.d.ts +17 -0
- package/dist/roomRepository/events/onRoomTerminated.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomUpdated.d.ts +17 -0
- package/dist/roomRepository/events/onRoomUpdated.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +17 -0
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -0
- package/dist/roomRepository/index.d.ts +4 -0
- package/dist/roomRepository/index.d.ts.map +1 -0
- package/dist/roomRepository/internalApi/getLiveChat.d.ts +16 -0
- package/dist/roomRepository/internalApi/getLiveChat.d.ts.map +1 -0
- package/dist/roomRepository/internalApi/getRoomById.d.ts +5 -0
- package/dist/roomRepository/internalApi/getRoomById.d.ts.map +1 -0
- package/dist/roomRepository/internalApi/index.d.ts +3 -0
- package/dist/roomRepository/internalApi/index.d.ts.map +1 -0
- package/dist/roomRepository/observers/enums.d.ts +10 -0
- package/dist/roomRepository/observers/enums.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRoom.d.ts +2 -0
- package/dist/roomRepository/observers/getRoom.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +14 -0
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +5 -0
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +15 -0
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms.d.ts +29 -0
- package/dist/roomRepository/observers/getRooms.d.ts.map +1 -0
- package/dist/roomRepository/observers/index.d.ts +3 -0
- package/dist/roomRepository/observers/index.d.ts.map +1 -0
- package/dist/roomRepository/observers/utils.d.ts +6 -0
- package/dist/roomRepository/observers/utils.d.ts.map +1 -0
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/eventResponseLinkObject.d.ts +2 -0
- package/dist/utils/linkedObject/eventResponseLinkObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +2 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/roomLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -0
- package/dist/utils/postTypePredicate.d.ts +1 -0
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/package.json +1 -1
- package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +0 -1
- package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +0 -17
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
- /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngine.d.ts +0 -0
- /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngine.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts +0 -0
- /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsLiveCollectionController.d.ts +0 -0
- /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsPaginationController.d.ts +0 -0
- /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsQueryStreamController.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -73,6 +73,11 @@ const CommunityPostSettingMaps = Object.freeze({
|
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
|
|
76
|
+
var AmityCommunityType;
|
|
77
|
+
(function (AmityCommunityType) {
|
|
78
|
+
AmityCommunityType["Default"] = "default";
|
|
79
|
+
AmityCommunityType["Event"] = "event";
|
|
80
|
+
})(AmityCommunityType || (AmityCommunityType = {}));
|
|
76
81
|
|
|
77
82
|
const ContentFeedType = Object.freeze({
|
|
78
83
|
STORY: 'story',
|
|
@@ -112,6 +117,7 @@ const PostContentType = Object.freeze({
|
|
|
112
117
|
POLL: 'poll',
|
|
113
118
|
CLIP: 'clip',
|
|
114
119
|
AUDIO: 'audio',
|
|
120
|
+
ROOM: 'room',
|
|
115
121
|
});
|
|
116
122
|
const PostStructureType = Object.freeze({
|
|
117
123
|
TEXT: 'text',
|
|
@@ -125,7 +131,7 @@ const PostStructureType = Object.freeze({
|
|
|
125
131
|
var InvitationTypeEnum;
|
|
126
132
|
(function (InvitationTypeEnum) {
|
|
127
133
|
InvitationTypeEnum["CommunityMemberInvite"] = "communityMemberInvite";
|
|
128
|
-
InvitationTypeEnum["
|
|
134
|
+
InvitationTypeEnum["LivestreamCohostInvite"] = "livestreamCohostInvite";
|
|
129
135
|
})(InvitationTypeEnum || (InvitationTypeEnum = {}));
|
|
130
136
|
var InvitationStatusEnum;
|
|
131
137
|
(function (InvitationStatusEnum) {
|
|
@@ -139,6 +145,11 @@ var InvitationSortByEnum;
|
|
|
139
145
|
InvitationSortByEnum["FirstCreated"] = "firstCreated";
|
|
140
146
|
InvitationSortByEnum["LastCreated"] = "lastCreated";
|
|
141
147
|
})(InvitationSortByEnum || (InvitationSortByEnum = {}));
|
|
148
|
+
var InvitationTargetTypeEnum;
|
|
149
|
+
(function (InvitationTargetTypeEnum) {
|
|
150
|
+
InvitationTargetTypeEnum["Community"] = "community";
|
|
151
|
+
InvitationTargetTypeEnum["Room"] = "room";
|
|
152
|
+
})(InvitationTargetTypeEnum || (InvitationTargetTypeEnum = {}));
|
|
142
153
|
|
|
143
154
|
var JoinRequestStatusEnum;
|
|
144
155
|
(function (JoinRequestStatusEnum) {
|
|
@@ -163,6 +174,7 @@ var FeedDataTypeEnum;
|
|
|
163
174
|
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
164
175
|
FeedDataTypeEnum["Clip"] = "clip";
|
|
165
176
|
FeedDataTypeEnum["Poll"] = "poll";
|
|
177
|
+
FeedDataTypeEnum["Room"] = "room";
|
|
166
178
|
})(FeedDataTypeEnum || (FeedDataTypeEnum = {}));
|
|
167
179
|
var FeedSortByEnum;
|
|
168
180
|
(function (FeedSortByEnum) {
|
|
@@ -199,6 +211,16 @@ var AmityEventResponseStatus;
|
|
|
199
211
|
AmityEventResponseStatus["Going"] = "going";
|
|
200
212
|
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
201
213
|
})(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
|
|
214
|
+
var AmityEventSortOption;
|
|
215
|
+
(function (AmityEventSortOption) {
|
|
216
|
+
AmityEventSortOption["StartTime"] = "startTime";
|
|
217
|
+
AmityEventSortOption["CreatedAt"] = "createdAt";
|
|
218
|
+
})(AmityEventSortOption || (AmityEventSortOption = {}));
|
|
219
|
+
var AmityEventOrderOption;
|
|
220
|
+
(function (AmityEventOrderOption) {
|
|
221
|
+
AmityEventOrderOption["Ascending"] = "asc";
|
|
222
|
+
AmityEventOrderOption["Descending"] = "desc";
|
|
223
|
+
})(AmityEventOrderOption || (AmityEventOrderOption = {}));
|
|
202
224
|
|
|
203
225
|
function getVersion() {
|
|
204
226
|
try {
|
|
@@ -648,9 +670,10 @@ const idResolvers = {
|
|
|
648
670
|
notificationTraySeen: ({ userId }) => userId,
|
|
649
671
|
invitation: ({ _id }) => _id,
|
|
650
672
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
673
|
+
room: ({ roomId }) => roomId,
|
|
674
|
+
viewer: ({ userId }) => userId,
|
|
651
675
|
event: ({ eventId }) => eventId,
|
|
652
|
-
eventResponse: ({
|
|
653
|
-
discussionCommunity: ({ communityId }) => communityId,
|
|
676
|
+
eventResponse: ({ userId }) => userId,
|
|
654
677
|
};
|
|
655
678
|
/**
|
|
656
679
|
* Retrieve the id resolver matching a domain name
|
|
@@ -706,9 +729,10 @@ const PAYLOAD2MODEL = {
|
|
|
706
729
|
notificationTrayItems: 'notificationTrayItem',
|
|
707
730
|
invitations: 'invitation',
|
|
708
731
|
joinRequests: 'joinRequest',
|
|
732
|
+
rooms: 'room',
|
|
709
733
|
events: 'event',
|
|
710
|
-
|
|
711
|
-
|
|
734
|
+
viewers: 'viewer',
|
|
735
|
+
eventResponses: 'eventResponse',
|
|
712
736
|
};
|
|
713
737
|
/** hidden */
|
|
714
738
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -1508,6 +1532,34 @@ async function modifyMqttConnection() {
|
|
|
1508
1532
|
}
|
|
1509
1533
|
}
|
|
1510
1534
|
|
|
1535
|
+
const userLinkedObject = (user) => {
|
|
1536
|
+
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
1537
|
+
var _a;
|
|
1538
|
+
if (!user.avatarFileId)
|
|
1539
|
+
return undefined;
|
|
1540
|
+
const avatar = (_a = pullFromCache([
|
|
1541
|
+
'file',
|
|
1542
|
+
'get',
|
|
1543
|
+
`${user.avatarFileId}`,
|
|
1544
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1545
|
+
return avatar;
|
|
1546
|
+
} });
|
|
1547
|
+
};
|
|
1548
|
+
|
|
1549
|
+
/* begin_public_function
|
|
1550
|
+
id: client.get_current_user
|
|
1551
|
+
*/
|
|
1552
|
+
const getCurrentUser = () => {
|
|
1553
|
+
var _a;
|
|
1554
|
+
const client = getActiveClient();
|
|
1555
|
+
if (!client) {
|
|
1556
|
+
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
1557
|
+
}
|
|
1558
|
+
const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1559
|
+
return cache ? userLinkedObject(cache) : null;
|
|
1560
|
+
};
|
|
1561
|
+
/* end_public_function */
|
|
1562
|
+
|
|
1511
1563
|
var SubscriptionLevels;
|
|
1512
1564
|
(function (SubscriptionLevels) {
|
|
1513
1565
|
SubscriptionLevels["COMMUNITY"] = "community";
|
|
@@ -1613,6 +1665,14 @@ const getLiveStreamTopic = () => {
|
|
|
1613
1665
|
const getLiveReactionTopic = (post) => {
|
|
1614
1666
|
return `${post.path}/liveReaction`;
|
|
1615
1667
|
};
|
|
1668
|
+
const getRoomWatcherTopic = (room) => {
|
|
1669
|
+
const user = getCurrentUser();
|
|
1670
|
+
return `${getNetworkId(user)}/room/${room._id}`;
|
|
1671
|
+
};
|
|
1672
|
+
const getRoomStreamerTopic = (room) => {
|
|
1673
|
+
const user = getCurrentUser();
|
|
1674
|
+
return `${getNetworkId(user)}/room/${room.roomId}/streamer`;
|
|
1675
|
+
};
|
|
1616
1676
|
function subscribeTopic(topic, callback) {
|
|
1617
1677
|
const { mqtt } = getActiveClient();
|
|
1618
1678
|
if (!mqtt)
|
|
@@ -21039,20 +21099,6 @@ const getChannelMessagePreview = (channelId) => {
|
|
|
21039
21099
|
return ((_b = (_a = pullFromCache(['messagePreviewChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : null);
|
|
21040
21100
|
};
|
|
21041
21101
|
|
|
21042
|
-
const userLinkedObject = (user) => {
|
|
21043
|
-
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
21044
|
-
var _a;
|
|
21045
|
-
if (!user.avatarFileId)
|
|
21046
|
-
return undefined;
|
|
21047
|
-
const avatar = (_a = pullFromCache([
|
|
21048
|
-
'file',
|
|
21049
|
-
'get',
|
|
21050
|
-
`${user.avatarFileId}`,
|
|
21051
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21052
|
-
return avatar;
|
|
21053
|
-
} });
|
|
21054
|
-
};
|
|
21055
|
-
|
|
21056
21102
|
const getChannelMessagePreviewWithUser = (channel) => {
|
|
21057
21103
|
var _a;
|
|
21058
21104
|
const messagePreview = channel.messagePreviewId
|
|
@@ -23358,6 +23404,13 @@ const getToken = async ({ params, options, }) => {
|
|
|
23358
23404
|
return data;
|
|
23359
23405
|
};
|
|
23360
23406
|
|
|
23407
|
+
function prepareUserPayload(response) {
|
|
23408
|
+
return {
|
|
23409
|
+
users: response.users.map(convertRawUserToInternalUser),
|
|
23410
|
+
files: response.files,
|
|
23411
|
+
};
|
|
23412
|
+
}
|
|
23413
|
+
|
|
23361
23414
|
/**
|
|
23362
23415
|
* A util to set or refresh client token
|
|
23363
23416
|
*
|
|
@@ -23374,7 +23427,7 @@ const setClientToken = async (params) => {
|
|
|
23374
23427
|
const client = getActiveClient();
|
|
23375
23428
|
// begin establishing session
|
|
23376
23429
|
setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
|
|
23377
|
-
const { accessToken, users, expiresAt, issuedAt, userType } = await getToken(params);
|
|
23430
|
+
const { accessToken, users, expiresAt, issuedAt, userType, files } = await getToken(params);
|
|
23378
23431
|
// manually setup the token for http transport
|
|
23379
23432
|
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
23380
23433
|
client.http.defaults.metadata = {
|
|
@@ -23390,6 +23443,10 @@ const setClientToken = async (params) => {
|
|
|
23390
23443
|
};
|
|
23391
23444
|
client.token = { accessToken, issuedAt, expiresAt };
|
|
23392
23445
|
setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
|
|
23446
|
+
ingestInCache(prepareUserPayload({
|
|
23447
|
+
users,
|
|
23448
|
+
files,
|
|
23449
|
+
}));
|
|
23393
23450
|
return { accessToken, users, userType };
|
|
23394
23451
|
};
|
|
23395
23452
|
|
|
@@ -23439,7 +23496,7 @@ const setVisitorClientToken = async (params) => {
|
|
|
23439
23496
|
const client = getActiveClient();
|
|
23440
23497
|
// begin establishing session
|
|
23441
23498
|
setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
|
|
23442
|
-
const { accessToken, users, expiresAt, issuedAt, userType } = await getVisitorToken(params);
|
|
23499
|
+
const { accessToken, users, expiresAt, issuedAt, userType, files } = await getVisitorToken(params);
|
|
23443
23500
|
// manually setup the token for http transport
|
|
23444
23501
|
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
23445
23502
|
client.http.defaults.metadata = {
|
|
@@ -23449,16 +23506,13 @@ const setVisitorClientToken = async (params) => {
|
|
|
23449
23506
|
};
|
|
23450
23507
|
client.token = { accessToken, issuedAt, expiresAt };
|
|
23451
23508
|
setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
|
|
23509
|
+
ingestInCache(prepareUserPayload({
|
|
23510
|
+
users,
|
|
23511
|
+
files,
|
|
23512
|
+
}));
|
|
23452
23513
|
return { accessToken, users, userType };
|
|
23453
23514
|
};
|
|
23454
23515
|
|
|
23455
|
-
function prepareUserPayload(response) {
|
|
23456
|
-
return {
|
|
23457
|
-
users: response.users.map(convertRawUserToInternalUser),
|
|
23458
|
-
files: response.files,
|
|
23459
|
-
};
|
|
23460
|
-
}
|
|
23461
|
-
|
|
23462
23516
|
const createUserEventSubscriber = (event, callback) => {
|
|
23463
23517
|
const client = getActiveClient();
|
|
23464
23518
|
const filter = (data) => {
|
|
@@ -24630,19 +24684,19 @@ class LiveReactionSyncEngine {
|
|
|
24630
24684
|
// Clear buffer
|
|
24631
24685
|
this.clearBuffer();
|
|
24632
24686
|
const payloads = reactions.reduce((prev, curr) => {
|
|
24633
|
-
const {
|
|
24634
|
-
if (!prev[
|
|
24687
|
+
const { roomId } = curr, rest = __rest(curr, ["roomId"]);
|
|
24688
|
+
if (!prev[roomId]) {
|
|
24635
24689
|
// eslint-disable-next-line no-param-reassign
|
|
24636
|
-
prev[
|
|
24690
|
+
prev[roomId] = [rest];
|
|
24637
24691
|
}
|
|
24638
24692
|
else
|
|
24639
|
-
prev[
|
|
24693
|
+
prev[roomId].push(rest);
|
|
24640
24694
|
return prev;
|
|
24641
24695
|
}, {});
|
|
24642
24696
|
// Call server api `POST /api/v1/reactions/live` to sync live reactions
|
|
24643
|
-
Object.entries(payloads).forEach(([
|
|
24697
|
+
Object.entries(payloads).forEach(([roomId, reactions]) => {
|
|
24644
24698
|
createLiveReaction({
|
|
24645
|
-
liveStreamId:
|
|
24699
|
+
liveStreamId: roomId,
|
|
24646
24700
|
reactions,
|
|
24647
24701
|
});
|
|
24648
24702
|
});
|
|
@@ -24927,7 +24981,6 @@ const setCurrentUserType = (userType) => {
|
|
|
24927
24981
|
const setCurrentUser = ({ user, userType, }) => {
|
|
24928
24982
|
setActiveUser(user);
|
|
24929
24983
|
setCurrentUserType(userType);
|
|
24930
|
-
pushToCache(['user', 'get', user.userId], user);
|
|
24931
24984
|
};
|
|
24932
24985
|
|
|
24933
24986
|
/* eslint-disable no-param-reassign */
|
|
@@ -25135,23 +25188,6 @@ const loginAsVisitor = async (params) => {
|
|
|
25135
25188
|
};
|
|
25136
25189
|
/* end_public_function */
|
|
25137
25190
|
|
|
25138
|
-
/* begin_public_function
|
|
25139
|
-
id: client.get_current_user
|
|
25140
|
-
*/
|
|
25141
|
-
const getCurrentUser = () => {
|
|
25142
|
-
var _a;
|
|
25143
|
-
const client = getActiveClient();
|
|
25144
|
-
if (!client) {
|
|
25145
|
-
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
25146
|
-
}
|
|
25147
|
-
const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
25148
|
-
if (!cache) {
|
|
25149
|
-
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
25150
|
-
}
|
|
25151
|
-
return userLinkedObject(cache);
|
|
25152
|
-
};
|
|
25153
|
-
/* end_public_function */
|
|
25154
|
-
|
|
25155
25191
|
/* begin_public_function
|
|
25156
25192
|
id: client.renew_access_token
|
|
25157
25193
|
*/
|
|
@@ -26051,6 +26087,9 @@ function setUploadedFileAccessType(accessType) {
|
|
|
26051
26087
|
GlobalFileAccessType$1.getInstance().setFileAccessType(accessType);
|
|
26052
26088
|
}
|
|
26053
26089
|
|
|
26090
|
+
/**
|
|
26091
|
+
* @deprecated This function will to be deprecated and use the new getLinkPreviewMetadata
|
|
26092
|
+
*/
|
|
26054
26093
|
/**
|
|
26055
26094
|
* ```js
|
|
26056
26095
|
* import { fetchLinkPreview } from '@amityco/ts-sdk'
|
|
@@ -26073,6 +26112,24 @@ const fetchLinkPreview = async (url) => {
|
|
|
26073
26112
|
return data;
|
|
26074
26113
|
};
|
|
26075
26114
|
|
|
26115
|
+
/**
|
|
26116
|
+
* ```js
|
|
26117
|
+
* import { getLinkPreviewMetadata } from '@amityco/ts-sdk'
|
|
26118
|
+
* const { title, description, imageUrl } = getLinkPreviewMetadata('https://www.example.com/')
|
|
26119
|
+
* ```
|
|
26120
|
+
*
|
|
26121
|
+
*
|
|
26122
|
+
* @param url the url to fetch link preview
|
|
26123
|
+
* @returns A {@link Amity.LinkPreviewMetadata} instance
|
|
26124
|
+
*
|
|
26125
|
+
* @category Client API
|
|
26126
|
+
* */
|
|
26127
|
+
const getLinkPreviewMetadata = async (url) => {
|
|
26128
|
+
const client = getActiveClient();
|
|
26129
|
+
const { data } = await client.http.get(`/api/v1/link-preview?url=${url}`);
|
|
26130
|
+
return data;
|
|
26131
|
+
};
|
|
26132
|
+
|
|
26076
26133
|
/**
|
|
26077
26134
|
* ```js
|
|
26078
26135
|
* import Client from '@amityco/ts-sdk'
|
|
@@ -26131,7 +26188,7 @@ const setBotClientToken = async (params) => {
|
|
|
26131
26188
|
const client = getActiveClient();
|
|
26132
26189
|
// begin establishing session
|
|
26133
26190
|
setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
|
|
26134
|
-
const { accessToken, users, expiresAt, issuedAt, userType } = await getBotToken(params);
|
|
26191
|
+
const { accessToken, users, expiresAt, issuedAt, userType, files } = await getBotToken(params);
|
|
26135
26192
|
// manually setup the token for http transport
|
|
26136
26193
|
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
26137
26194
|
client.http.defaults.metadata = {
|
|
@@ -26141,6 +26198,10 @@ const setBotClientToken = async (params) => {
|
|
|
26141
26198
|
};
|
|
26142
26199
|
client.token = { accessToken, issuedAt, expiresAt };
|
|
26143
26200
|
setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
|
|
26201
|
+
ingestInCache(prepareUserPayload({
|
|
26202
|
+
users,
|
|
26203
|
+
files,
|
|
26204
|
+
}));
|
|
26144
26205
|
return { accessToken, users, userType };
|
|
26145
26206
|
};
|
|
26146
26207
|
|
|
@@ -26581,7 +26642,7 @@ const getUserUnread = (callback) => {
|
|
|
26581
26642
|
};
|
|
26582
26643
|
};
|
|
26583
26644
|
|
|
26584
|
-
var index$
|
|
26645
|
+
var index$r = /*#__PURE__*/Object.freeze({
|
|
26585
26646
|
__proto__: null,
|
|
26586
26647
|
getActiveClient: getActiveClient,
|
|
26587
26648
|
getActiveUser: getActiveUser,
|
|
@@ -26598,6 +26659,7 @@ var index$p = /*#__PURE__*/Object.freeze({
|
|
|
26598
26659
|
enableUnreadCount: enableUnreadCount,
|
|
26599
26660
|
setUploadedFileAccessType: setUploadedFileAccessType,
|
|
26600
26661
|
fetchLinkPreview: fetchLinkPreview,
|
|
26662
|
+
getLinkPreviewMetadata: getLinkPreviewMetadata,
|
|
26601
26663
|
getSocialSettings: getSocialSettings,
|
|
26602
26664
|
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
26603
26665
|
loginAsVisitor: loginAsVisitor,
|
|
@@ -27800,7 +27862,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
27800
27862
|
};
|
|
27801
27863
|
/* end_public_function */
|
|
27802
27864
|
|
|
27803
|
-
var index$
|
|
27865
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
27804
27866
|
__proto__: null,
|
|
27805
27867
|
blockUser: blockUser,
|
|
27806
27868
|
unBlockUser: unBlockUser,
|
|
@@ -28153,7 +28215,7 @@ getChannel$1.locally = (channelId) => {
|
|
|
28153
28215
|
* @category Stream API
|
|
28154
28216
|
* @async
|
|
28155
28217
|
*/
|
|
28156
|
-
const getLiveChat = async (stream) => {
|
|
28218
|
+
const getLiveChat$1 = async (stream) => {
|
|
28157
28219
|
var _a;
|
|
28158
28220
|
const client = getActiveClient();
|
|
28159
28221
|
client.log('stream/getLiveChat', stream.streamId);
|
|
@@ -28220,7 +28282,7 @@ const streamLinkedObject = (stream) => {
|
|
|
28220
28282
|
return streamLinkedObject(streamCache);
|
|
28221
28283
|
})
|
|
28222
28284
|
.filter(isNonNullable);
|
|
28223
|
-
}, getLiveChat: () => getLiveChat(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
|
|
28285
|
+
}, getLiveChat: () => getLiveChat$1(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
|
|
28224
28286
|
return stream.watcherUrl;
|
|
28225
28287
|
} });
|
|
28226
28288
|
};
|
|
@@ -28328,405 +28390,294 @@ function isAmityAudioPost(post) {
|
|
|
28328
28390
|
'fileId' in post.data &&
|
|
28329
28391
|
post.dataType === 'audio');
|
|
28330
28392
|
}
|
|
28393
|
+
function isAmityRoomPost(post) {
|
|
28394
|
+
return !!(post.data &&
|
|
28395
|
+
typeof post.data !== 'string' &&
|
|
28396
|
+
'roomId' in post.data &&
|
|
28397
|
+
post.dataType === 'room');
|
|
28398
|
+
}
|
|
28331
28399
|
|
|
28332
|
-
|
|
28333
|
-
|
|
28334
|
-
|
|
28335
|
-
|
|
28336
|
-
|
|
28337
|
-
|
|
28338
|
-
|
|
28339
|
-
|
|
28340
|
-
|
|
28341
|
-
|
|
28342
|
-
|
|
28343
|
-
|
|
28344
|
-
|
|
28345
|
-
|
|
28346
|
-
|
|
28347
|
-
|
|
28348
|
-
|
|
28349
|
-
|
|
28350
|
-
|
|
28351
|
-
|
|
28352
|
-
|
|
28353
|
-
|
|
28354
|
-
|
|
28355
|
-
|
|
28356
|
-
|
|
28357
|
-
|
|
28358
|
-
|
|
28359
|
-
|
|
28360
|
-
|
|
28361
|
-
|
|
28362
|
-
|
|
28363
|
-
|
|
28364
|
-
|
|
28365
|
-
|
|
28366
|
-
|
|
28367
|
-
|
|
28368
|
-
|
|
28369
|
-
|
|
28370
|
-
|
|
28371
|
-
|
|
28372
|
-
}
|
|
28373
|
-
|
|
28374
|
-
|
|
28375
|
-
|
|
28376
|
-
|
|
28377
|
-
: undefined;
|
|
28378
|
-
},
|
|
28379
|
-
getVideoThumbnailInfo() {
|
|
28380
|
-
var _a, _b;
|
|
28381
|
-
return isAmityVideoPost(post)
|
|
28382
|
-
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
28383
|
-
: undefined;
|
|
28384
|
-
},
|
|
28385
|
-
getFileInfo() {
|
|
28386
|
-
var _a, _b;
|
|
28387
|
-
return isAmityFilePost(post)
|
|
28388
|
-
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
28389
|
-
: undefined;
|
|
28390
|
-
},
|
|
28391
|
-
getLivestreamInfo() {
|
|
28392
|
-
var _a, _b;
|
|
28393
|
-
if (!isAmityLivestreamPost(post))
|
|
28394
|
-
return;
|
|
28395
|
-
const cache = (_b = pullFromCache([
|
|
28396
|
-
'stream',
|
|
28397
|
-
'get',
|
|
28398
|
-
(_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.streamId,
|
|
28399
|
-
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
28400
|
-
if (!cache)
|
|
28401
|
-
return;
|
|
28402
|
-
return streamLinkedObject(cache);
|
|
28403
|
-
},
|
|
28404
|
-
getPollInfo() {
|
|
28405
|
-
var _a, _b;
|
|
28406
|
-
if (!isAmityPollPost(post))
|
|
28407
|
-
return;
|
|
28408
|
-
const cache = (_b = pullFromCache(['poll', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.pollId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
28409
|
-
if (!cache)
|
|
28410
|
-
return;
|
|
28411
|
-
return cache;
|
|
28412
|
-
},
|
|
28413
|
-
getClipInfo() {
|
|
28414
|
-
var _a, _b;
|
|
28415
|
-
return isAmityClipPost(post)
|
|
28416
|
-
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
28417
|
-
: undefined;
|
|
28418
|
-
},
|
|
28419
|
-
getAudioInfo() {
|
|
28420
|
-
var _a, _b;
|
|
28421
|
-
return isAmityAudioPost(post)
|
|
28422
|
-
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
28423
|
-
: undefined;
|
|
28424
|
-
},
|
|
28425
|
-
});
|
|
28400
|
+
/**
|
|
28401
|
+
* ```js
|
|
28402
|
+
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
28403
|
+
* const stream = await getStream('foobar')
|
|
28404
|
+
* ```
|
|
28405
|
+
*
|
|
28406
|
+
* Fetches a {@link Amity.Channel} object linked with a current stream
|
|
28407
|
+
*
|
|
28408
|
+
* @param stream {@link Amity.Stream} that has linked live channel
|
|
28409
|
+
* @returns the associated {@link Amity.Channel<'live'>} object
|
|
28410
|
+
*
|
|
28411
|
+
* @category Stream API
|
|
28412
|
+
* @async
|
|
28413
|
+
*/
|
|
28414
|
+
const getLiveChat = async (room) => {
|
|
28415
|
+
var _a;
|
|
28416
|
+
const client = getActiveClient();
|
|
28417
|
+
client.log('room/getLiveChat', room.roomId);
|
|
28418
|
+
if (room.liveChannelId) {
|
|
28419
|
+
const channel = (_a = pullFromCache([
|
|
28420
|
+
'channel',
|
|
28421
|
+
'get',
|
|
28422
|
+
room.liveChannelId,
|
|
28423
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28424
|
+
if (channel)
|
|
28425
|
+
return channelLinkedObject(constructChannelObject(channel));
|
|
28426
|
+
const { data } = await getChannel$1(room.liveChannelId);
|
|
28427
|
+
return channelLinkedObject(constructChannelObject(data));
|
|
28428
|
+
}
|
|
28429
|
+
// No Channel ID
|
|
28430
|
+
// streamer: create a new live channel
|
|
28431
|
+
if (room.createdBy === client.userId) {
|
|
28432
|
+
const { data: channel } = await createChannel({
|
|
28433
|
+
type: 'live',
|
|
28434
|
+
postId: room.referenceId,
|
|
28435
|
+
roomId: room.roomId,
|
|
28436
|
+
});
|
|
28437
|
+
// Update channelId to stream object in cache
|
|
28438
|
+
mergeInCache(['room', 'get', room.roomId], {
|
|
28439
|
+
liveChannelId: channel.channelId,
|
|
28440
|
+
});
|
|
28441
|
+
return channel;
|
|
28442
|
+
}
|
|
28443
|
+
// watcher: return undefined
|
|
28444
|
+
return undefined;
|
|
28426
28445
|
};
|
|
28427
28446
|
|
|
28428
|
-
|
|
28429
|
-
|
|
28430
|
-
if (referenceType === 'message')
|
|
28431
|
-
// @ts-ignore: refactor later
|
|
28432
|
-
fireEvent('local.message.updated', { messages: [model] });
|
|
28433
|
-
else if (referenceType === 'post')
|
|
28434
|
-
// @ts-ignore: refactor later
|
|
28435
|
-
fireEvent('post.updated', { posts: [model] });
|
|
28436
|
-
else if (referenceType === 'comment')
|
|
28437
|
-
// @ts-ignore: refactor later
|
|
28438
|
-
fireEvent('comment.updated', { comments: [model] });
|
|
28439
|
-
else if (referenceType === 'story')
|
|
28440
|
-
// Need to provide all data same StoryPayload from BE
|
|
28441
|
-
fireEvent('story.updated', {
|
|
28442
|
-
categories: [],
|
|
28443
|
-
comments: [],
|
|
28444
|
-
communities: [],
|
|
28445
|
-
communityUsers: [],
|
|
28446
|
-
files: [],
|
|
28447
|
-
users: [],
|
|
28448
|
-
stories: [model],
|
|
28449
|
-
});
|
|
28447
|
+
const convertRawInvitationToInternalInvitation = (rawInvitation) => {
|
|
28448
|
+
return Object.assign(Object.assign({}, rawInvitation), { createdById: rawInvitation.createdBy });
|
|
28450
28449
|
};
|
|
28451
28450
|
|
|
28452
|
-
const
|
|
28453
|
-
|
|
28451
|
+
const prepareInvitationPayload = (rawPayload) => {
|
|
28452
|
+
return Object.assign(Object.assign({}, rawPayload), { invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation), users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
28453
|
+
};
|
|
28454
|
+
|
|
28455
|
+
/* begin_public_function
|
|
28456
|
+
id: invitation.createInvitations
|
|
28457
|
+
*/
|
|
28458
|
+
/**
|
|
28459
|
+
* ```js
|
|
28460
|
+
* import { createInvitations } from '@amityco/ts-sdk'
|
|
28461
|
+
* const created = await createInvitations({
|
|
28462
|
+
* type: string,
|
|
28463
|
+
* targetType: string,
|
|
28464
|
+
* targetId: string,
|
|
28465
|
+
* userIds: string[]
|
|
28466
|
+
* }))
|
|
28467
|
+
* ```
|
|
28468
|
+
*
|
|
28469
|
+
* Creates an {@link Amity.Invitation}
|
|
28470
|
+
*
|
|
28471
|
+
* @param bundle The data necessary to create a new {@link Amity.Invitation}
|
|
28472
|
+
* @returns The newly created {@link Amity.Invitation}
|
|
28473
|
+
*
|
|
28474
|
+
* @category Invitation API
|
|
28475
|
+
* @async
|
|
28476
|
+
*/
|
|
28477
|
+
const createInvitations = async (bundle) => {
|
|
28454
28478
|
const client = getActiveClient();
|
|
28455
|
-
client.log('
|
|
28456
|
-
|
|
28457
|
-
|
|
28458
|
-
|
|
28459
|
-
|
|
28460
|
-
|
|
28461
|
-
|
|
28462
|
-
|
|
28463
|
-
|
|
28464
|
-
|
|
28465
|
-
|
|
28466
|
-
referenceVersion,
|
|
28467
|
-
});
|
|
28468
|
-
if (client.cache) {
|
|
28469
|
-
const model = pullFromCache([
|
|
28470
|
-
referenceType,
|
|
28471
|
-
'get',
|
|
28472
|
-
referenceId,
|
|
28473
|
-
]);
|
|
28474
|
-
if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
28475
|
-
return true;
|
|
28476
|
-
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }), updatedAt: new Date().toISOString() });
|
|
28477
|
-
if (referenceType === 'comment') {
|
|
28478
|
-
fireEvent('local.comment.addReaction', {
|
|
28479
|
-
comment: updatedModel,
|
|
28480
|
-
reactor: {
|
|
28481
|
-
userId: client.userId,
|
|
28482
|
-
reactionName,
|
|
28483
|
-
reactionId: data.addedId,
|
|
28484
|
-
},
|
|
28485
|
-
});
|
|
28486
|
-
return true;
|
|
28487
|
-
}
|
|
28488
|
-
if (referenceType === 'post') {
|
|
28489
|
-
fireEvent('local.post.addReaction', {
|
|
28490
|
-
post: updatedModel,
|
|
28491
|
-
reactor: {
|
|
28492
|
-
userId: client.userId,
|
|
28493
|
-
reactionName,
|
|
28494
|
-
reactionId: data.addedId,
|
|
28495
|
-
},
|
|
28496
|
-
});
|
|
28497
|
-
return true;
|
|
28498
|
-
}
|
|
28499
|
-
if (referenceType === 'story') {
|
|
28500
|
-
fireEvent('local.story.reactionAdded', {
|
|
28501
|
-
story: updatedModel,
|
|
28502
|
-
reactor: {
|
|
28503
|
-
userId: client.userId,
|
|
28504
|
-
reactionName,
|
|
28505
|
-
reactionId: data.addedId,
|
|
28506
|
-
},
|
|
28507
|
-
});
|
|
28508
|
-
return true;
|
|
28509
|
-
}
|
|
28510
|
-
}
|
|
28511
|
-
return true;
|
|
28479
|
+
client.log('invitation/createInvitations', bundle);
|
|
28480
|
+
const { data: payload } = await client.http.post('/api/v1/invitations', bundle);
|
|
28481
|
+
const data = prepareInvitationPayload(payload);
|
|
28482
|
+
const cachedAt = client.cache && Date.now();
|
|
28483
|
+
if (client.cache)
|
|
28484
|
+
ingestInCache(data, { cachedAt });
|
|
28485
|
+
fireEvent('local.invitation.created', data.invitations);
|
|
28486
|
+
return {
|
|
28487
|
+
data: data.invitations,
|
|
28488
|
+
cachedAt,
|
|
28489
|
+
};
|
|
28512
28490
|
};
|
|
28513
|
-
|
|
28514
|
-
|
|
28491
|
+
/* end_public_function */
|
|
28492
|
+
|
|
28493
|
+
/* begin_public_function
|
|
28494
|
+
id: invitation.accept
|
|
28495
|
+
*/
|
|
28496
|
+
/**
|
|
28497
|
+
* ```js
|
|
28498
|
+
* import { acceptInvitation } from '@amityco/ts-sdk'
|
|
28499
|
+
* const isAccepted = await acceptInvitation(invitationId)
|
|
28500
|
+
* ```
|
|
28501
|
+
*
|
|
28502
|
+
* Accepts a {@link Amity.Invitation} object
|
|
28503
|
+
*
|
|
28504
|
+
* @param invitationId the {@link Amity.Invitation} to accept
|
|
28505
|
+
* @returns A success boolean if the {@link Amity.Invitation} was accepted
|
|
28506
|
+
*
|
|
28507
|
+
* @category Invitation API
|
|
28508
|
+
* @async
|
|
28509
|
+
*/
|
|
28510
|
+
const acceptInvitation = async (invitationId) => {
|
|
28511
|
+
var _a;
|
|
28515
28512
|
const client = getActiveClient();
|
|
28516
|
-
client.log('
|
|
28517
|
-
|
|
28518
|
-
|
|
28519
|
-
|
|
28520
|
-
});
|
|
28521
|
-
if (!client.cache)
|
|
28522
|
-
return;
|
|
28523
|
-
const model = pullFromCache([
|
|
28524
|
-
referenceType,
|
|
28513
|
+
client.log('invitation/acceptInvitation', invitationId);
|
|
28514
|
+
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/accept`);
|
|
28515
|
+
const invitation = (_a = pullFromCache([
|
|
28516
|
+
'invitation',
|
|
28525
28517
|
'get',
|
|
28526
|
-
|
|
28527
|
-
]);
|
|
28528
|
-
if (
|
|
28529
|
-
|
|
28530
|
-
|
|
28531
|
-
|
|
28532
|
-
|
|
28533
|
-
});
|
|
28534
|
-
dispatchReactable(referenceType, reaction);
|
|
28535
|
-
return (_e = (_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName)) !== null && _e !== void 0 ? _e : false;
|
|
28518
|
+
invitationId,
|
|
28519
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28520
|
+
if (invitation) {
|
|
28521
|
+
upsertInCache(['invitation', 'get', invitationId], { status: "approved" /* InvitationStatusEnum.Approved */ });
|
|
28522
|
+
fireEvent('local.invitation.updated', [invitation]);
|
|
28523
|
+
}
|
|
28524
|
+
return data.success;
|
|
28536
28525
|
};
|
|
28526
|
+
/* end_public_function */
|
|
28537
28527
|
|
|
28538
|
-
|
|
28539
|
-
|
|
28528
|
+
/* begin_public_function
|
|
28529
|
+
id: invitation.reject
|
|
28530
|
+
*/
|
|
28531
|
+
/**
|
|
28532
|
+
* ```js
|
|
28533
|
+
* import { rejectInvitation } from '@amityco/ts-sdk'
|
|
28534
|
+
* const isRejected = await rejectInvitation(invitationId)
|
|
28535
|
+
* ```
|
|
28536
|
+
*
|
|
28537
|
+
* Rejects a {@link Amity.Invitation} object
|
|
28538
|
+
*
|
|
28539
|
+
* @param invitationId the {@link Amity.Invitation} to reject
|
|
28540
|
+
* @returns A success boolean if the {@link Amity.Invitation} was rejected
|
|
28541
|
+
*
|
|
28542
|
+
* @category Invitation API
|
|
28543
|
+
* @async
|
|
28544
|
+
*/
|
|
28545
|
+
const rejectInvitation = async (invitationId) => {
|
|
28546
|
+
var _a;
|
|
28540
28547
|
const client = getActiveClient();
|
|
28541
|
-
client.log('
|
|
28542
|
-
|
|
28543
|
-
|
|
28544
|
-
|
|
28545
|
-
|
|
28546
|
-
|
|
28547
|
-
|
|
28548
|
-
|
|
28549
|
-
|
|
28550
|
-
|
|
28551
|
-
referenceType,
|
|
28552
|
-
reactionName,
|
|
28553
|
-
referenceVersion,
|
|
28554
|
-
},
|
|
28555
|
-
});
|
|
28556
|
-
if (client.cache) {
|
|
28557
|
-
const model = pullFromCache([
|
|
28558
|
-
referenceType,
|
|
28559
|
-
'get',
|
|
28560
|
-
referenceId,
|
|
28561
|
-
]);
|
|
28562
|
-
if (!model)
|
|
28563
|
-
return true;
|
|
28564
|
-
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }), updatedAt: new Date().toISOString() });
|
|
28565
|
-
if (referenceType === 'comment') {
|
|
28566
|
-
fireEvent('local.comment.removeReaction', {
|
|
28567
|
-
comment: updatedModel,
|
|
28568
|
-
reactor: {
|
|
28569
|
-
reactionId: data.removedId,
|
|
28570
|
-
reactionName,
|
|
28571
|
-
userId: client.userId,
|
|
28572
|
-
},
|
|
28573
|
-
});
|
|
28574
|
-
return true;
|
|
28575
|
-
}
|
|
28576
|
-
if (referenceType === 'post') {
|
|
28577
|
-
fireEvent('local.post.removeReaction', {
|
|
28578
|
-
post: updatedModel,
|
|
28579
|
-
reactor: {
|
|
28580
|
-
reactionId: data.removedId,
|
|
28581
|
-
reactionName,
|
|
28582
|
-
userId: client.userId,
|
|
28583
|
-
},
|
|
28584
|
-
});
|
|
28585
|
-
return true;
|
|
28586
|
-
}
|
|
28587
|
-
if (referenceType === 'story') {
|
|
28588
|
-
fireEvent('local.story.reactionAdded', {
|
|
28589
|
-
story: updatedModel,
|
|
28590
|
-
reactor: {
|
|
28591
|
-
userId: client.userId,
|
|
28592
|
-
reactionName,
|
|
28593
|
-
reactionId: data.removedId,
|
|
28594
|
-
},
|
|
28595
|
-
});
|
|
28596
|
-
return true;
|
|
28597
|
-
}
|
|
28548
|
+
client.log('invitation/rejectInvitation', invitationId);
|
|
28549
|
+
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/reject`);
|
|
28550
|
+
const invitation = (_a = pullFromCache([
|
|
28551
|
+
'invitation',
|
|
28552
|
+
'get',
|
|
28553
|
+
invitationId,
|
|
28554
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28555
|
+
if (invitation) {
|
|
28556
|
+
upsertInCache(['invitation', 'get', invitationId], { status: "rejected" /* InvitationStatusEnum.Rejected */ });
|
|
28557
|
+
fireEvent('local.invitation.updated', [invitation]);
|
|
28598
28558
|
}
|
|
28599
|
-
return
|
|
28559
|
+
return data.success;
|
|
28600
28560
|
};
|
|
28561
|
+
/* end_public_function */
|
|
28601
28562
|
|
|
28602
|
-
const
|
|
28603
|
-
|
|
28604
|
-
return addReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
|
|
28563
|
+
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
28564
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
28605
28565
|
};
|
|
28606
28566
|
|
|
28607
|
-
const
|
|
28608
|
-
|
|
28609
|
-
|
|
28610
|
-
|
|
28611
|
-
|
|
28612
|
-
|
|
28613
|
-
};
|
|
28614
|
-
return (_b = pullFromCache([
|
|
28615
|
-
'messageMarker',
|
|
28616
|
-
'get',
|
|
28617
|
-
getResolver('messageMarker')(key),
|
|
28618
|
-
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
28619
|
-
};
|
|
28620
|
-
const getMessageReadCount = (message, marker) => {
|
|
28621
|
-
var _a;
|
|
28622
|
-
// Look in the marker param first
|
|
28623
|
-
return (_a = marker !== null && marker !== void 0 ? marker :
|
|
28624
|
-
// If the marker param is not set, look in the cache
|
|
28625
|
-
getCachedMarker(message)) !== null && _a !== void 0 ? _a : { readCount: 0, deliveredCount: 0 };
|
|
28626
|
-
}; // and if not found in cache use default value `0`
|
|
28627
|
-
|
|
28628
|
-
const removeReactionToMessage = (reactionName, message) => {
|
|
28629
|
-
const isMessageV3 = message.publicId !== message.messageId;
|
|
28630
|
-
return removeReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
|
|
28631
|
-
};
|
|
28632
|
-
|
|
28633
|
-
const messageLinkedObject = (message) => {
|
|
28634
|
-
const rest = __rest(message, ["creatorPrivateId"]);
|
|
28635
|
-
return Object.assign(Object.assign({}, rest), { get readCount() {
|
|
28636
|
-
return getMessageReadCount(message).readCount;
|
|
28567
|
+
const invitationLinkedObject = (invitation) => {
|
|
28568
|
+
return Object.assign(Object.assign({}, invitation), { get user() {
|
|
28569
|
+
const cacheData = pullFromCache(['user', 'get', invitation.invitedUserPublicId]);
|
|
28570
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
28571
|
+
return userLinkedObject(cacheData.data);
|
|
28572
|
+
return undefined;
|
|
28637
28573
|
},
|
|
28638
|
-
get
|
|
28639
|
-
|
|
28574
|
+
get createdBy() {
|
|
28575
|
+
const cacheData = pullFromCache(['user', 'get', invitation.inviterUserPublicId]);
|
|
28576
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
28577
|
+
return userLinkedObject(cacheData.data);
|
|
28578
|
+
return undefined;
|
|
28640
28579
|
},
|
|
28641
|
-
get
|
|
28642
|
-
|
|
28643
|
-
|
|
28644
|
-
|
|
28645
|
-
|
|
28646
|
-
|
|
28647
|
-
|
|
28648
|
-
|
|
28649
|
-
|
|
28650
|
-
const user = (_a = pullFromCache(['user', 'get', reactor.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28651
|
-
if (!user)
|
|
28580
|
+
get target() {
|
|
28581
|
+
if (invitation.targetType === 'community') {
|
|
28582
|
+
const cacheData = pullFromCache([
|
|
28583
|
+
'community',
|
|
28584
|
+
'get',
|
|
28585
|
+
invitation.targetId,
|
|
28586
|
+
]);
|
|
28587
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
28588
|
+
return cacheData.data;
|
|
28652
28589
|
return undefined;
|
|
28653
|
-
|
|
28590
|
+
}
|
|
28591
|
+
return undefined;
|
|
28592
|
+
}, accept: async () => {
|
|
28593
|
+
await acceptInvitation(invitation._id);
|
|
28594
|
+
}, reject: async () => {
|
|
28595
|
+
await rejectInvitation(invitation._id);
|
|
28654
28596
|
} });
|
|
28655
28597
|
};
|
|
28656
28598
|
|
|
28657
|
-
|
|
28658
|
-
|
|
28659
|
-
|
|
28660
|
-
|
|
28661
|
-
|
|
28662
|
-
|
|
28663
|
-
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
|
|
28667
|
-
|
|
28668
|
-
|
|
28669
|
-
|
|
28670
|
-
|
|
28671
|
-
|
|
28672
|
-
|
|
28673
|
-
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
|
|
28682
|
-
}
|
|
28683
|
-
|
|
28684
|
-
|
|
28685
|
-
|
|
28686
|
-
|
|
28687
|
-
return cacheData.data || undefined;
|
|
28688
|
-
},
|
|
28689
|
-
get image9_16() {
|
|
28690
|
-
const cacheData = pullFromCache(['file', 'get', image916]);
|
|
28691
|
-
if (!cacheData)
|
|
28692
|
-
return undefined;
|
|
28693
|
-
return cacheData.data || undefined;
|
|
28694
|
-
} });
|
|
28599
|
+
/* begin_public_function
|
|
28600
|
+
id: invitation.get
|
|
28601
|
+
*/
|
|
28602
|
+
/**
|
|
28603
|
+
* ```js
|
|
28604
|
+
* import { getInvitation } from '@amityco/ts-sdk'
|
|
28605
|
+
* const { invitation } = await getInvitation(targetType, targetId)
|
|
28606
|
+
* ```
|
|
28607
|
+
*
|
|
28608
|
+
* Get a {@link Amity.Invitation} object
|
|
28609
|
+
*
|
|
28610
|
+
* @param targetType The type of the target of the {@link Amity.Invitation}
|
|
28611
|
+
* @param targetId The ID of the target of the {@link Amity.Invitation}
|
|
28612
|
+
* @returns A {@link Amity.Invitation} object
|
|
28613
|
+
*
|
|
28614
|
+
* @category Invitation API
|
|
28615
|
+
* @async
|
|
28616
|
+
*/
|
|
28617
|
+
const getInvitation = async (params) => {
|
|
28618
|
+
const client = getActiveClient();
|
|
28619
|
+
client.log('invitation/getInvitation', params.targetType, params.targetId, params.type);
|
|
28620
|
+
const { data: payload } = await client.http.get(`/api/v1/invitations/me`, { params });
|
|
28621
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
28622
|
+
const cachedAt = client.cache && Date.now();
|
|
28623
|
+
if (client.cache)
|
|
28624
|
+
ingestInCache(data, { cachedAt });
|
|
28625
|
+
return {
|
|
28626
|
+
data: data.invitations[0] ? invitationLinkedObject(data.invitations[0]) : undefined,
|
|
28627
|
+
cachedAt,
|
|
28628
|
+
};
|
|
28695
28629
|
};
|
|
28630
|
+
/* end_public_function */
|
|
28696
28631
|
|
|
28697
|
-
const
|
|
28698
|
-
|
|
28699
|
-
|
|
28700
|
-
|
|
28701
|
-
var _a;
|
|
28702
|
-
return ((_a = cache.data) === null || _a === void 0 ? void 0 : _a.userInternalId) === pinnedPost.pinnedBy;
|
|
28703
|
-
})) === null || _a === void 0 ? void 0 : _a.data;
|
|
28704
|
-
return Object.assign(Object.assign({}, pinnedPost), { pinnedBy,
|
|
28705
|
-
get post() {
|
|
28706
|
-
if (!(postCached === null || postCached === void 0 ? void 0 : postCached.data))
|
|
28632
|
+
const roomLinkedObject = (room) => {
|
|
28633
|
+
return Object.assign(Object.assign({}, room), { get post() {
|
|
28634
|
+
var _a;
|
|
28635
|
+
if (room.referenceType !== 'post')
|
|
28707
28636
|
return;
|
|
28708
|
-
return
|
|
28637
|
+
return (_a = pullFromCache(['post', 'get', room.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28709
28638
|
},
|
|
28710
|
-
get
|
|
28711
|
-
|
|
28712
|
-
|
|
28713
|
-
'get',
|
|
28714
|
-
postCached === null || postCached === void 0 ? void 0 : postCached.data.targetId,
|
|
28715
|
-
]);
|
|
28716
|
-
if (!(pinTarget === null || pinTarget === void 0 ? void 0 : pinTarget.data))
|
|
28639
|
+
get community() {
|
|
28640
|
+
var _a;
|
|
28641
|
+
if (room.targetType !== 'community')
|
|
28717
28642
|
return;
|
|
28718
|
-
return
|
|
28643
|
+
return (_a = pullFromCache(['community', 'get', room.targetId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28644
|
+
},
|
|
28645
|
+
get user() {
|
|
28646
|
+
var _a;
|
|
28647
|
+
const user = (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28648
|
+
return user ? userLinkedObject(user) : user;
|
|
28649
|
+
},
|
|
28650
|
+
get childRooms() {
|
|
28651
|
+
if (!room.childRoomIds || room.childRoomIds.length === 0)
|
|
28652
|
+
return [];
|
|
28653
|
+
return room.childRoomIds
|
|
28654
|
+
.map(id => {
|
|
28655
|
+
var _a;
|
|
28656
|
+
const roomCache = (_a = pullFromCache(['room', 'get', id])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28657
|
+
if (!roomCache)
|
|
28658
|
+
return undefined;
|
|
28659
|
+
return roomLinkedObject(roomCache);
|
|
28660
|
+
})
|
|
28661
|
+
.filter(isNonNullable);
|
|
28662
|
+
}, participants: room.participants.map(participant => (Object.assign(Object.assign({}, participant), { get user() {
|
|
28663
|
+
var _a;
|
|
28664
|
+
const user = (_a = pullFromCache(['user', 'get', participant.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28665
|
+
return user ? userLinkedObject(user) : user;
|
|
28666
|
+
} }))), getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
|
|
28667
|
+
type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
|
|
28668
|
+
targetType: 'room',
|
|
28669
|
+
targetId: room.roomId,
|
|
28670
|
+
userIds: [userId],
|
|
28671
|
+
}), getInvitations: async () => {
|
|
28672
|
+
const { data } = await getInvitation({
|
|
28673
|
+
targetId: room.roomId,
|
|
28674
|
+
targetType: 'room',
|
|
28675
|
+
type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
|
|
28676
|
+
});
|
|
28677
|
+
return data;
|
|
28719
28678
|
} });
|
|
28720
28679
|
};
|
|
28721
28680
|
|
|
28722
|
-
const notificationTrayLinkedObject = (noti) => {
|
|
28723
|
-
return Object.assign(Object.assign({}, noti), { isSeen: noti.lastSeenAt > noti.lastOccurredAt, isRecent: new Date(noti.lastOccurredAt).getTime() >= Date.now() - WEEK, users: noti.actors
|
|
28724
|
-
.map(({ publicId }) => pullFromCache(['user', 'get', publicId]))
|
|
28725
|
-
.filter(isNonNullable)
|
|
28726
|
-
.map(({ data }) => data)
|
|
28727
|
-
.map(user => userLinkedObject(user)) });
|
|
28728
|
-
};
|
|
28729
|
-
|
|
28730
28681
|
/*
|
|
28731
28682
|
* verifies membership status
|
|
28732
28683
|
*/
|
|
@@ -29292,196 +29243,11 @@ const getJoinRequests = (params, callback, config) => {
|
|
|
29292
29243
|
};
|
|
29293
29244
|
};
|
|
29294
29245
|
|
|
29295
|
-
const convertRawInvitationToInternalInvitation = (rawInvitation) => {
|
|
29296
|
-
return Object.assign(Object.assign({}, rawInvitation), { createdById: rawInvitation.createdBy });
|
|
29297
|
-
};
|
|
29298
|
-
|
|
29299
|
-
const prepareInvitationPayload = (rawPayload) => {
|
|
29300
|
-
return Object.assign(Object.assign({}, rawPayload), { invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation), users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
29301
|
-
};
|
|
29302
|
-
|
|
29303
|
-
/* begin_public_function
|
|
29304
|
-
id: invitation.createInvitations
|
|
29305
|
-
*/
|
|
29306
|
-
/**
|
|
29307
|
-
* ```js
|
|
29308
|
-
* import { createInvitations } from '@amityco/ts-sdk'
|
|
29309
|
-
* const created = await createInvitations({
|
|
29310
|
-
* type: string,
|
|
29311
|
-
* targetType: string,
|
|
29312
|
-
* targetId: string,
|
|
29313
|
-
* userIds: string[]
|
|
29314
|
-
* }))
|
|
29315
|
-
* ```
|
|
29316
|
-
*
|
|
29317
|
-
* Creates an {@link Amity.Invitation}
|
|
29318
|
-
*
|
|
29319
|
-
* @param bundle The data necessary to create a new {@link Amity.Invitation}
|
|
29320
|
-
* @returns The newly created {@link Amity.Invitation}
|
|
29321
|
-
*
|
|
29322
|
-
* @category Invitation API
|
|
29323
|
-
* @async
|
|
29324
|
-
*/
|
|
29325
|
-
const createInvitations = async (bundle) => {
|
|
29326
|
-
const client = getActiveClient();
|
|
29327
|
-
client.log('invitation/createInvitations', bundle);
|
|
29328
|
-
const { data: payload } = await client.http.post('/api/v1/invitations', bundle);
|
|
29329
|
-
const data = prepareInvitationPayload(payload);
|
|
29330
|
-
const cachedAt = client.cache && Date.now();
|
|
29331
|
-
if (client.cache)
|
|
29332
|
-
ingestInCache(data, { cachedAt });
|
|
29333
|
-
fireEvent('local.invitation.created', data.invitations);
|
|
29334
|
-
return {
|
|
29335
|
-
data: data.invitations,
|
|
29336
|
-
cachedAt,
|
|
29337
|
-
};
|
|
29338
|
-
};
|
|
29339
|
-
/* end_public_function */
|
|
29340
|
-
|
|
29341
|
-
/* begin_public_function
|
|
29342
|
-
id: invitation.accept
|
|
29343
|
-
*/
|
|
29344
|
-
/**
|
|
29345
|
-
* ```js
|
|
29346
|
-
* import { acceptInvitation } from '@amityco/ts-sdk'
|
|
29347
|
-
* const isAccepted = await acceptInvitation(invitationId)
|
|
29348
|
-
* ```
|
|
29349
|
-
*
|
|
29350
|
-
* Accepts a {@link Amity.Invitation} object
|
|
29351
|
-
*
|
|
29352
|
-
* @param invitationId the {@link Amity.Invitation} to accept
|
|
29353
|
-
* @returns A success boolean if the {@link Amity.Invitation} was accepted
|
|
29354
|
-
*
|
|
29355
|
-
* @category Invitation API
|
|
29356
|
-
* @async
|
|
29357
|
-
*/
|
|
29358
|
-
const acceptInvitation = async (invitationId) => {
|
|
29359
|
-
var _a;
|
|
29360
|
-
const client = getActiveClient();
|
|
29361
|
-
client.log('invitation/acceptInvitation', invitationId);
|
|
29362
|
-
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/accept`);
|
|
29363
|
-
const invitation = (_a = pullFromCache([
|
|
29364
|
-
'invitation',
|
|
29365
|
-
'get',
|
|
29366
|
-
invitationId,
|
|
29367
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29368
|
-
if (invitation) {
|
|
29369
|
-
upsertInCache(['invitation', 'get', invitationId], { status: "approved" /* InvitationStatusEnum.Approved */ });
|
|
29370
|
-
fireEvent('local.invitation.updated', [invitation]);
|
|
29371
|
-
}
|
|
29372
|
-
return data.success;
|
|
29373
|
-
};
|
|
29374
|
-
/* end_public_function */
|
|
29375
|
-
|
|
29376
|
-
/* begin_public_function
|
|
29377
|
-
id: invitation.reject
|
|
29378
|
-
*/
|
|
29379
|
-
/**
|
|
29380
|
-
* ```js
|
|
29381
|
-
* import { rejectInvitation } from '@amityco/ts-sdk'
|
|
29382
|
-
* const isRejected = await rejectInvitation(invitationId)
|
|
29383
|
-
* ```
|
|
29384
|
-
*
|
|
29385
|
-
* Rejects a {@link Amity.Invitation} object
|
|
29386
|
-
*
|
|
29387
|
-
* @param invitationId the {@link Amity.Invitation} to reject
|
|
29388
|
-
* @returns A success boolean if the {@link Amity.Invitation} was rejected
|
|
29389
|
-
*
|
|
29390
|
-
* @category Invitation API
|
|
29391
|
-
* @async
|
|
29392
|
-
*/
|
|
29393
|
-
const rejectInvitation = async (invitationId) => {
|
|
29394
|
-
var _a;
|
|
29395
|
-
const client = getActiveClient();
|
|
29396
|
-
client.log('invitation/rejectInvitation', invitationId);
|
|
29397
|
-
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/reject`);
|
|
29398
|
-
const invitation = (_a = pullFromCache([
|
|
29399
|
-
'invitation',
|
|
29400
|
-
'get',
|
|
29401
|
-
invitationId,
|
|
29402
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29403
|
-
if (invitation) {
|
|
29404
|
-
upsertInCache(['invitation', 'get', invitationId], { status: "rejected" /* InvitationStatusEnum.Rejected */ });
|
|
29405
|
-
fireEvent('local.invitation.updated', [invitation]);
|
|
29406
|
-
}
|
|
29407
|
-
return data.success;
|
|
29408
|
-
};
|
|
29409
|
-
/* end_public_function */
|
|
29410
|
-
|
|
29411
|
-
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
29412
|
-
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
29413
|
-
};
|
|
29414
|
-
|
|
29415
|
-
const invitationLinkedObject = (invitation) => {
|
|
29416
|
-
return Object.assign(Object.assign({}, invitation), { get user() {
|
|
29417
|
-
const cacheData = pullFromCache(['user', 'get', invitation.invitedUserPublicId]);
|
|
29418
|
-
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
29419
|
-
return userLinkedObject(cacheData.data);
|
|
29420
|
-
return undefined;
|
|
29421
|
-
},
|
|
29422
|
-
get createdBy() {
|
|
29423
|
-
const cacheData = pullFromCache(['user', 'get', invitation.inviterUserPublicId]);
|
|
29424
|
-
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
29425
|
-
return userLinkedObject(cacheData.data);
|
|
29426
|
-
return undefined;
|
|
29427
|
-
},
|
|
29428
|
-
get target() {
|
|
29429
|
-
if (invitation.targetType === 'community') {
|
|
29430
|
-
const cacheData = pullFromCache([
|
|
29431
|
-
'community',
|
|
29432
|
-
'get',
|
|
29433
|
-
invitation.targetId,
|
|
29434
|
-
]);
|
|
29435
|
-
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
29436
|
-
return cacheData.data;
|
|
29437
|
-
return undefined;
|
|
29438
|
-
}
|
|
29439
|
-
return undefined;
|
|
29440
|
-
}, accept: async () => {
|
|
29441
|
-
await acceptInvitation(invitation._id);
|
|
29442
|
-
}, reject: async () => {
|
|
29443
|
-
await rejectInvitation(invitation._id);
|
|
29444
|
-
} });
|
|
29445
|
-
};
|
|
29446
|
-
|
|
29447
|
-
/* begin_public_function
|
|
29448
|
-
id: invitation.get
|
|
29449
|
-
*/
|
|
29450
|
-
/**
|
|
29451
|
-
* ```js
|
|
29452
|
-
* import { getInvitation } from '@amityco/ts-sdk'
|
|
29453
|
-
* const { invitation } = await getInvitation(targetType, targetId)
|
|
29454
|
-
* ```
|
|
29455
|
-
*
|
|
29456
|
-
* Get a {@link Amity.Invitation} object
|
|
29457
|
-
*
|
|
29458
|
-
* @param targetType The type of the target of the {@link Amity.Invitation}
|
|
29459
|
-
* @param targetId The ID of the target of the {@link Amity.Invitation}
|
|
29460
|
-
* @returns A {@link Amity.Invitation} object
|
|
29461
|
-
*
|
|
29462
|
-
* @category Invitation API
|
|
29463
|
-
* @async
|
|
29464
|
-
*/
|
|
29465
|
-
const getInvitation = async (targetType, targetId) => {
|
|
29466
|
-
const client = getActiveClient();
|
|
29467
|
-
client.log('invitation/getInvitation', targetType, targetId);
|
|
29468
|
-
const { data: payload } = await client.http.get(`/api/v1/invitations/me`, { params: { targetType, targetId } });
|
|
29469
|
-
const data = prepareMyInvitationsPayload(payload);
|
|
29470
|
-
const cachedAt = client.cache && Date.now();
|
|
29471
|
-
if (client.cache)
|
|
29472
|
-
ingestInCache(data, { cachedAt });
|
|
29473
|
-
return {
|
|
29474
|
-
data: data.invitations[0] ? invitationLinkedObject(data.invitations[0]) : undefined,
|
|
29475
|
-
cachedAt,
|
|
29476
|
-
};
|
|
29477
|
-
};
|
|
29478
|
-
/* end_public_function */
|
|
29479
|
-
|
|
29480
29246
|
var InvitationActionsEnum;
|
|
29481
29247
|
(function (InvitationActionsEnum) {
|
|
29482
29248
|
InvitationActionsEnum["OnLocalInvitationCreated"] = "onLocalInvitationCreated";
|
|
29483
29249
|
InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
|
|
29484
|
-
InvitationActionsEnum["
|
|
29250
|
+
InvitationActionsEnum["OnLocalInvitationCanceled"] = "onLocalInvitationCanceled";
|
|
29485
29251
|
})(InvitationActionsEnum || (InvitationActionsEnum = {}));
|
|
29486
29252
|
|
|
29487
29253
|
class InvitationsPaginationController extends PaginationController {
|
|
@@ -29605,8 +29371,8 @@ const onLocalInvitationUpdated = (callback) => {
|
|
|
29605
29371
|
|
|
29606
29372
|
/**
|
|
29607
29373
|
* ```js
|
|
29608
|
-
* import {
|
|
29609
|
-
* const dispose =
|
|
29374
|
+
* import { onLocalInvitationCanceled } from '@amityco/ts-sdk'
|
|
29375
|
+
* const dispose = onLocalInvitationCanceled(data => {
|
|
29610
29376
|
* // ...
|
|
29611
29377
|
* })
|
|
29612
29378
|
* ```
|
|
@@ -29618,10 +29384,10 @@ const onLocalInvitationUpdated = (callback) => {
|
|
|
29618
29384
|
*
|
|
29619
29385
|
* @category Invitation Events
|
|
29620
29386
|
*/
|
|
29621
|
-
const
|
|
29387
|
+
const onLocalInvitationCanceled = (callback) => {
|
|
29622
29388
|
const client = getActiveClient();
|
|
29623
29389
|
const disposers = [
|
|
29624
|
-
createEventSubscriber(client, '
|
|
29390
|
+
createEventSubscriber(client, 'onLocalInvitationCanceled', 'local.invitation.canceled', payload => callback(payload)),
|
|
29625
29391
|
];
|
|
29626
29392
|
return () => {
|
|
29627
29393
|
disposers.forEach(fn => fn());
|
|
@@ -29666,8 +29432,8 @@ class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
|
29666
29432
|
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
29667
29433
|
},
|
|
29668
29434
|
{
|
|
29669
|
-
fn:
|
|
29670
|
-
action: InvitationActionsEnum.
|
|
29435
|
+
fn: onLocalInvitationCanceled,
|
|
29436
|
+
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
29671
29437
|
},
|
|
29672
29438
|
]);
|
|
29673
29439
|
}
|
|
@@ -29729,7 +29495,7 @@ class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
|
29729
29495
|
* @category Invitation Live Collection
|
|
29730
29496
|
*
|
|
29731
29497
|
*/
|
|
29732
|
-
const getInvitations = (params, callback, config) => {
|
|
29498
|
+
const getInvitations$1 = (params, callback, config) => {
|
|
29733
29499
|
const { log, cache } = getActiveClient();
|
|
29734
29500
|
if (!cache) {
|
|
29735
29501
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
@@ -29759,6 +29525,17 @@ const communityLinkedObject = (community) => {
|
|
|
29759
29525
|
return undefined;
|
|
29760
29526
|
})
|
|
29761
29527
|
.filter(category => !!category);
|
|
29528
|
+
},
|
|
29529
|
+
get avatar() {
|
|
29530
|
+
var _a;
|
|
29531
|
+
if (!community.avatarFileId)
|
|
29532
|
+
return undefined;
|
|
29533
|
+
const avatar = (_a = pullFromCache([
|
|
29534
|
+
'file',
|
|
29535
|
+
'get',
|
|
29536
|
+
community.avatarFileId,
|
|
29537
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29538
|
+
return avatar;
|
|
29762
29539
|
}, createInvitations: async (userIds) => {
|
|
29763
29540
|
await createInvitations({
|
|
29764
29541
|
type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */,
|
|
@@ -29767,9 +29544,12 @@ const communityLinkedObject = (community) => {
|
|
|
29767
29544
|
userIds,
|
|
29768
29545
|
});
|
|
29769
29546
|
}, getMemberInvitations: (params, callback) => {
|
|
29770
|
-
return getInvitations(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
|
|
29547
|
+
return getInvitations$1(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
|
|
29771
29548
|
}, getInvitation: async () => {
|
|
29772
|
-
const { data } = await getInvitation(
|
|
29549
|
+
const { data } = await getInvitation({
|
|
29550
|
+
targetType: 'community',
|
|
29551
|
+
targetId: community.communityId,
|
|
29552
|
+
});
|
|
29773
29553
|
return data;
|
|
29774
29554
|
}, join: async () => joinRequest(community.communityId), getJoinRequests: (params, callback) => {
|
|
29775
29555
|
return getJoinRequests(Object.assign(Object.assign({}, params), { communityId: community.communityId }), callback);
|
|
@@ -29779,14 +29559,456 @@ const communityLinkedObject = (community) => {
|
|
|
29779
29559
|
} });
|
|
29780
29560
|
};
|
|
29781
29561
|
|
|
29782
|
-
const
|
|
29783
|
-
return {
|
|
29784
|
-
|
|
29785
|
-
|
|
29786
|
-
|
|
29787
|
-
|
|
29788
|
-
|
|
29562
|
+
const postLinkedObject = (post) => {
|
|
29563
|
+
return shallowClone(post, {
|
|
29564
|
+
childrenPosts: post.children
|
|
29565
|
+
.map(childPost => { var _a; return (_a = pullFromCache(['post', 'get', childPost])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
29566
|
+
.filter(isNonNullable)
|
|
29567
|
+
.map(postLinkedObject),
|
|
29568
|
+
analytics: {
|
|
29569
|
+
markAsViewed: () => {
|
|
29570
|
+
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
29571
|
+
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
29572
|
+
},
|
|
29573
|
+
},
|
|
29574
|
+
get latestComments() {
|
|
29575
|
+
if (!post.comments)
|
|
29576
|
+
return [];
|
|
29577
|
+
return (post.comments
|
|
29578
|
+
.map(commentId => {
|
|
29579
|
+
var _a;
|
|
29580
|
+
const commentCached = (_a = pullFromCache([
|
|
29581
|
+
'comment',
|
|
29582
|
+
'get',
|
|
29583
|
+
commentId,
|
|
29584
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29585
|
+
if (!commentCached)
|
|
29586
|
+
return null;
|
|
29587
|
+
return commentLinkedObject(commentCached);
|
|
29588
|
+
})
|
|
29589
|
+
.filter(Boolean) || []);
|
|
29590
|
+
},
|
|
29591
|
+
get creator() {
|
|
29592
|
+
const cacheData = pullFromCache(['user', 'get', post.postedUserId]);
|
|
29593
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29594
|
+
return;
|
|
29595
|
+
return userLinkedObject(cacheData.data);
|
|
29596
|
+
},
|
|
29597
|
+
get targetCommunity() {
|
|
29598
|
+
var _a;
|
|
29599
|
+
const communityCache = (_a = pullFromCache([
|
|
29600
|
+
'community',
|
|
29601
|
+
'get',
|
|
29602
|
+
post.targetId,
|
|
29603
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29604
|
+
if (!communityCache)
|
|
29605
|
+
return;
|
|
29606
|
+
return communityLinkedObject(communityCache);
|
|
29607
|
+
},
|
|
29608
|
+
getImageInfo() {
|
|
29609
|
+
var _a, _b;
|
|
29610
|
+
return isAmityImagePost(post)
|
|
29611
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
29612
|
+
: undefined;
|
|
29613
|
+
},
|
|
29614
|
+
getVideoInfo() {
|
|
29615
|
+
var _a, _b, _c;
|
|
29616
|
+
return isAmityVideoPost(post)
|
|
29617
|
+
? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
|
|
29618
|
+
: undefined;
|
|
29619
|
+
},
|
|
29620
|
+
getVideoThumbnailInfo() {
|
|
29621
|
+
var _a, _b;
|
|
29622
|
+
return isAmityVideoPost(post)
|
|
29623
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
29624
|
+
: undefined;
|
|
29625
|
+
},
|
|
29626
|
+
getFileInfo() {
|
|
29627
|
+
var _a, _b;
|
|
29628
|
+
return isAmityFilePost(post)
|
|
29629
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
29630
|
+
: undefined;
|
|
29631
|
+
},
|
|
29632
|
+
getLivestreamInfo() {
|
|
29633
|
+
var _a, _b;
|
|
29634
|
+
if (!isAmityLivestreamPost(post))
|
|
29635
|
+
return;
|
|
29636
|
+
const cache = (_b = pullFromCache([
|
|
29637
|
+
'stream',
|
|
29638
|
+
'get',
|
|
29639
|
+
(_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.streamId,
|
|
29640
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
29641
|
+
if (!cache)
|
|
29642
|
+
return;
|
|
29643
|
+
return streamLinkedObject(cache);
|
|
29644
|
+
},
|
|
29645
|
+
getPollInfo() {
|
|
29646
|
+
var _a, _b;
|
|
29647
|
+
if (!isAmityPollPost(post))
|
|
29648
|
+
return;
|
|
29649
|
+
const cache = (_b = pullFromCache(['poll', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.pollId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
29650
|
+
if (!cache)
|
|
29651
|
+
return;
|
|
29652
|
+
return cache;
|
|
29653
|
+
},
|
|
29654
|
+
getClipInfo() {
|
|
29655
|
+
var _a, _b;
|
|
29656
|
+
return isAmityClipPost(post)
|
|
29657
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
29658
|
+
: undefined;
|
|
29659
|
+
},
|
|
29660
|
+
getAudioInfo() {
|
|
29661
|
+
var _a, _b;
|
|
29662
|
+
return isAmityAudioPost(post)
|
|
29663
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
29664
|
+
: undefined;
|
|
29665
|
+
},
|
|
29666
|
+
getRoomInfo() {
|
|
29667
|
+
var _a, _b;
|
|
29668
|
+
if (!isAmityRoomPost(post))
|
|
29669
|
+
return;
|
|
29670
|
+
const room = (_b = pullFromCache(['room', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.roomId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
29671
|
+
return room ? roomLinkedObject(room) : undefined;
|
|
29672
|
+
},
|
|
29673
|
+
});
|
|
29674
|
+
};
|
|
29675
|
+
|
|
29676
|
+
/** @hidden */
|
|
29677
|
+
const dispatchReactable = (referenceType, model) => {
|
|
29678
|
+
if (referenceType === 'message')
|
|
29679
|
+
// @ts-ignore: refactor later
|
|
29680
|
+
fireEvent('local.message.updated', { messages: [model] });
|
|
29681
|
+
else if (referenceType === 'post')
|
|
29682
|
+
// @ts-ignore: refactor later
|
|
29683
|
+
fireEvent('post.updated', { posts: [model] });
|
|
29684
|
+
else if (referenceType === 'comment')
|
|
29685
|
+
// @ts-ignore: refactor later
|
|
29686
|
+
fireEvent('comment.updated', { comments: [model] });
|
|
29687
|
+
else if (referenceType === 'story')
|
|
29688
|
+
// Need to provide all data same StoryPayload from BE
|
|
29689
|
+
fireEvent('story.updated', {
|
|
29690
|
+
categories: [],
|
|
29691
|
+
comments: [],
|
|
29692
|
+
communities: [],
|
|
29693
|
+
communityUsers: [],
|
|
29694
|
+
files: [],
|
|
29695
|
+
users: [],
|
|
29696
|
+
stories: [model],
|
|
29697
|
+
});
|
|
29698
|
+
};
|
|
29699
|
+
|
|
29700
|
+
const addReaction$1 = async (referenceType, referenceId, reactionName, referenceVersion) => {
|
|
29701
|
+
var _a, _b, _c;
|
|
29702
|
+
const client = getActiveClient();
|
|
29703
|
+
client.log('reaction/createReaction', {
|
|
29704
|
+
referenceId,
|
|
29705
|
+
referenceType,
|
|
29706
|
+
reactionName,
|
|
29707
|
+
});
|
|
29708
|
+
if (!['post', 'comment', 'story', 'message'].includes(referenceType))
|
|
29709
|
+
throw new ASCApiError('The reference type is not valid. It should be one of post, comment, story, or message', 400000 /* Amity.ServerError.BAD_REQUEST */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
29710
|
+
const { data } = await client.http.post('/api/v2/reactions', {
|
|
29711
|
+
referenceId,
|
|
29712
|
+
referenceType,
|
|
29713
|
+
reactionName,
|
|
29714
|
+
referenceVersion,
|
|
29715
|
+
});
|
|
29716
|
+
if (client.cache) {
|
|
29717
|
+
const model = pullFromCache([
|
|
29718
|
+
referenceType,
|
|
29719
|
+
'get',
|
|
29720
|
+
referenceId,
|
|
29721
|
+
]);
|
|
29722
|
+
if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
29723
|
+
return true;
|
|
29724
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }), updatedAt: new Date().toISOString() });
|
|
29725
|
+
if (referenceType === 'comment') {
|
|
29726
|
+
fireEvent('local.comment.addReaction', {
|
|
29727
|
+
comment: updatedModel,
|
|
29728
|
+
reactor: {
|
|
29729
|
+
userId: client.userId,
|
|
29730
|
+
reactionName,
|
|
29731
|
+
reactionId: data.addedId,
|
|
29732
|
+
},
|
|
29733
|
+
});
|
|
29734
|
+
return true;
|
|
29735
|
+
}
|
|
29736
|
+
if (referenceType === 'post') {
|
|
29737
|
+
fireEvent('local.post.addReaction', {
|
|
29738
|
+
post: updatedModel,
|
|
29739
|
+
reactor: {
|
|
29740
|
+
userId: client.userId,
|
|
29741
|
+
reactionName,
|
|
29742
|
+
reactionId: data.addedId,
|
|
29743
|
+
},
|
|
29744
|
+
});
|
|
29745
|
+
return true;
|
|
29746
|
+
}
|
|
29747
|
+
if (referenceType === 'story') {
|
|
29748
|
+
fireEvent('local.story.reactionAdded', {
|
|
29749
|
+
story: updatedModel,
|
|
29750
|
+
reactor: {
|
|
29751
|
+
userId: client.userId,
|
|
29752
|
+
reactionName,
|
|
29753
|
+
reactionId: data.addedId,
|
|
29754
|
+
},
|
|
29755
|
+
});
|
|
29756
|
+
return true;
|
|
29757
|
+
}
|
|
29758
|
+
}
|
|
29759
|
+
return true;
|
|
29760
|
+
};
|
|
29761
|
+
addReaction$1.optimistically = (referenceType, referenceId, reactionName) => {
|
|
29762
|
+
var _a, _b, _c, _d, _e;
|
|
29763
|
+
const client = getActiveClient();
|
|
29764
|
+
client.log('reaction/createReaction.optimistically', {
|
|
29765
|
+
referenceId,
|
|
29766
|
+
referenceType,
|
|
29767
|
+
reactionName,
|
|
29768
|
+
});
|
|
29769
|
+
if (!client.cache)
|
|
29770
|
+
return;
|
|
29771
|
+
const model = pullFromCache([
|
|
29772
|
+
referenceType,
|
|
29773
|
+
'get',
|
|
29774
|
+
referenceId,
|
|
29775
|
+
]);
|
|
29776
|
+
if (!(model === null || model === void 0 ? void 0 : model.data) || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
29777
|
+
return;
|
|
29778
|
+
const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
|
|
29779
|
+
upsertInCache([referenceType, 'get', referenceId], reaction, {
|
|
29780
|
+
cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
|
|
29781
|
+
});
|
|
29782
|
+
dispatchReactable(referenceType, reaction);
|
|
29783
|
+
return (_e = (_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName)) !== null && _e !== void 0 ? _e : false;
|
|
29784
|
+
};
|
|
29785
|
+
|
|
29786
|
+
const removeReaction$1 = async (referenceType, referenceId, reactionName, referenceVersion) => {
|
|
29787
|
+
var _a, _b;
|
|
29788
|
+
const client = getActiveClient();
|
|
29789
|
+
client.log('reaction/removeReaction', {
|
|
29790
|
+
referenceId,
|
|
29791
|
+
referenceType,
|
|
29792
|
+
reactionName,
|
|
29793
|
+
});
|
|
29794
|
+
if (!['post', 'comment', 'story', 'message'].includes(referenceType))
|
|
29795
|
+
throw new ASCApiError('The reference type is not valid. It should be one of post, comment, story, or message', 400000 /* Amity.ServerError.BAD_REQUEST */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
29796
|
+
const { data } = await client.http.delete(`/api/v2/reactions`, {
|
|
29797
|
+
data: {
|
|
29798
|
+
referenceId,
|
|
29799
|
+
referenceType,
|
|
29800
|
+
reactionName,
|
|
29801
|
+
referenceVersion,
|
|
29802
|
+
},
|
|
29803
|
+
});
|
|
29804
|
+
if (client.cache) {
|
|
29805
|
+
const model = pullFromCache([
|
|
29806
|
+
referenceType,
|
|
29807
|
+
'get',
|
|
29808
|
+
referenceId,
|
|
29809
|
+
]);
|
|
29810
|
+
if (!model)
|
|
29811
|
+
return true;
|
|
29812
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }), updatedAt: new Date().toISOString() });
|
|
29813
|
+
if (referenceType === 'comment') {
|
|
29814
|
+
fireEvent('local.comment.removeReaction', {
|
|
29815
|
+
comment: updatedModel,
|
|
29816
|
+
reactor: {
|
|
29817
|
+
reactionId: data.removedId,
|
|
29818
|
+
reactionName,
|
|
29819
|
+
userId: client.userId,
|
|
29820
|
+
},
|
|
29821
|
+
});
|
|
29822
|
+
return true;
|
|
29823
|
+
}
|
|
29824
|
+
if (referenceType === 'post') {
|
|
29825
|
+
fireEvent('local.post.removeReaction', {
|
|
29826
|
+
post: updatedModel,
|
|
29827
|
+
reactor: {
|
|
29828
|
+
reactionId: data.removedId,
|
|
29829
|
+
reactionName,
|
|
29830
|
+
userId: client.userId,
|
|
29831
|
+
},
|
|
29832
|
+
});
|
|
29833
|
+
return true;
|
|
29834
|
+
}
|
|
29835
|
+
if (referenceType === 'story') {
|
|
29836
|
+
fireEvent('local.story.reactionAdded', {
|
|
29837
|
+
story: updatedModel,
|
|
29838
|
+
reactor: {
|
|
29839
|
+
userId: client.userId,
|
|
29840
|
+
reactionName,
|
|
29841
|
+
reactionId: data.removedId,
|
|
29842
|
+
},
|
|
29843
|
+
});
|
|
29844
|
+
return true;
|
|
29845
|
+
}
|
|
29846
|
+
}
|
|
29847
|
+
return true;
|
|
29848
|
+
};
|
|
29849
|
+
|
|
29850
|
+
const addReactionToMessage = (reactionName, message) => {
|
|
29851
|
+
const isMessageV3 = message.publicId !== message.messageId;
|
|
29852
|
+
return addReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
|
|
29853
|
+
};
|
|
29854
|
+
|
|
29855
|
+
const getCachedMarker = (message) => {
|
|
29856
|
+
var _a, _b;
|
|
29857
|
+
const key = {
|
|
29858
|
+
creatorId: 'creatorPrivateId' in message ? message.creatorPrivateId : message.creatorId,
|
|
29859
|
+
feedId: (_a = message.messageFeedId) !== null && _a !== void 0 ? _a : message.subChannelId,
|
|
29860
|
+
contentId: message.messageId,
|
|
29789
29861
|
};
|
|
29862
|
+
return (_b = pullFromCache([
|
|
29863
|
+
'messageMarker',
|
|
29864
|
+
'get',
|
|
29865
|
+
getResolver('messageMarker')(key),
|
|
29866
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
29867
|
+
};
|
|
29868
|
+
const getMessageReadCount = (message, marker) => {
|
|
29869
|
+
var _a;
|
|
29870
|
+
// Look in the marker param first
|
|
29871
|
+
return (_a = marker !== null && marker !== void 0 ? marker :
|
|
29872
|
+
// If the marker param is not set, look in the cache
|
|
29873
|
+
getCachedMarker(message)) !== null && _a !== void 0 ? _a : { readCount: 0, deliveredCount: 0 };
|
|
29874
|
+
}; // and if not found in cache use default value `0`
|
|
29875
|
+
|
|
29876
|
+
const removeReactionToMessage = (reactionName, message) => {
|
|
29877
|
+
const isMessageV3 = message.publicId !== message.messageId;
|
|
29878
|
+
return removeReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
|
|
29879
|
+
};
|
|
29880
|
+
|
|
29881
|
+
const messageLinkedObject = (message) => {
|
|
29882
|
+
const rest = __rest(message, ["creatorPrivateId"]);
|
|
29883
|
+
return Object.assign(Object.assign({}, rest), { get readCount() {
|
|
29884
|
+
return getMessageReadCount(message).readCount;
|
|
29885
|
+
},
|
|
29886
|
+
get deliveredCount() {
|
|
29887
|
+
return getMessageReadCount(message).deliveredCount;
|
|
29888
|
+
},
|
|
29889
|
+
get creator() {
|
|
29890
|
+
var _a;
|
|
29891
|
+
return (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29892
|
+
}, markRead: () => markReadMessage(message), addReaction: (reactionName) => addReactionToMessage(reactionName, message), removeReaction: (reactionName) => removeReactionToMessage(reactionName, message) });
|
|
29893
|
+
};
|
|
29894
|
+
|
|
29895
|
+
const reactorLinkedObject = (reactor) => {
|
|
29896
|
+
return Object.assign(Object.assign({}, reactor), { get user() {
|
|
29897
|
+
var _a;
|
|
29898
|
+
const user = (_a = pullFromCache(['user', 'get', reactor.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29899
|
+
if (!user)
|
|
29900
|
+
return undefined;
|
|
29901
|
+
return userLinkedObject(user);
|
|
29902
|
+
} });
|
|
29903
|
+
};
|
|
29904
|
+
|
|
29905
|
+
const adLinkedObject = (ad) => {
|
|
29906
|
+
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
29907
|
+
const { image9_16: image916, image1_1: image11 } = ad, restAds = __rest(ad, ["image9_16", "image1_1"]);
|
|
29908
|
+
return Object.assign(Object.assign({}, restAds), { analytics: {
|
|
29909
|
+
markAsSeen: (placement) => {
|
|
29910
|
+
analyticsEngineInstance.markAdAsViewed(ad, placement);
|
|
29911
|
+
},
|
|
29912
|
+
markLinkAsClicked: (placement) => {
|
|
29913
|
+
analyticsEngineInstance.markAdAsClicked(ad, placement);
|
|
29914
|
+
},
|
|
29915
|
+
}, get advertiser() {
|
|
29916
|
+
var _a, _b;
|
|
29917
|
+
const advertiserData = (_a = pullFromCache([
|
|
29918
|
+
'advertiser',
|
|
29919
|
+
'get',
|
|
29920
|
+
ad.advertiserId,
|
|
29921
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29922
|
+
if (!advertiserData)
|
|
29923
|
+
return;
|
|
29924
|
+
const avatarFile = (_b = pullFromCache([
|
|
29925
|
+
'file',
|
|
29926
|
+
'get',
|
|
29927
|
+
advertiserData.avatarFileId,
|
|
29928
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
29929
|
+
return Object.assign(Object.assign({}, advertiserData), { avatar: avatarFile });
|
|
29930
|
+
},
|
|
29931
|
+
get image1_1() {
|
|
29932
|
+
const cacheData = pullFromCache(['file', 'get', image11]);
|
|
29933
|
+
if (!cacheData)
|
|
29934
|
+
return undefined;
|
|
29935
|
+
return cacheData.data || undefined;
|
|
29936
|
+
},
|
|
29937
|
+
get image9_16() {
|
|
29938
|
+
const cacheData = pullFromCache(['file', 'get', image916]);
|
|
29939
|
+
if (!cacheData)
|
|
29940
|
+
return undefined;
|
|
29941
|
+
return cacheData.data || undefined;
|
|
29942
|
+
} });
|
|
29943
|
+
};
|
|
29944
|
+
|
|
29945
|
+
const pinnedPostLinkedObject = (pinnedPost) => {
|
|
29946
|
+
var _a;
|
|
29947
|
+
const postCached = pullFromCache(['post', 'get', pinnedPost.referenceId]);
|
|
29948
|
+
const pinnedBy = (_a = queryCache(['user', 'get']).find(cache => {
|
|
29949
|
+
var _a;
|
|
29950
|
+
return ((_a = cache.data) === null || _a === void 0 ? void 0 : _a.userInternalId) === pinnedPost.pinnedBy;
|
|
29951
|
+
})) === null || _a === void 0 ? void 0 : _a.data;
|
|
29952
|
+
return Object.assign(Object.assign({}, pinnedPost), { pinnedBy,
|
|
29953
|
+
get post() {
|
|
29954
|
+
if (!(postCached === null || postCached === void 0 ? void 0 : postCached.data))
|
|
29955
|
+
return;
|
|
29956
|
+
return postLinkedObject(postCached.data);
|
|
29957
|
+
},
|
|
29958
|
+
get target() {
|
|
29959
|
+
const pinTarget = pullFromCache([
|
|
29960
|
+
'pinTarget',
|
|
29961
|
+
'get',
|
|
29962
|
+
postCached === null || postCached === void 0 ? void 0 : postCached.data.targetId,
|
|
29963
|
+
]);
|
|
29964
|
+
if (!(pinTarget === null || pinTarget === void 0 ? void 0 : pinTarget.data))
|
|
29965
|
+
return;
|
|
29966
|
+
return pinTarget === null || pinTarget === void 0 ? void 0 : pinTarget.data;
|
|
29967
|
+
} });
|
|
29968
|
+
};
|
|
29969
|
+
|
|
29970
|
+
const notificationTrayLinkedObject = (noti) => {
|
|
29971
|
+
return Object.assign(Object.assign({}, noti), { isSeen: noti.lastSeenAt > noti.lastOccurredAt, isRecent: new Date(noti.lastOccurredAt).getTime() >= Date.now() - WEEK, users: noti.actors
|
|
29972
|
+
.map(({ publicId }) => pullFromCache(['user', 'get', publicId]))
|
|
29973
|
+
.filter(isNonNullable)
|
|
29974
|
+
.map(({ data }) => data)
|
|
29975
|
+
.map(user => userLinkedObject(user)), get event() {
|
|
29976
|
+
const cacheData = pullFromCache(['event', 'get', noti.actionReferenceId]);
|
|
29977
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29978
|
+
return;
|
|
29979
|
+
return cacheData.data;
|
|
29980
|
+
} });
|
|
29981
|
+
};
|
|
29982
|
+
|
|
29983
|
+
const prepareEventResponsePayload = (rawPayload) => {
|
|
29984
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
29985
|
+
};
|
|
29986
|
+
|
|
29987
|
+
const eventResponseLinkedObject = (event) => {
|
|
29988
|
+
return Object.assign(Object.assign({}, event), { get status() {
|
|
29989
|
+
return event.status;
|
|
29990
|
+
},
|
|
29991
|
+
get userId() {
|
|
29992
|
+
return event.userId;
|
|
29993
|
+
},
|
|
29994
|
+
get eventId() {
|
|
29995
|
+
return event.eventId;
|
|
29996
|
+
},
|
|
29997
|
+
get respondedAt() {
|
|
29998
|
+
return event.respondedAt;
|
|
29999
|
+
},
|
|
30000
|
+
get event() {
|
|
30001
|
+
const cacheData = pullFromCache(['event', 'get', event.eventId]);
|
|
30002
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30003
|
+
return;
|
|
30004
|
+
return cacheData.data;
|
|
30005
|
+
},
|
|
30006
|
+
get user() {
|
|
30007
|
+
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
30008
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30009
|
+
return;
|
|
30010
|
+
return userLinkedObject(cacheData.data);
|
|
30011
|
+
} });
|
|
29790
30012
|
};
|
|
29791
30013
|
|
|
29792
30014
|
/* begin_public_function
|
|
@@ -29798,10 +30020,11 @@ const prepareEventResponsePayload = (rawPayload) => {
|
|
|
29798
30020
|
* const response = await event.createRSVP(eventId, status)
|
|
29799
30021
|
* ```
|
|
29800
30022
|
*
|
|
29801
|
-
* Creates an {@link Amity.
|
|
30023
|
+
* Creates an {@link Amity.EventResponse} for the active user for a specific event.
|
|
29802
30024
|
*
|
|
29803
|
-
* @param
|
|
29804
|
-
* @
|
|
30025
|
+
* @param eventId The ID of the {@link Amity.EventResponse} to create an RSVP for
|
|
30026
|
+
* @param status The RSVP status to set for the event
|
|
30027
|
+
* @returns The {@link Amity.EventResponse} with updated RSVP information
|
|
29805
30028
|
*
|
|
29806
30029
|
* @category Event API
|
|
29807
30030
|
* @async
|
|
@@ -29814,9 +30037,9 @@ const createRSVP = async (eventId, status) => {
|
|
|
29814
30037
|
const data = prepareEventResponsePayload(payload);
|
|
29815
30038
|
const cachedAt = client.cache && Date.now();
|
|
29816
30039
|
if (client.cache)
|
|
29817
|
-
ingestInCache(
|
|
30040
|
+
ingestInCache(data, { cachedAt });
|
|
29818
30041
|
return {
|
|
29819
|
-
data,
|
|
30042
|
+
data: eventResponseLinkedObject(data.eventResponses[0]),
|
|
29820
30043
|
cachedAt,
|
|
29821
30044
|
};
|
|
29822
30045
|
};
|
|
@@ -29848,9 +30071,9 @@ const updateRSVP = async (eventId, status) => {
|
|
|
29848
30071
|
const data = prepareEventResponsePayload(payload);
|
|
29849
30072
|
const cachedAt = client.cache && Date.now();
|
|
29850
30073
|
if (client.cache)
|
|
29851
|
-
ingestInCache(
|
|
30074
|
+
ingestInCache(data, { cachedAt });
|
|
29852
30075
|
return {
|
|
29853
|
-
data,
|
|
30076
|
+
data: eventResponseLinkedObject(data.eventResponses[0]),
|
|
29854
30077
|
cachedAt,
|
|
29855
30078
|
};
|
|
29856
30079
|
};
|
|
@@ -29924,9 +30147,9 @@ const getMyRSVP = async (eventId) => {
|
|
|
29924
30147
|
const data = prepareEventResponsePayload(payload);
|
|
29925
30148
|
const cachedAt = client.cache && Date.now();
|
|
29926
30149
|
if (client.cache)
|
|
29927
|
-
ingestInCache(
|
|
30150
|
+
ingestInCache(data, { cachedAt });
|
|
29928
30151
|
return {
|
|
29929
|
-
data,
|
|
30152
|
+
data: eventResponseLinkedObject(data.eventResponses[0]),
|
|
29930
30153
|
cachedAt,
|
|
29931
30154
|
};
|
|
29932
30155
|
};
|
|
@@ -29958,79 +30181,395 @@ getMyRSVP.locally = (eventId) => {
|
|
|
29958
30181
|
};
|
|
29959
30182
|
};
|
|
29960
30183
|
|
|
29961
|
-
|
|
29962
|
-
|
|
29963
|
-
|
|
29964
|
-
|
|
29965
|
-
|
|
29966
|
-
|
|
29967
|
-
|
|
29968
|
-
|
|
29969
|
-
if (!event.discussionCommunityId)
|
|
29970
|
-
return;
|
|
29971
|
-
const cacheData = pullFromCache([
|
|
29972
|
-
'discussionCommunity',
|
|
29973
|
-
'get',
|
|
29974
|
-
event.discussionCommunityId,
|
|
29975
|
-
]);
|
|
29976
|
-
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29977
|
-
return;
|
|
29978
|
-
return communityLinkedObject(cacheData.data);
|
|
29979
|
-
},
|
|
29980
|
-
get targetCommunity() {
|
|
29981
|
-
if (!event.originId)
|
|
29982
|
-
return;
|
|
29983
|
-
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
29984
|
-
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29985
|
-
return;
|
|
29986
|
-
return communityLinkedObject(cacheData.data);
|
|
29987
|
-
},
|
|
29988
|
-
get coverImage() {
|
|
29989
|
-
if (!event.coverImageFileId)
|
|
29990
|
-
return;
|
|
29991
|
-
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
29992
|
-
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29993
|
-
return;
|
|
29994
|
-
return cacheData.data;
|
|
29995
|
-
},
|
|
29996
|
-
get liveStream() {
|
|
29997
|
-
if (!event.livestreamId)
|
|
29998
|
-
return;
|
|
29999
|
-
const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
|
|
30000
|
-
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30001
|
-
return;
|
|
30002
|
-
return cacheData.data;
|
|
30003
|
-
}, createRSVP: async (status) => {
|
|
30004
|
-
const { data } = await createRSVP(event.eventId, status);
|
|
30005
|
-
return data;
|
|
30006
|
-
}, updateRSVP: async (status) => {
|
|
30007
|
-
const { data } = await updateRSVP(event.eventId, status);
|
|
30008
|
-
return data;
|
|
30009
|
-
}, getMyRSVP: async () => {
|
|
30010
|
-
const { data } = await getMyRSVP(event.eventId);
|
|
30011
|
-
return data;
|
|
30012
|
-
} });
|
|
30013
|
-
};
|
|
30184
|
+
var EventActionsEnum;
|
|
30185
|
+
(function (EventActionsEnum) {
|
|
30186
|
+
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
30187
|
+
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
30188
|
+
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
30189
|
+
EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
|
|
30190
|
+
EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
|
|
30191
|
+
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
30014
30192
|
|
|
30015
|
-
|
|
30016
|
-
|
|
30017
|
-
|
|
30018
|
-
|
|
30019
|
-
|
|
30020
|
-
|
|
30021
|
-
|
|
30022
|
-
|
|
30023
|
-
|
|
30024
|
-
|
|
30025
|
-
|
|
30026
|
-
|
|
30193
|
+
class RSVPPaginationController extends PaginationController {
|
|
30194
|
+
async getRequest(queryParams, token) {
|
|
30195
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
|
|
30196
|
+
const options = token ? { token } : { limit };
|
|
30197
|
+
const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvp`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
30198
|
+
return response;
|
|
30199
|
+
}
|
|
30200
|
+
}
|
|
30201
|
+
|
|
30202
|
+
class RSVPQueryStreamController extends QueryStreamController {
|
|
30203
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
30204
|
+
super(query, cacheKey);
|
|
30205
|
+
this.notifyChange = notifyChange;
|
|
30206
|
+
this.preparePayload = preparePayload;
|
|
30207
|
+
}
|
|
30208
|
+
async saveToMainDB(response) {
|
|
30209
|
+
const processedPayload = this.preparePayload(response);
|
|
30210
|
+
const client = getActiveClient();
|
|
30211
|
+
const cachedAt = client.cache && Date.now();
|
|
30212
|
+
if (client.cache)
|
|
30213
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
30214
|
+
}
|
|
30215
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
30216
|
+
var _a, _b;
|
|
30217
|
+
if (refresh) {
|
|
30218
|
+
pushToCache(this.cacheKey, {
|
|
30219
|
+
data: response.eventResponses.map(getResolver('eventResponse')),
|
|
30220
|
+
});
|
|
30221
|
+
}
|
|
30222
|
+
else {
|
|
30223
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30224
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30225
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
30226
|
+
...new Set([...events, ...response.eventResponses.map(getResolver('eventResponse'))]),
|
|
30227
|
+
] }));
|
|
30228
|
+
}
|
|
30229
|
+
}
|
|
30230
|
+
reactor(action) {
|
|
30231
|
+
return (event) => {
|
|
30232
|
+
var _a;
|
|
30233
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30234
|
+
if (!collection)
|
|
30235
|
+
return;
|
|
30236
|
+
if (action === EventActionsEnum.OnRSVPCreated) {
|
|
30237
|
+
collection.data = [...new Set([event.userId, ...collection.data])];
|
|
30238
|
+
}
|
|
30239
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
30240
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
30241
|
+
}
|
|
30242
|
+
pushToCache(this.cacheKey, collection);
|
|
30243
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
30244
|
+
};
|
|
30245
|
+
}
|
|
30246
|
+
subscribeRTE(createSubscriber) {
|
|
30247
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
30248
|
+
}
|
|
30249
|
+
}
|
|
30250
|
+
|
|
30251
|
+
/**
|
|
30252
|
+
* ```js
|
|
30253
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30254
|
+
* const dispose = EventRepository.onEventCreated(event => {
|
|
30255
|
+
* // ...
|
|
30256
|
+
* })
|
|
30257
|
+
* ```
|
|
30258
|
+
*
|
|
30259
|
+
* Fired when an RSVP response for a {@link Amity.Event} has been created
|
|
30260
|
+
*
|
|
30261
|
+
* @param callback The function to call when the event was fired
|
|
30262
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30263
|
+
*
|
|
30264
|
+
* @category Event Events
|
|
30265
|
+
*/
|
|
30266
|
+
const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
|
|
30267
|
+
|
|
30268
|
+
/**
|
|
30269
|
+
* ```js
|
|
30270
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30271
|
+
* const dispose = EventRepository.onEventUpdated(event => {
|
|
30272
|
+
* // ...
|
|
30273
|
+
* })
|
|
30274
|
+
* ```
|
|
30275
|
+
*
|
|
30276
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30277
|
+
*
|
|
30278
|
+
* @param callback The function to call when the event was fired
|
|
30279
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30280
|
+
*
|
|
30281
|
+
* @category Event Events
|
|
30282
|
+
*/
|
|
30283
|
+
const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
|
|
30284
|
+
|
|
30285
|
+
/**
|
|
30286
|
+
* ```js
|
|
30287
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30288
|
+
* const dispose = EventRepository.onEventDeleted(event => {
|
|
30289
|
+
* // ...
|
|
30290
|
+
* })
|
|
30291
|
+
* ```
|
|
30292
|
+
*
|
|
30293
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
30294
|
+
*
|
|
30295
|
+
* @param callback The function to call when the event was fired
|
|
30296
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30297
|
+
*
|
|
30298
|
+
* @category Event Events
|
|
30299
|
+
*/
|
|
30300
|
+
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
30301
|
+
|
|
30302
|
+
/**
|
|
30303
|
+
* ```js
|
|
30304
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30305
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
30306
|
+
* // ...
|
|
30307
|
+
* })
|
|
30308
|
+
* ```
|
|
30309
|
+
*
|
|
30310
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30311
|
+
*
|
|
30312
|
+
* @param callback The function to call when the event was fired
|
|
30313
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30314
|
+
*
|
|
30315
|
+
* @category Event Events
|
|
30316
|
+
*/
|
|
30317
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
30318
|
+
|
|
30319
|
+
/**
|
|
30320
|
+
* ```js
|
|
30321
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30322
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30323
|
+
* // ...
|
|
30324
|
+
* })
|
|
30325
|
+
* ```
|
|
30326
|
+
*
|
|
30327
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30328
|
+
*
|
|
30329
|
+
* @param callback The function to call when the event was fired
|
|
30330
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30331
|
+
*
|
|
30332
|
+
* @category Event Events
|
|
30333
|
+
*/
|
|
30334
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
30335
|
+
|
|
30336
|
+
/**
|
|
30337
|
+
* ```js
|
|
30338
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30339
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
30340
|
+
* // ...
|
|
30341
|
+
* })
|
|
30342
|
+
* ```
|
|
30343
|
+
*
|
|
30344
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
30345
|
+
*
|
|
30346
|
+
* @param callback The function to call when the event was fired
|
|
30347
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30348
|
+
*
|
|
30349
|
+
* @category Event Events
|
|
30350
|
+
*/
|
|
30351
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
30352
|
+
|
|
30353
|
+
/**
|
|
30354
|
+
* ```js
|
|
30355
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30356
|
+
* const dispose = EventRepository.onRSVPCreated(event => {
|
|
30357
|
+
* // ...
|
|
30358
|
+
* })
|
|
30359
|
+
* ```
|
|
30360
|
+
*
|
|
30361
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30362
|
+
*
|
|
30363
|
+
* @param callback The function to call when the event was fired
|
|
30364
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30365
|
+
*
|
|
30366
|
+
* @category Event Events
|
|
30367
|
+
*/
|
|
30368
|
+
const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
|
|
30369
|
+
|
|
30370
|
+
/**
|
|
30371
|
+
* ```js
|
|
30372
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30373
|
+
* const dispose = EventRepository.onRSVPUpdated(event => {
|
|
30374
|
+
* // ...
|
|
30375
|
+
* })
|
|
30376
|
+
* ```
|
|
30377
|
+
*
|
|
30378
|
+
* Fired when a {@link Amity.InternalEventResponse} has been updated
|
|
30379
|
+
*
|
|
30380
|
+
* @param callback The function to call when the event was fired
|
|
30381
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30382
|
+
*
|
|
30383
|
+
* @category Event Events
|
|
30384
|
+
*/
|
|
30385
|
+
const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
|
|
30386
|
+
|
|
30387
|
+
/**
|
|
30388
|
+
* ```js
|
|
30389
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30390
|
+
* const dispose = EventRepository.onLocalRSVPCreated(event => {
|
|
30391
|
+
* // ...
|
|
30392
|
+
* })
|
|
30393
|
+
* ```
|
|
30394
|
+
*
|
|
30395
|
+
* Fired when an RSVP response for a {@link Amity.EventResponse} has been created
|
|
30396
|
+
*
|
|
30397
|
+
* @param callback The function to call when the event was fired
|
|
30398
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30399
|
+
*
|
|
30400
|
+
* @category Event Events
|
|
30401
|
+
*/
|
|
30402
|
+
const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
|
|
30403
|
+
|
|
30404
|
+
/**
|
|
30405
|
+
* ```js
|
|
30406
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30407
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30408
|
+
* // ...
|
|
30409
|
+
* })
|
|
30410
|
+
* ```
|
|
30411
|
+
*
|
|
30412
|
+
* Fired when an RSVP response for a {@link Amity.EventResponse} has been updated
|
|
30413
|
+
*
|
|
30414
|
+
* @param callback The function to call when the event was fired
|
|
30415
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30416
|
+
*
|
|
30417
|
+
* @category Event Events
|
|
30418
|
+
*/
|
|
30419
|
+
const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
|
|
30420
|
+
|
|
30421
|
+
class RSVPLiveCollectionController extends LiveCollectionController {
|
|
30422
|
+
constructor(query, callback) {
|
|
30423
|
+
const queryStreamId = hash(query);
|
|
30424
|
+
const cacheKey = ['eventResponse', 'collection', queryStreamId];
|
|
30425
|
+
const paginationController = new RSVPPaginationController(query);
|
|
30426
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
30427
|
+
this.query = query;
|
|
30428
|
+
this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventResponsePayload);
|
|
30429
|
+
this.callback = callback.bind(this);
|
|
30430
|
+
this.loadPage({ initial: true });
|
|
30431
|
+
}
|
|
30432
|
+
setup() {
|
|
30433
|
+
var _a;
|
|
30434
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30435
|
+
if (!collection)
|
|
30436
|
+
pushToCache(this.cacheKey, { data: [], params: this.query });
|
|
30437
|
+
}
|
|
30438
|
+
async persistModel(queryPayload) {
|
|
30439
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
30440
|
+
}
|
|
30441
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
30442
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
30443
|
+
}
|
|
30444
|
+
startSubscription() {
|
|
30445
|
+
return this.queryStreamController.subscribeRTE([
|
|
30446
|
+
{ fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
30447
|
+
{ fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
30448
|
+
{ fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
30449
|
+
{ fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
30450
|
+
]);
|
|
30451
|
+
}
|
|
30452
|
+
notifyChange({ origin, loading, error }) {
|
|
30453
|
+
var _a;
|
|
30454
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30455
|
+
if (!collection)
|
|
30456
|
+
return;
|
|
30457
|
+
const data = collection.data
|
|
30458
|
+
.map(userId => pullFromCache(['eventResponse', 'get', userId]))
|
|
30459
|
+
.filter(isNonNullable)
|
|
30460
|
+
.map(({ data }) => eventResponseLinkedObject(data));
|
|
30461
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
30462
|
+
return;
|
|
30463
|
+
this.callback({
|
|
30464
|
+
data,
|
|
30465
|
+
error,
|
|
30466
|
+
loading,
|
|
30467
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
30468
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
30469
|
+
});
|
|
30470
|
+
}
|
|
30471
|
+
}
|
|
30472
|
+
|
|
30473
|
+
/**
|
|
30474
|
+
* Get events
|
|
30475
|
+
*
|
|
30476
|
+
* @param params the query parameters
|
|
30477
|
+
* @param callback the callback to be called when the events are updated
|
|
30478
|
+
* @returns events
|
|
30479
|
+
*
|
|
30480
|
+
* @category RSVP Live Collection
|
|
30481
|
+
*
|
|
30482
|
+
*/
|
|
30483
|
+
const getRSVPs = (params, callback, config) => {
|
|
30484
|
+
const { log, cache } = getActiveClient();
|
|
30485
|
+
if (!cache)
|
|
30486
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
30487
|
+
const timestamp = Date.now();
|
|
30488
|
+
log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
|
|
30489
|
+
const rsvpLiveCollection = new RSVPLiveCollectionController(params, callback);
|
|
30490
|
+
const disposers = rsvpLiveCollection.startSubscription();
|
|
30491
|
+
const cacheKey = rsvpLiveCollection.getCacheKey();
|
|
30492
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
30493
|
+
return () => {
|
|
30494
|
+
log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
|
|
30495
|
+
disposers.forEach(fn => fn());
|
|
30496
|
+
};
|
|
30497
|
+
};
|
|
30498
|
+
|
|
30499
|
+
const eventLinkedObject = (event) => {
|
|
30500
|
+
return Object.assign(Object.assign({}, event), { get creator() {
|
|
30501
|
+
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
30502
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30503
|
+
return;
|
|
30504
|
+
return userLinkedObject(cacheData.data);
|
|
30505
|
+
},
|
|
30506
|
+
get targetCommunity() {
|
|
30507
|
+
if (!event.originId)
|
|
30508
|
+
return;
|
|
30509
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
30510
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30511
|
+
return;
|
|
30512
|
+
return communityLinkedObject(cacheData.data);
|
|
30513
|
+
},
|
|
30514
|
+
get coverImage() {
|
|
30515
|
+
if (!event.coverImageFileId)
|
|
30516
|
+
return;
|
|
30517
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
30518
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30519
|
+
return;
|
|
30520
|
+
return cacheData.data;
|
|
30521
|
+
},
|
|
30522
|
+
get post() {
|
|
30523
|
+
if (!event.postId)
|
|
30524
|
+
return;
|
|
30525
|
+
const cacheData = pullFromCache(['post', 'get', event.postId]);
|
|
30526
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30527
|
+
return;
|
|
30528
|
+
return postLinkedObject(cacheData.data);
|
|
30529
|
+
},
|
|
30530
|
+
get room() {
|
|
30531
|
+
var _a;
|
|
30532
|
+
if (!event.postId)
|
|
30533
|
+
return;
|
|
30534
|
+
const cacheData = (_a = queryCache(['room', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(room => room.data.referenceId === event.postId);
|
|
30535
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length) || !cacheData[0].data)
|
|
30536
|
+
return;
|
|
30537
|
+
return roomLinkedObject(cacheData[0].data);
|
|
30538
|
+
}, createRSVP: async (status) => {
|
|
30539
|
+
const { data } = await createRSVP(event.eventId, status);
|
|
30540
|
+
return data;
|
|
30541
|
+
}, updateRSVP: async (status) => {
|
|
30542
|
+
const { data } = await updateRSVP(event.eventId, status);
|
|
30543
|
+
return data;
|
|
30544
|
+
}, getMyRSVP: async () => {
|
|
30545
|
+
const { data } = await getMyRSVP(event.eventId);
|
|
30546
|
+
return data;
|
|
30547
|
+
}, getRSVPs: (params, callback) => {
|
|
30548
|
+
return getRSVPs(Object.assign({ eventId: event.eventId }, params), callback);
|
|
30549
|
+
} });
|
|
30550
|
+
};
|
|
30551
|
+
|
|
30552
|
+
const LinkedObject = {
|
|
30553
|
+
ad: adLinkedObject,
|
|
30554
|
+
comment: commentLinkedObject,
|
|
30555
|
+
post: postLinkedObject,
|
|
30556
|
+
user: userLinkedObject,
|
|
30557
|
+
category: categoryLinkedObject,
|
|
30558
|
+
stream: streamLinkedObject,
|
|
30559
|
+
story: storyLinkedObject,
|
|
30560
|
+
storyTarget: storyTargetLinkedObject,
|
|
30561
|
+
message: messageLinkedObject,
|
|
30562
|
+
reactor: reactorLinkedObject,
|
|
30563
|
+
channel: channelLinkedObject,
|
|
30027
30564
|
pinnedPost: pinnedPostLinkedObject,
|
|
30028
30565
|
notificationTray: notificationTrayLinkedObject,
|
|
30029
30566
|
community: communityLinkedObject,
|
|
30030
30567
|
invitation: invitationLinkedObject,
|
|
30031
30568
|
joinRequest: joinRequestLinkedObject,
|
|
30032
30569
|
channelMember: channelMemberLinkedObject,
|
|
30570
|
+
room: roomLinkedObject,
|
|
30033
30571
|
event: eventLinkedObject,
|
|
30572
|
+
eventResponse: eventResponseLinkedObject,
|
|
30034
30573
|
};
|
|
30035
30574
|
|
|
30036
30575
|
/* begin_public_function
|
|
@@ -31021,9 +31560,9 @@ var AmityUserSearchMatchType;
|
|
|
31021
31560
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
31022
31561
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
31023
31562
|
|
|
31024
|
-
var index$
|
|
31563
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
31025
31564
|
__proto__: null,
|
|
31026
|
-
Relationship: index$
|
|
31565
|
+
Relationship: index$q,
|
|
31027
31566
|
getUserByIds: getUserByIds,
|
|
31028
31567
|
updateUser: updateUser,
|
|
31029
31568
|
flagUser: flagUser,
|
|
@@ -31426,7 +31965,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
31426
31965
|
};
|
|
31427
31966
|
/* end_public_function */
|
|
31428
31967
|
|
|
31429
|
-
var index$
|
|
31968
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
31430
31969
|
__proto__: null,
|
|
31431
31970
|
getFile: getFile,
|
|
31432
31971
|
uploadFile: uploadFile,
|
|
@@ -33238,7 +33777,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
33238
33777
|
};
|
|
33239
33778
|
/* end_public_function */
|
|
33240
33779
|
|
|
33241
|
-
var index$
|
|
33780
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
33242
33781
|
__proto__: null,
|
|
33243
33782
|
addReaction: addReaction,
|
|
33244
33783
|
removeReaction: removeReaction,
|
|
@@ -35010,7 +35549,7 @@ const getMessages = (params, callback, config) => {
|
|
|
35010
35549
|
};
|
|
35011
35550
|
/* end_public_function */
|
|
35012
35551
|
|
|
35013
|
-
var index$
|
|
35552
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
35014
35553
|
__proto__: null,
|
|
35015
35554
|
createMessage: createMessage,
|
|
35016
35555
|
updateMessage: updateMessage,
|
|
@@ -35536,7 +36075,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
35536
36075
|
};
|
|
35537
36076
|
/* end_public_function */
|
|
35538
36077
|
|
|
35539
|
-
var index$
|
|
36078
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
35540
36079
|
__proto__: null,
|
|
35541
36080
|
getSubChannelByIds: getSubChannels$1,
|
|
35542
36081
|
createSubChannel: createSubChannel,
|
|
@@ -36863,7 +37402,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
36863
37402
|
};
|
|
36864
37403
|
/* end_public_function */
|
|
36865
37404
|
|
|
36866
|
-
var index$
|
|
37405
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
36867
37406
|
__proto__: null,
|
|
36868
37407
|
addMembers: addMembers$1,
|
|
36869
37408
|
removeMembers: removeMembers$1,
|
|
@@ -37066,7 +37605,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
37066
37605
|
};
|
|
37067
37606
|
/* end_public_function */
|
|
37068
37607
|
|
|
37069
|
-
var index$
|
|
37608
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
37070
37609
|
__proto__: null,
|
|
37071
37610
|
addRole: addRole,
|
|
37072
37611
|
removeRole: removeRole,
|
|
@@ -37076,10 +37615,10 @@ var index$h = /*#__PURE__*/Object.freeze({
|
|
|
37076
37615
|
unmuteMembers: unmuteMembers
|
|
37077
37616
|
});
|
|
37078
37617
|
|
|
37079
|
-
var index$
|
|
37618
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
37080
37619
|
__proto__: null,
|
|
37081
|
-
Membership: index$
|
|
37082
|
-
Moderation: index$
|
|
37620
|
+
Membership: index$k,
|
|
37621
|
+
Moderation: index$j,
|
|
37083
37622
|
getChannelByIds: getChannelByIds$1,
|
|
37084
37623
|
createChannel: createChannel,
|
|
37085
37624
|
updateChannel: updateChannel,
|
|
@@ -38482,7 +39021,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
38482
39021
|
};
|
|
38483
39022
|
/* end_public_function */
|
|
38484
39023
|
|
|
38485
|
-
var index$
|
|
39024
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
38486
39025
|
__proto__: null,
|
|
38487
39026
|
addMembers: addMembers,
|
|
38488
39027
|
removeMembers: removeMembers,
|
|
@@ -39733,7 +40272,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
39733
40272
|
};
|
|
39734
40273
|
/* end_public_function */
|
|
39735
40274
|
|
|
39736
|
-
var index$
|
|
40275
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
39737
40276
|
__proto__: null,
|
|
39738
40277
|
addRoles: addRoles,
|
|
39739
40278
|
removeRoles: removeRoles,
|
|
@@ -39741,10 +40280,10 @@ var index$e = /*#__PURE__*/Object.freeze({
|
|
|
39741
40280
|
unbanMembers: unbanMembers
|
|
39742
40281
|
});
|
|
39743
40282
|
|
|
39744
|
-
var index$
|
|
40283
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
39745
40284
|
__proto__: null,
|
|
39746
|
-
Moderation: index$
|
|
39747
|
-
Membership: index$
|
|
40285
|
+
Moderation: index$g,
|
|
40286
|
+
Membership: index$h,
|
|
39748
40287
|
getCommunityByIds: getCommunities$1,
|
|
39749
40288
|
createCommunity: createCommunity,
|
|
39750
40289
|
updateCommunity: updateCommunity,
|
|
@@ -39978,7 +40517,7 @@ const getCategories = (params, callback, config) => {
|
|
|
39978
40517
|
};
|
|
39979
40518
|
/* end_public_function */
|
|
39980
40519
|
|
|
39981
|
-
var index$
|
|
40520
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
39982
40521
|
__proto__: null,
|
|
39983
40522
|
getCategory: getCategory,
|
|
39984
40523
|
getCategories: getCategories
|
|
@@ -41037,7 +41576,7 @@ const getComments = (params, callback, config) => {
|
|
|
41037
41576
|
};
|
|
41038
41577
|
/* end_public_function */
|
|
41039
41578
|
|
|
41040
|
-
var index$
|
|
41579
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
41041
41580
|
__proto__: null,
|
|
41042
41581
|
getCommentByIds: getCommentByIds,
|
|
41043
41582
|
createComment: createComment,
|
|
@@ -41708,7 +42247,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
41708
42247
|
};
|
|
41709
42248
|
/* end_public_function */
|
|
41710
42249
|
|
|
41711
|
-
var index$
|
|
42250
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
41712
42251
|
__proto__: null,
|
|
41713
42252
|
queryGlobalFeed: queryGlobalFeed,
|
|
41714
42253
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -42504,6 +43043,15 @@ const getPostSubscription = (cacheKey) => {
|
|
|
42504
43043
|
...generateCommentSubscriptions({ cacheKey }),
|
|
42505
43044
|
];
|
|
42506
43045
|
};
|
|
43046
|
+
const resolvePostIdsFromRooms = (rooms, posts) => {
|
|
43047
|
+
var _a;
|
|
43048
|
+
return ((_a = rooms
|
|
43049
|
+
.map(room => {
|
|
43050
|
+
const post = posts.find(post => post.postId === room.referenceId);
|
|
43051
|
+
return post ? getResolver('post')({ postId: post === null || post === void 0 ? void 0 : post.postId }) : undefined;
|
|
43052
|
+
})
|
|
43053
|
+
.filter(isNonNullable)) !== null && _a !== void 0 ? _a : []);
|
|
43054
|
+
};
|
|
42507
43055
|
|
|
42508
43056
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
42509
43057
|
constructor(query, callback) {
|
|
@@ -43269,45 +43817,1242 @@ class SearchPostLiveCollectionController extends LiveCollectionController {
|
|
|
43269
43817
|
}
|
|
43270
43818
|
startSubscription() {
|
|
43271
43819
|
return this.queryStreamController.subscribeRTE([
|
|
43272
|
-
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
43273
|
-
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
43274
|
-
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
43275
|
-
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
43276
|
-
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
43277
|
-
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
43278
|
-
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
43279
|
-
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
43280
|
-
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
43281
|
-
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
43282
|
-
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
43283
|
-
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
43284
|
-
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
43285
|
-
{
|
|
43286
|
-
fn: convertEventPayload((callback) => {
|
|
43287
|
-
return onCommentCreated(async (comment) => {
|
|
43288
|
-
var _a;
|
|
43289
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43290
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
43291
|
-
return;
|
|
43292
|
-
await getPost$1(comment.referenceId);
|
|
43293
|
-
callback(comment);
|
|
43294
|
-
});
|
|
43295
|
-
}, 'referenceId', 'post'),
|
|
43296
|
-
action: EnumPostActions.OnPostUpdated,
|
|
43297
|
-
},
|
|
43298
|
-
{
|
|
43299
|
-
fn: convertEventPayload((callback) => {
|
|
43300
|
-
return onCommentDeleted(async (comment) => {
|
|
43301
|
-
var _a;
|
|
43302
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43303
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
43304
|
-
return;
|
|
43305
|
-
await getPost$1(comment.referenceId);
|
|
43306
|
-
callback(comment);
|
|
43307
|
-
});
|
|
43308
|
-
}, 'referenceId', 'post'),
|
|
43309
|
-
action: EnumPostActions.OnPostUpdated,
|
|
43310
|
-
},
|
|
43820
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
43821
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
43822
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
43823
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
43824
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
43825
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
43826
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
43827
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
43828
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
43829
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
43830
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
43831
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
43832
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
43833
|
+
{
|
|
43834
|
+
fn: convertEventPayload((callback) => {
|
|
43835
|
+
return onCommentCreated(async (comment) => {
|
|
43836
|
+
var _a;
|
|
43837
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43838
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
43839
|
+
return;
|
|
43840
|
+
await getPost$1(comment.referenceId);
|
|
43841
|
+
callback(comment);
|
|
43842
|
+
});
|
|
43843
|
+
}, 'referenceId', 'post'),
|
|
43844
|
+
action: EnumPostActions.OnPostUpdated,
|
|
43845
|
+
},
|
|
43846
|
+
{
|
|
43847
|
+
fn: convertEventPayload((callback) => {
|
|
43848
|
+
return onCommentDeleted(async (comment) => {
|
|
43849
|
+
var _a;
|
|
43850
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43851
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
43852
|
+
return;
|
|
43853
|
+
await getPost$1(comment.referenceId);
|
|
43854
|
+
callback(comment);
|
|
43855
|
+
});
|
|
43856
|
+
}, 'referenceId', 'post'),
|
|
43857
|
+
action: EnumPostActions.OnPostUpdated,
|
|
43858
|
+
},
|
|
43859
|
+
]);
|
|
43860
|
+
}
|
|
43861
|
+
notifyChange({ origin, loading, error }) {
|
|
43862
|
+
var _a, _b;
|
|
43863
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43864
|
+
if (!collection)
|
|
43865
|
+
return;
|
|
43866
|
+
const data = this.applyFilter((_b = collection.data
|
|
43867
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
43868
|
+
.filter(isNonNullable)
|
|
43869
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
43870
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
43871
|
+
return;
|
|
43872
|
+
this.callback({
|
|
43873
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
43874
|
+
data,
|
|
43875
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
43876
|
+
loading,
|
|
43877
|
+
error,
|
|
43878
|
+
});
|
|
43879
|
+
}
|
|
43880
|
+
applyFilter(data) {
|
|
43881
|
+
var _a;
|
|
43882
|
+
let posts = data;
|
|
43883
|
+
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
43884
|
+
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
43885
|
+
}
|
|
43886
|
+
switch (this.query.sortBy) {
|
|
43887
|
+
case 'firstCreated':
|
|
43888
|
+
posts = posts.sort(sortByFirstCreated);
|
|
43889
|
+
break;
|
|
43890
|
+
case 'lastCreated':
|
|
43891
|
+
default:
|
|
43892
|
+
posts = posts.sort(sortByLastCreated);
|
|
43893
|
+
break;
|
|
43894
|
+
}
|
|
43895
|
+
return posts;
|
|
43896
|
+
}
|
|
43897
|
+
}
|
|
43898
|
+
|
|
43899
|
+
/* begin_public_function
|
|
43900
|
+
id: post.query
|
|
43901
|
+
*/
|
|
43902
|
+
/**
|
|
43903
|
+
* ```js
|
|
43904
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
43905
|
+
*
|
|
43906
|
+
* let posts = []
|
|
43907
|
+
* const unsub = PostRepository.searchPostsByHashtag({
|
|
43908
|
+
* hashtags: ['amity'],
|
|
43909
|
+
* limit: 10,
|
|
43910
|
+
* }, response => merge(posts, response.data))
|
|
43911
|
+
* ```
|
|
43912
|
+
*
|
|
43913
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
43914
|
+
*
|
|
43915
|
+
* @param params.hashtags the hashtags to search for
|
|
43916
|
+
* @param callback the function to call when new data are available
|
|
43917
|
+
* @param config
|
|
43918
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
43919
|
+
*
|
|
43920
|
+
* @category Posts Live Collection
|
|
43921
|
+
*/
|
|
43922
|
+
const searchPostsByHashtag = (params, callback, config) => {
|
|
43923
|
+
const { log, cache } = getActiveClient();
|
|
43924
|
+
if (!cache) {
|
|
43925
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
43926
|
+
}
|
|
43927
|
+
const timestamp = Date.now();
|
|
43928
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > listen`);
|
|
43929
|
+
const postsLiveCollection = new SearchPostLiveCollectionController(params, callback);
|
|
43930
|
+
const disposers = postsLiveCollection.startSubscription();
|
|
43931
|
+
const cacheKey = postsLiveCollection.getCacheKey();
|
|
43932
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
43933
|
+
return () => {
|
|
43934
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > dispose`);
|
|
43935
|
+
disposers.forEach(fn => fn());
|
|
43936
|
+
};
|
|
43937
|
+
};
|
|
43938
|
+
/* end_public_function */
|
|
43939
|
+
|
|
43940
|
+
class LiveRoomPostPaginationController extends PaginationNoPageController {
|
|
43941
|
+
async getRequest(queryParams) {
|
|
43942
|
+
const { limit = 100 } = queryParams;
|
|
43943
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/rooms/lives`, {
|
|
43944
|
+
params: {
|
|
43945
|
+
targetTypes: ['all'],
|
|
43946
|
+
options: {
|
|
43947
|
+
limit,
|
|
43948
|
+
sortBy: 'lastCreated',
|
|
43949
|
+
},
|
|
43950
|
+
},
|
|
43951
|
+
});
|
|
43952
|
+
return queryResponse;
|
|
43953
|
+
}
|
|
43954
|
+
}
|
|
43955
|
+
|
|
43956
|
+
class LiveRoomPostQueryStreamController extends QueryStreamController {
|
|
43957
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
43958
|
+
super(query, cacheKey);
|
|
43959
|
+
this.notifyChange = notifyChange;
|
|
43960
|
+
this.preparePayload = preparePayload;
|
|
43961
|
+
}
|
|
43962
|
+
async saveToMainDB(response) {
|
|
43963
|
+
const processedPayload = await this.preparePayload(response);
|
|
43964
|
+
const client = getActiveClient();
|
|
43965
|
+
const cachedAt = client.cache && Date.now();
|
|
43966
|
+
if (client.cache) {
|
|
43967
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
43968
|
+
}
|
|
43969
|
+
}
|
|
43970
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
43971
|
+
var _a, _b;
|
|
43972
|
+
if (refresh) {
|
|
43973
|
+
pushToCache(this.cacheKey, {
|
|
43974
|
+
data: resolvePostIdsFromRooms(response.rooms, response.posts),
|
|
43975
|
+
});
|
|
43976
|
+
}
|
|
43977
|
+
else {
|
|
43978
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43979
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
43980
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...resolvePostIdsFromRooms(response.rooms, response.posts)])] }));
|
|
43981
|
+
}
|
|
43982
|
+
}
|
|
43983
|
+
reactor(action) {
|
|
43984
|
+
return (room) => {
|
|
43985
|
+
var _a;
|
|
43986
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43987
|
+
if (!collection)
|
|
43988
|
+
return;
|
|
43989
|
+
if (room.status === 'ended') {
|
|
43990
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: collection.data.filter(postId => room.referenceId !== postId) }));
|
|
43991
|
+
}
|
|
43992
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
43993
|
+
};
|
|
43994
|
+
}
|
|
43995
|
+
subscribeRTE(createSubscriber) {
|
|
43996
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
43997
|
+
}
|
|
43998
|
+
}
|
|
43999
|
+
|
|
44000
|
+
/* begin_public_function
|
|
44001
|
+
id: room.create
|
|
44002
|
+
*/
|
|
44003
|
+
/**
|
|
44004
|
+
* ```js
|
|
44005
|
+
* import { createRoom } from '@amityco/ts-sdk'
|
|
44006
|
+
* const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
|
|
44007
|
+
* ```
|
|
44008
|
+
*
|
|
44009
|
+
* Creates an {@link Amity.Room}
|
|
44010
|
+
*
|
|
44011
|
+
* @param bundle The data necessary to create a new {@link Amity.Room}
|
|
44012
|
+
* @returns The newly created {@link Amity.Room}
|
|
44013
|
+
*
|
|
44014
|
+
* @category Room API
|
|
44015
|
+
* @async
|
|
44016
|
+
*/
|
|
44017
|
+
const createRoom = async (bundle) => {
|
|
44018
|
+
const client = getActiveClient();
|
|
44019
|
+
client.log('room/createRoom', bundle);
|
|
44020
|
+
const { data } = await client.http.post('/api/v1/rooms', bundle);
|
|
44021
|
+
fireEvent('local.room.created', data);
|
|
44022
|
+
const cachedAt = client.cache && Date.now();
|
|
44023
|
+
// TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
|
|
44024
|
+
if (client.cache)
|
|
44025
|
+
ingestInCache(data, { cachedAt });
|
|
44026
|
+
const { rooms } = data;
|
|
44027
|
+
return {
|
|
44028
|
+
data: roomLinkedObject(rooms[0]),
|
|
44029
|
+
cachedAt,
|
|
44030
|
+
};
|
|
44031
|
+
};
|
|
44032
|
+
/* end_public_function */
|
|
44033
|
+
|
|
44034
|
+
/* begin_public_function
|
|
44035
|
+
id: room.update
|
|
44036
|
+
*/
|
|
44037
|
+
/**
|
|
44038
|
+
* ```js
|
|
44039
|
+
* import { updateRoom } from '@amityco/ts-sdk'
|
|
44040
|
+
* const updated = await updateRoom('roomId', { title: 'updated title' })
|
|
44041
|
+
* ```
|
|
44042
|
+
*
|
|
44043
|
+
* Updates an {@link Amity.InternalRoom}
|
|
44044
|
+
*
|
|
44045
|
+
* @param roomId The ID of the room to update
|
|
44046
|
+
* @param bundle The data to update the room with
|
|
44047
|
+
* @returns The updated {@link Amity.InternalRoom}
|
|
44048
|
+
*
|
|
44049
|
+
* @category Room API
|
|
44050
|
+
* @async
|
|
44051
|
+
*/
|
|
44052
|
+
const updateRoom = async (roomId, bundle) => {
|
|
44053
|
+
const client = getActiveClient();
|
|
44054
|
+
client.log('room/updateRoom', { roomId, bundle });
|
|
44055
|
+
const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
|
|
44056
|
+
fireEvent('local.room.updated', data);
|
|
44057
|
+
const cachedAt = client.cache && Date.now();
|
|
44058
|
+
if (client.cache)
|
|
44059
|
+
ingestInCache(data, { cachedAt });
|
|
44060
|
+
const { rooms } = data;
|
|
44061
|
+
return {
|
|
44062
|
+
data: roomLinkedObject(rooms[0]),
|
|
44063
|
+
cachedAt,
|
|
44064
|
+
};
|
|
44065
|
+
};
|
|
44066
|
+
/* end_public_function */
|
|
44067
|
+
|
|
44068
|
+
/* begin_public_function
|
|
44069
|
+
id: room.delete
|
|
44070
|
+
*/
|
|
44071
|
+
/**
|
|
44072
|
+
* ```js
|
|
44073
|
+
* import { deleteRoom } from '@amityco/ts-sdk'
|
|
44074
|
+
* const result = await deleteRoom('roomId')
|
|
44075
|
+
* ```
|
|
44076
|
+
*
|
|
44077
|
+
* Deletes an {@link Amity.Room}
|
|
44078
|
+
*
|
|
44079
|
+
* @param roomId The ID of the room to delete
|
|
44080
|
+
* @returns Promise that resolves when the room is deleted
|
|
44081
|
+
*
|
|
44082
|
+
* @category Room API
|
|
44083
|
+
* @async
|
|
44084
|
+
*/
|
|
44085
|
+
const deleteRoom = async (roomId) => {
|
|
44086
|
+
const client = getActiveClient();
|
|
44087
|
+
client.log('room/deleteRoom', { roomId });
|
|
44088
|
+
await client.http.delete(`/api/v1/rooms/${roomId}`);
|
|
44089
|
+
fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
|
|
44090
|
+
};
|
|
44091
|
+
/* end_public_function */
|
|
44092
|
+
|
|
44093
|
+
/* begin_public_function
|
|
44094
|
+
id: room.stop
|
|
44095
|
+
*/
|
|
44096
|
+
/**
|
|
44097
|
+
* ```js
|
|
44098
|
+
* import { stopRoom } from '@amityco/ts-sdk'
|
|
44099
|
+
* const result = await stopRoom('roomId')
|
|
44100
|
+
* ```
|
|
44101
|
+
*
|
|
44102
|
+
* Stops a room's broadcasting
|
|
44103
|
+
*
|
|
44104
|
+
* @param roomId The ID of the room to stop
|
|
44105
|
+
* @returns The updated room data
|
|
44106
|
+
*
|
|
44107
|
+
* @category Room API
|
|
44108
|
+
* @async
|
|
44109
|
+
*/
|
|
44110
|
+
const stopRoom = async (roomId) => {
|
|
44111
|
+
const client = getActiveClient();
|
|
44112
|
+
client.log('room/stopRoom', { roomId });
|
|
44113
|
+
const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
|
|
44114
|
+
fireEvent('local.room.stopped', data);
|
|
44115
|
+
const cachedAt = client.cache && Date.now();
|
|
44116
|
+
if (client.cache)
|
|
44117
|
+
ingestInCache(data, { cachedAt });
|
|
44118
|
+
const { rooms } = data;
|
|
44119
|
+
return {
|
|
44120
|
+
data: rooms[0],
|
|
44121
|
+
cachedAt,
|
|
44122
|
+
};
|
|
44123
|
+
};
|
|
44124
|
+
/* end_public_function */
|
|
44125
|
+
|
|
44126
|
+
/* begin_public_function
|
|
44127
|
+
id: room.getBroadcasterData
|
|
44128
|
+
*/
|
|
44129
|
+
/**
|
|
44130
|
+
* ```js
|
|
44131
|
+
* import { getBroadcasterData } from '@amityco/ts-sdk'
|
|
44132
|
+
* const token = await getBroadcasterData('roomId')
|
|
44133
|
+
* ```
|
|
44134
|
+
*
|
|
44135
|
+
* Gets broadcaster data for a room
|
|
44136
|
+
*
|
|
44137
|
+
* @param roomId The ID of the room to get token for
|
|
44138
|
+
* @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
|
|
44139
|
+
*
|
|
44140
|
+
* @category Room API
|
|
44141
|
+
* @async
|
|
44142
|
+
*/
|
|
44143
|
+
const getBroadcasterData = async (roomId) => {
|
|
44144
|
+
const client = getActiveClient();
|
|
44145
|
+
client.log('room/getBroadcasterData', { roomId });
|
|
44146
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
|
|
44147
|
+
return data;
|
|
44148
|
+
};
|
|
44149
|
+
/* end_public_function */
|
|
44150
|
+
|
|
44151
|
+
/* begin_public_function
|
|
44152
|
+
id: room.getRecordedUrl
|
|
44153
|
+
*/
|
|
44154
|
+
/**
|
|
44155
|
+
* ```js
|
|
44156
|
+
* import { getRecordedUrl } from '@amityco/ts-sdk'
|
|
44157
|
+
* const recordedUrl = await getRecordedUrl('roomId')
|
|
44158
|
+
* ```
|
|
44159
|
+
*
|
|
44160
|
+
* Gets the recorded URL for a room
|
|
44161
|
+
*
|
|
44162
|
+
* @param roomId The ID of the room to get recorded URL for
|
|
44163
|
+
* @returns The recorded URL information
|
|
44164
|
+
*
|
|
44165
|
+
* @category Room API
|
|
44166
|
+
* @async
|
|
44167
|
+
*/
|
|
44168
|
+
const getRecordedUrl = async (roomId) => {
|
|
44169
|
+
const client = getActiveClient();
|
|
44170
|
+
client.log('room/getRecordedUrl', { roomId });
|
|
44171
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
|
|
44172
|
+
return data;
|
|
44173
|
+
};
|
|
44174
|
+
/* end_public_function */
|
|
44175
|
+
|
|
44176
|
+
/* begin_public_function
|
|
44177
|
+
id: room.removeParticipant
|
|
44178
|
+
*/
|
|
44179
|
+
/**
|
|
44180
|
+
* ```js
|
|
44181
|
+
* import { removeParticipant } from '@amityco/ts-sdk'
|
|
44182
|
+
* const result = await removeParticipant('roomId', 'participantUserId')
|
|
44183
|
+
* ```
|
|
44184
|
+
*
|
|
44185
|
+
* Removes a participant from an {@link Amity.Room}
|
|
44186
|
+
*
|
|
44187
|
+
* @param roomId The ID of the room to remove participant from
|
|
44188
|
+
* @param participantUserId The ID of the user to remove as participant
|
|
44189
|
+
* @returns Promise that resolves when the participant is removed
|
|
44190
|
+
*
|
|
44191
|
+
* @category Room API
|
|
44192
|
+
* @async
|
|
44193
|
+
*/
|
|
44194
|
+
const removeParticipant = async (roomId, participantUserId) => {
|
|
44195
|
+
const client = getActiveClient();
|
|
44196
|
+
client.log('room/removeParticipant', { roomId, participantUserId });
|
|
44197
|
+
await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
|
|
44198
|
+
fireEvent('local.room.participantRemoved', {
|
|
44199
|
+
rooms: [{ _id: roomId }],
|
|
44200
|
+
users: [{ _id: participantUserId }],
|
|
44201
|
+
});
|
|
44202
|
+
};
|
|
44203
|
+
/* end_public_function */
|
|
44204
|
+
|
|
44205
|
+
/* begin_public_function
|
|
44206
|
+
id: room.leave
|
|
44207
|
+
*/
|
|
44208
|
+
/**
|
|
44209
|
+
* ```js
|
|
44210
|
+
* import { leaveRoom } from '@amityco/ts-sdk'
|
|
44211
|
+
* const result = await leaveRoom('roomId')
|
|
44212
|
+
* ```
|
|
44213
|
+
*
|
|
44214
|
+
* Leaves an {@link Amity.Room}
|
|
44215
|
+
*
|
|
44216
|
+
* @param roomId The ID of the room to leave
|
|
44217
|
+
* @returns Promise that resolves when the user has left the room
|
|
44218
|
+
*
|
|
44219
|
+
* @category Room API
|
|
44220
|
+
* @async
|
|
44221
|
+
*/
|
|
44222
|
+
const leaveRoom = async (roomId) => {
|
|
44223
|
+
const client = getActiveClient();
|
|
44224
|
+
client.log('room/leaveRoom', { roomId });
|
|
44225
|
+
await client.http.post(`/api/v1/rooms/${roomId}/leave`);
|
|
44226
|
+
fireEvent('local.room.left', {
|
|
44227
|
+
rooms: [{ _id: roomId }],
|
|
44228
|
+
});
|
|
44229
|
+
};
|
|
44230
|
+
/* end_public_function */
|
|
44231
|
+
|
|
44232
|
+
/**
|
|
44233
|
+
* ```js
|
|
44234
|
+
* import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
|
|
44235
|
+
* const dispose = onRoomStartBroadcasting(room => {
|
|
44236
|
+
* // ...
|
|
44237
|
+
* })
|
|
44238
|
+
* ```
|
|
44239
|
+
*
|
|
44240
|
+
* Fired when a {@link Amity.Room} has started broadcasting
|
|
44241
|
+
*
|
|
44242
|
+
* @param callback The function to call when the event was fired
|
|
44243
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44244
|
+
*
|
|
44245
|
+
* @category Room Events
|
|
44246
|
+
*/
|
|
44247
|
+
const onRoomStartBroadcasting = (callback) => {
|
|
44248
|
+
const client = getActiveClient();
|
|
44249
|
+
const filter = (payload) => {
|
|
44250
|
+
ingestInCache(payload);
|
|
44251
|
+
callback(payload.rooms[0]);
|
|
44252
|
+
};
|
|
44253
|
+
return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
|
|
44254
|
+
};
|
|
44255
|
+
|
|
44256
|
+
/**
|
|
44257
|
+
* ```js
|
|
44258
|
+
* import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
|
|
44259
|
+
* const dispose = onRoomWaitingReconnect(room => {
|
|
44260
|
+
* // ...
|
|
44261
|
+
* })
|
|
44262
|
+
* ```
|
|
44263
|
+
*
|
|
44264
|
+
* Fired when a {@link Amity.Room} is waiting for reconnection
|
|
44265
|
+
*
|
|
44266
|
+
* @param callback The function to call when the event was fired
|
|
44267
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44268
|
+
*
|
|
44269
|
+
* @category Room Events
|
|
44270
|
+
*/
|
|
44271
|
+
const onRoomWaitingReconnect = (callback) => {
|
|
44272
|
+
const client = getActiveClient();
|
|
44273
|
+
const filter = (payload) => {
|
|
44274
|
+
ingestInCache(payload);
|
|
44275
|
+
callback(payload.rooms[0]);
|
|
44276
|
+
};
|
|
44277
|
+
return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
|
|
44278
|
+
};
|
|
44279
|
+
|
|
44280
|
+
/**
|
|
44281
|
+
* ```js
|
|
44282
|
+
* import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
|
|
44283
|
+
* const dispose = onRoomEndBroadcasting(room => {
|
|
44284
|
+
* // ...
|
|
44285
|
+
* })
|
|
44286
|
+
* ```
|
|
44287
|
+
*
|
|
44288
|
+
* Fired when a {@link Amity.Room} has ended broadcasting
|
|
44289
|
+
*
|
|
44290
|
+
* @param callback The function to call when the event was fired
|
|
44291
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44292
|
+
*
|
|
44293
|
+
* @category Room Events
|
|
44294
|
+
*/
|
|
44295
|
+
const onRoomEndBroadcasting = (callback) => {
|
|
44296
|
+
const client = getActiveClient();
|
|
44297
|
+
const filter = (payload) => {
|
|
44298
|
+
ingestInCache(payload);
|
|
44299
|
+
callback(payload.rooms[0]);
|
|
44300
|
+
};
|
|
44301
|
+
return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
|
|
44302
|
+
};
|
|
44303
|
+
|
|
44304
|
+
/**
|
|
44305
|
+
* ```js
|
|
44306
|
+
* import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
|
|
44307
|
+
* const dispose = onRoomRecordedAvailable(room => {
|
|
44308
|
+
* // ...
|
|
44309
|
+
* })
|
|
44310
|
+
* ```
|
|
44311
|
+
*
|
|
44312
|
+
* Fired when a {@link Amity.Room} recorded content becomes available
|
|
44313
|
+
*
|
|
44314
|
+
* @param callback The function to call when the event was fired
|
|
44315
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44316
|
+
*
|
|
44317
|
+
* @category Room Events
|
|
44318
|
+
*/
|
|
44319
|
+
const onRoomRecordedAvailable = (callback) => {
|
|
44320
|
+
const client = getActiveClient();
|
|
44321
|
+
const filter = (payload) => {
|
|
44322
|
+
ingestInCache(payload);
|
|
44323
|
+
callback(payload.rooms[0]);
|
|
44324
|
+
};
|
|
44325
|
+
return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
|
|
44326
|
+
};
|
|
44327
|
+
|
|
44328
|
+
/**
|
|
44329
|
+
* ```js
|
|
44330
|
+
* import { onRoomParticipantInviting } from '@amityco/ts-sdk'
|
|
44331
|
+
* const dispose = onRoomParticipantInviting(room => {
|
|
44332
|
+
* // ...
|
|
44333
|
+
* })
|
|
44334
|
+
* ```
|
|
44335
|
+
*
|
|
44336
|
+
* Fired when a participant is being invited to a {@link Amity.Room}
|
|
44337
|
+
*
|
|
44338
|
+
* @param callback The function to call when the event was fired
|
|
44339
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44340
|
+
*
|
|
44341
|
+
* @category Room Events
|
|
44342
|
+
*/
|
|
44343
|
+
const onRoomCoHostInvited = (callback) => {
|
|
44344
|
+
const client = getActiveClient();
|
|
44345
|
+
const filter = (payload) => {
|
|
44346
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44347
|
+
ingestInCache(data);
|
|
44348
|
+
callback(data.invitations);
|
|
44349
|
+
};
|
|
44350
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
|
|
44351
|
+
};
|
|
44352
|
+
|
|
44353
|
+
const getRoomById = async (roomId) => {
|
|
44354
|
+
const client = getActiveClient();
|
|
44355
|
+
client.log('room/getRoomById', roomId);
|
|
44356
|
+
// Check if room is in tombstone
|
|
44357
|
+
isInTombstone('room', roomId);
|
|
44358
|
+
let data;
|
|
44359
|
+
try {
|
|
44360
|
+
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
44361
|
+
data = response.data;
|
|
44362
|
+
}
|
|
44363
|
+
catch (error) {
|
|
44364
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
44365
|
+
pushToTombstone('room', roomId);
|
|
44366
|
+
}
|
|
44367
|
+
throw error;
|
|
44368
|
+
}
|
|
44369
|
+
const cachedAt = client.cache && Date.now();
|
|
44370
|
+
if (client.cache) {
|
|
44371
|
+
ingestInCache(data, { cachedAt });
|
|
44372
|
+
}
|
|
44373
|
+
return {
|
|
44374
|
+
data: data.rooms[0],
|
|
44375
|
+
cachedAt,
|
|
44376
|
+
};
|
|
44377
|
+
};
|
|
44378
|
+
getRoomById.locally = (roomId) => {
|
|
44379
|
+
const client = getActiveClient();
|
|
44380
|
+
client.log('room/getRoomById.locally', roomId);
|
|
44381
|
+
// Check if room is in tombstone
|
|
44382
|
+
isInTombstone('room', roomId);
|
|
44383
|
+
const cachedAt = client.cache && Date.now();
|
|
44384
|
+
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
44385
|
+
if (!roomCache)
|
|
44386
|
+
return;
|
|
44387
|
+
return {
|
|
44388
|
+
data: roomCache.data,
|
|
44389
|
+
cachedAt,
|
|
44390
|
+
};
|
|
44391
|
+
};
|
|
44392
|
+
|
|
44393
|
+
/**
|
|
44394
|
+
* ```js
|
|
44395
|
+
* import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
|
|
44396
|
+
* const dispose = onRoomCoHostInviteAccepted(room => {
|
|
44397
|
+
* // ...
|
|
44398
|
+
* })
|
|
44399
|
+
* ```
|
|
44400
|
+
*
|
|
44401
|
+
* Fired when a co-host invitation is accepted for a {@link Amity.Room}
|
|
44402
|
+
*
|
|
44403
|
+
* @param callback The function to call when the event was fired
|
|
44404
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44405
|
+
*
|
|
44406
|
+
* @category Room Events
|
|
44407
|
+
*/
|
|
44408
|
+
const onRoomCoHostInviteAccepted = (callback) => {
|
|
44409
|
+
const client = getActiveClient();
|
|
44410
|
+
const filter = async (payload) => {
|
|
44411
|
+
var _a;
|
|
44412
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44413
|
+
await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
|
|
44414
|
+
ingestInCache(data);
|
|
44415
|
+
callback(data.invitations[0]);
|
|
44416
|
+
};
|
|
44417
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
|
|
44418
|
+
};
|
|
44419
|
+
|
|
44420
|
+
/**
|
|
44421
|
+
* ```js
|
|
44422
|
+
* import { onRoomCoHostInviteRejected } from '@amityco/ts-sdk'
|
|
44423
|
+
* const dispose = onRoomCoHostInviteRejected(room => {
|
|
44424
|
+
* // ...
|
|
44425
|
+
* })
|
|
44426
|
+
* ```
|
|
44427
|
+
*
|
|
44428
|
+
* Fired when a co-host invitation is rejected for a {@link Amity.Room}
|
|
44429
|
+
*
|
|
44430
|
+
* @param callback The function to call when the event was fired
|
|
44431
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44432
|
+
*
|
|
44433
|
+
* @category Room Events
|
|
44434
|
+
*/
|
|
44435
|
+
const onRoomCoHostInviteRejected = (callback) => {
|
|
44436
|
+
const client = getActiveClient();
|
|
44437
|
+
const filter = (payload) => {
|
|
44438
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44439
|
+
ingestInCache(data);
|
|
44440
|
+
callback(data.invitations);
|
|
44441
|
+
};
|
|
44442
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
|
|
44443
|
+
};
|
|
44444
|
+
|
|
44445
|
+
/**
|
|
44446
|
+
* ```js
|
|
44447
|
+
* import { onRoomCoHostInviteCanceled } from '@amityco/ts-sdk'
|
|
44448
|
+
* const dispose = onRoomCoHostInviteCanceled(room => {
|
|
44449
|
+
* // ...
|
|
44450
|
+
* })
|
|
44451
|
+
* ```
|
|
44452
|
+
*
|
|
44453
|
+
* Fired when a co-host invitation is canceled for a {@link Amity.Room}
|
|
44454
|
+
*
|
|
44455
|
+
* @param callback The function to call when the event was fired
|
|
44456
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44457
|
+
*
|
|
44458
|
+
* @category Room Events
|
|
44459
|
+
*/
|
|
44460
|
+
const onRoomCoHostInviteCanceled = (callback) => {
|
|
44461
|
+
const client = getActiveClient();
|
|
44462
|
+
const filter = (payload) => {
|
|
44463
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44464
|
+
ingestInCache(data);
|
|
44465
|
+
callback(data.invitations);
|
|
44466
|
+
};
|
|
44467
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
|
|
44468
|
+
};
|
|
44469
|
+
|
|
44470
|
+
/**
|
|
44471
|
+
* ```js
|
|
44472
|
+
* import { onRoomParticipantJoined } from '@amityco/ts-sdk'
|
|
44473
|
+
* const dispose = onRoomParticipantJoined(room => {
|
|
44474
|
+
* // ...
|
|
44475
|
+
* })
|
|
44476
|
+
* ```
|
|
44477
|
+
*
|
|
44478
|
+
* Fired when a participant has joined a {@link Amity.Room}
|
|
44479
|
+
*
|
|
44480
|
+
* @param callback The function to call when the event was fired
|
|
44481
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44482
|
+
*
|
|
44483
|
+
* @category Room Events
|
|
44484
|
+
*/
|
|
44485
|
+
const onRoomParticipantJoined = (callback) => {
|
|
44486
|
+
const client = getActiveClient();
|
|
44487
|
+
const filter = (payload) => {
|
|
44488
|
+
ingestInCache(payload);
|
|
44489
|
+
callback(payload.rooms[0]);
|
|
44490
|
+
};
|
|
44491
|
+
return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
|
|
44492
|
+
};
|
|
44493
|
+
|
|
44494
|
+
/**
|
|
44495
|
+
* ```js
|
|
44496
|
+
* import { onRoomParticipantLeft } from '@amityco/ts-sdk'
|
|
44497
|
+
* const dispose = onRoomParticipantLeft(room => {
|
|
44498
|
+
* // ...
|
|
44499
|
+
* })
|
|
44500
|
+
* ```
|
|
44501
|
+
*
|
|
44502
|
+
* Fired when a participant has left a {@link Amity.Room}
|
|
44503
|
+
*
|
|
44504
|
+
* @param callback The function to call when the event was fired
|
|
44505
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44506
|
+
*
|
|
44507
|
+
* @category Room Events
|
|
44508
|
+
*/
|
|
44509
|
+
const onRoomParticipantLeft = (callback) => {
|
|
44510
|
+
const client = getActiveClient();
|
|
44511
|
+
const filter = (payload) => {
|
|
44512
|
+
ingestInCache(payload);
|
|
44513
|
+
callback(payload.rooms[0]);
|
|
44514
|
+
};
|
|
44515
|
+
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
44516
|
+
};
|
|
44517
|
+
|
|
44518
|
+
/**
|
|
44519
|
+
* ```js
|
|
44520
|
+
* import { onRoomParticipantStageLeft } from '@amityco/ts-sdk'
|
|
44521
|
+
* const dispose = onRoomParticipantStageLeft(room => {
|
|
44522
|
+
* // ...
|
|
44523
|
+
* })
|
|
44524
|
+
* ```
|
|
44525
|
+
*
|
|
44526
|
+
* Fired when a participant has left the stage of a {@link Amity.Room}
|
|
44527
|
+
*
|
|
44528
|
+
* @param callback The function to call when the event was fired
|
|
44529
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44530
|
+
*
|
|
44531
|
+
* @category Room Events
|
|
44532
|
+
*/
|
|
44533
|
+
const onRoomParticipantStageLeft = (callback) => {
|
|
44534
|
+
const client = getActiveClient();
|
|
44535
|
+
const filter = (payload) => {
|
|
44536
|
+
ingestInCache(payload);
|
|
44537
|
+
callback(payload.rooms[0]);
|
|
44538
|
+
};
|
|
44539
|
+
return createEventSubscriber(client, 'room/onRoomParticipantStageLeft', 'room.participantStageLeft', filter);
|
|
44540
|
+
};
|
|
44541
|
+
|
|
44542
|
+
/**
|
|
44543
|
+
* ```js
|
|
44544
|
+
* import { onRoomParticipantStageJoined } from '@amityco/ts-sdk'
|
|
44545
|
+
* const dispose = onRoomParticipantStageJoined(room => {
|
|
44546
|
+
* // ...
|
|
44547
|
+
* })
|
|
44548
|
+
* ```
|
|
44549
|
+
*
|
|
44550
|
+
* Fired when a participant has joined the stage of a {@link Amity.Room}
|
|
44551
|
+
*
|
|
44552
|
+
* @param callback The function to call when the event was fired
|
|
44553
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44554
|
+
*
|
|
44555
|
+
* @category Room Events
|
|
44556
|
+
*/
|
|
44557
|
+
const onRoomParticipantStageJoined = (callback) => {
|
|
44558
|
+
const client = getActiveClient();
|
|
44559
|
+
const filter = (payload) => {
|
|
44560
|
+
ingestInCache(payload);
|
|
44561
|
+
callback(payload.rooms[0]);
|
|
44562
|
+
};
|
|
44563
|
+
return createEventSubscriber(client, 'room/onRoomParticipantStageJoined', 'room.participantStageJoined', filter);
|
|
44564
|
+
};
|
|
44565
|
+
|
|
44566
|
+
/**
|
|
44567
|
+
* ```js
|
|
44568
|
+
* import { onRoomTerminated } from '@amityco/ts-sdk'
|
|
44569
|
+
* const dispose = onRoomTerminated(room => {
|
|
44570
|
+
* // ...
|
|
44571
|
+
* })
|
|
44572
|
+
* ```
|
|
44573
|
+
*
|
|
44574
|
+
* Fired when a {@link Amity.Room} has started broadcasting
|
|
44575
|
+
*
|
|
44576
|
+
* @param callback The function to call when the event was fired
|
|
44577
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44578
|
+
*
|
|
44579
|
+
* @category Room Events
|
|
44580
|
+
*/
|
|
44581
|
+
const onRoomTerminated = (callback) => {
|
|
44582
|
+
const client = getActiveClient();
|
|
44583
|
+
const filter = (payload) => {
|
|
44584
|
+
ingestInCache(payload);
|
|
44585
|
+
callback(payload.rooms[0]);
|
|
44586
|
+
};
|
|
44587
|
+
return createEventSubscriber(client, 'room/onRoomTerminated', 'room.terminated', filter);
|
|
44588
|
+
};
|
|
44589
|
+
|
|
44590
|
+
/**
|
|
44591
|
+
* ```js
|
|
44592
|
+
* import { onRoomCreated } from '@amityco/ts-sdk'
|
|
44593
|
+
* const dispose = onRoomCreated(room => {
|
|
44594
|
+
* // ...
|
|
44595
|
+
* })
|
|
44596
|
+
* ```
|
|
44597
|
+
*
|
|
44598
|
+
* Fired when a {@link Amity.Room} has been created locally
|
|
44599
|
+
*
|
|
44600
|
+
* @param callback The function to call when the event was fired
|
|
44601
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44602
|
+
*
|
|
44603
|
+
* @category Room Events
|
|
44604
|
+
*/
|
|
44605
|
+
const onRoomCreated = (callback) => {
|
|
44606
|
+
const client = getActiveClient();
|
|
44607
|
+
const filter = (payload) => {
|
|
44608
|
+
ingestInCache(payload);
|
|
44609
|
+
callback(payload.rooms[0]);
|
|
44610
|
+
};
|
|
44611
|
+
return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
|
|
44612
|
+
};
|
|
44613
|
+
|
|
44614
|
+
/**
|
|
44615
|
+
* ```js
|
|
44616
|
+
* import { onRoomUpdated } from '@amityco/ts-sdk'
|
|
44617
|
+
* const dispose = onRoomUpdated(room => {
|
|
44618
|
+
* // ...
|
|
44619
|
+
* })
|
|
44620
|
+
* ```
|
|
44621
|
+
*
|
|
44622
|
+
* Fired when a {@link Amity.Room} has been updated locally
|
|
44623
|
+
*
|
|
44624
|
+
* @param callback The function to call when the event was fired
|
|
44625
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44626
|
+
*
|
|
44627
|
+
* @category Room Events
|
|
44628
|
+
*/
|
|
44629
|
+
const onRoomUpdated = (callback) => {
|
|
44630
|
+
const client = getActiveClient();
|
|
44631
|
+
const filter = (payload) => {
|
|
44632
|
+
ingestInCache(payload);
|
|
44633
|
+
callback(payload.rooms[0]);
|
|
44634
|
+
};
|
|
44635
|
+
return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
|
|
44636
|
+
};
|
|
44637
|
+
|
|
44638
|
+
/**
|
|
44639
|
+
* ```js
|
|
44640
|
+
* import { onRoomDeleted } from '@amityco/ts-sdk'
|
|
44641
|
+
* const dispose = onRoomDeleted(room => {
|
|
44642
|
+
* // ...
|
|
44643
|
+
* })
|
|
44644
|
+
* ```
|
|
44645
|
+
*
|
|
44646
|
+
* Fired when a {@link Amity.Room} has been deleted locally
|
|
44647
|
+
*
|
|
44648
|
+
* @param callback The function to call when the event was fired
|
|
44649
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44650
|
+
*
|
|
44651
|
+
* @category Room Events
|
|
44652
|
+
*/
|
|
44653
|
+
const onRoomDeleted = (callback) => {
|
|
44654
|
+
const client = getActiveClient();
|
|
44655
|
+
const filter = (payload) => {
|
|
44656
|
+
ingestInCache(payload);
|
|
44657
|
+
callback(payload.rooms[0]);
|
|
44658
|
+
};
|
|
44659
|
+
return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
|
|
44660
|
+
};
|
|
44661
|
+
|
|
44662
|
+
/**
|
|
44663
|
+
* ```js
|
|
44664
|
+
* import { onRoomStopped } from '@amityco/ts-sdk'
|
|
44665
|
+
* const dispose = onRoomStopped(room => {
|
|
44666
|
+
* // ...
|
|
44667
|
+
* })
|
|
44668
|
+
* ```
|
|
44669
|
+
*
|
|
44670
|
+
* Fired when a {@link Amity.Room} has been stopped locally
|
|
44671
|
+
*
|
|
44672
|
+
* @param callback The function to call when the event was fired
|
|
44673
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44674
|
+
*
|
|
44675
|
+
* @category Room Events
|
|
44676
|
+
*/
|
|
44677
|
+
const onRoomStopped = (callback) => {
|
|
44678
|
+
const client = getActiveClient();
|
|
44679
|
+
const filter = (payload) => {
|
|
44680
|
+
ingestInCache(payload);
|
|
44681
|
+
callback(payload.rooms[0]);
|
|
44682
|
+
};
|
|
44683
|
+
return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
|
|
44684
|
+
};
|
|
44685
|
+
|
|
44686
|
+
/**
|
|
44687
|
+
* ```js
|
|
44688
|
+
* import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
|
|
44689
|
+
* const dispose = onRoomParticipantRemoved(room => {
|
|
44690
|
+
* // ...
|
|
44691
|
+
* })
|
|
44692
|
+
* ```
|
|
44693
|
+
*
|
|
44694
|
+
* Fired when a participant has been removed from a {@link Amity.Room} locally
|
|
44695
|
+
*
|
|
44696
|
+
* @param callback The function to call when the event was fired
|
|
44697
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44698
|
+
*
|
|
44699
|
+
* @category Room Events
|
|
44700
|
+
*/
|
|
44701
|
+
const onRoomParticipantRemoved = (callback) => {
|
|
44702
|
+
const client = getActiveClient();
|
|
44703
|
+
const filter = (payload) => {
|
|
44704
|
+
ingestInCache(payload);
|
|
44705
|
+
callback(payload.rooms[0]);
|
|
44706
|
+
};
|
|
44707
|
+
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
|
|
44708
|
+
};
|
|
44709
|
+
|
|
44710
|
+
/**
|
|
44711
|
+
* ```js
|
|
44712
|
+
* import { onRoomLeft } from '@amityco/ts-sdk'
|
|
44713
|
+
* const dispose = onRoomLeft(room => {
|
|
44714
|
+
* // ...
|
|
44715
|
+
* })
|
|
44716
|
+
* ```
|
|
44717
|
+
*
|
|
44718
|
+
* Fired when a user has left a {@link Amity.Room} locally
|
|
44719
|
+
*
|
|
44720
|
+
* @param callback The function to call when the event was fired
|
|
44721
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44722
|
+
*
|
|
44723
|
+
* @category Room Events
|
|
44724
|
+
*/
|
|
44725
|
+
const onRoomLeft = (callback) => {
|
|
44726
|
+
const client = getActiveClient();
|
|
44727
|
+
const filter = (payload) => {
|
|
44728
|
+
ingestInCache(payload);
|
|
44729
|
+
callback(payload.rooms[0]);
|
|
44730
|
+
};
|
|
44731
|
+
return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
|
|
44732
|
+
};
|
|
44733
|
+
|
|
44734
|
+
/**
|
|
44735
|
+
* ```js
|
|
44736
|
+
* import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
|
|
44737
|
+
* const dispose = onRoomParticipantRemoved(room => {
|
|
44738
|
+
* // ...
|
|
44739
|
+
* })
|
|
44740
|
+
* ```
|
|
44741
|
+
*
|
|
44742
|
+
* Fired when a participant has been removed from a {@link Amity.Room} locally
|
|
44743
|
+
*
|
|
44744
|
+
* @param callback The function to call when the event was fired
|
|
44745
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44746
|
+
*
|
|
44747
|
+
* @category Room Events
|
|
44748
|
+
*/
|
|
44749
|
+
const onRoomParticipantRemovedLocal = (callback) => {
|
|
44750
|
+
const client = getActiveClient();
|
|
44751
|
+
const filter = (payload) => {
|
|
44752
|
+
ingestInCache(payload);
|
|
44753
|
+
callback(payload.rooms[0]);
|
|
44754
|
+
};
|
|
44755
|
+
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
|
|
44756
|
+
};
|
|
44757
|
+
|
|
44758
|
+
const getRoom = (roomId, callback) => {
|
|
44759
|
+
// TODO: add callbackDataSelector if there are linked object fields
|
|
44760
|
+
return liveObject(roomId, callback, '_id', getRoomById, [
|
|
44761
|
+
onRoomEndBroadcasting,
|
|
44762
|
+
onRoomStartBroadcasting,
|
|
44763
|
+
onRoomWaitingReconnect,
|
|
44764
|
+
onRoomTerminated,
|
|
44765
|
+
onRoomRecordedAvailable,
|
|
44766
|
+
onRoomParticipantJoined,
|
|
44767
|
+
onRoomParticipantLeft,
|
|
44768
|
+
onRoomParticipantRemoved,
|
|
44769
|
+
onRoomParticipantRemovedLocal,
|
|
44770
|
+
onRoomParticipantStageJoined,
|
|
44771
|
+
onRoomParticipantLeft,
|
|
44772
|
+
convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
|
|
44773
|
+
], {
|
|
44774
|
+
callbackDataSelector: (data) => {
|
|
44775
|
+
if (!data)
|
|
44776
|
+
return data;
|
|
44777
|
+
return LinkedObject.room(data);
|
|
44778
|
+
},
|
|
44779
|
+
});
|
|
44780
|
+
};
|
|
44781
|
+
|
|
44782
|
+
class RoomPaginationController extends PaginationController {
|
|
44783
|
+
async getRequest(queryParams, token) {
|
|
44784
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
44785
|
+
const baseOptions = {
|
|
44786
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
44787
|
+
};
|
|
44788
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
44789
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
|
|
44790
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
44791
|
+
});
|
|
44792
|
+
return queryResponse;
|
|
44793
|
+
}
|
|
44794
|
+
}
|
|
44795
|
+
|
|
44796
|
+
var EnumRoomActions;
|
|
44797
|
+
(function (EnumRoomActions) {
|
|
44798
|
+
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
44799
|
+
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
44800
|
+
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
44801
|
+
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
44802
|
+
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
44803
|
+
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
44804
|
+
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
44805
|
+
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
44806
|
+
|
|
44807
|
+
class RoomQueryStreamController extends QueryStreamController {
|
|
44808
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
44809
|
+
super(query, cacheKey);
|
|
44810
|
+
this.notifyChange = notifyChange;
|
|
44811
|
+
this.preparePayload = preparePayload;
|
|
44812
|
+
}
|
|
44813
|
+
async saveToMainDB(response) {
|
|
44814
|
+
const processedPayload = await this.preparePayload(response);
|
|
44815
|
+
const client = getActiveClient();
|
|
44816
|
+
const cachedAt = client.cache && Date.now();
|
|
44817
|
+
if (client.cache) {
|
|
44818
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
44819
|
+
}
|
|
44820
|
+
}
|
|
44821
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
44822
|
+
var _a, _b;
|
|
44823
|
+
if (refresh) {
|
|
44824
|
+
pushToCache(this.cacheKey, {
|
|
44825
|
+
data: response.rooms.map(getResolver('room')),
|
|
44826
|
+
});
|
|
44827
|
+
}
|
|
44828
|
+
else {
|
|
44829
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44830
|
+
const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
44831
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
|
|
44832
|
+
}
|
|
44833
|
+
}
|
|
44834
|
+
reactor(action) {
|
|
44835
|
+
return (room) => {
|
|
44836
|
+
var _a;
|
|
44837
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44838
|
+
if (!collection)
|
|
44839
|
+
return;
|
|
44840
|
+
if (action === EnumRoomActions.OnRoomDeleted) {
|
|
44841
|
+
collection.data = collection.data.filter(roomId => roomId !== room._id);
|
|
44842
|
+
}
|
|
44843
|
+
if (action === EnumRoomActions.OnRoomCreated) {
|
|
44844
|
+
collection.data = [...new Set([room._id, ...collection.data])];
|
|
44845
|
+
}
|
|
44846
|
+
pushToCache(this.cacheKey, collection);
|
|
44847
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
44848
|
+
};
|
|
44849
|
+
}
|
|
44850
|
+
subscribeRTE(createSubscriber) {
|
|
44851
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
44852
|
+
}
|
|
44853
|
+
}
|
|
44854
|
+
|
|
44855
|
+
// TODO: confirm related events
|
|
44856
|
+
const getRoomSubscription = () => [
|
|
44857
|
+
{
|
|
44858
|
+
fn: onRoomStartBroadcasting,
|
|
44859
|
+
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
44860
|
+
},
|
|
44861
|
+
{
|
|
44862
|
+
fn: onRoomEndBroadcasting,
|
|
44863
|
+
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
44864
|
+
},
|
|
44865
|
+
{
|
|
44866
|
+
fn: onRoomRecordedAvailable,
|
|
44867
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44868
|
+
},
|
|
44869
|
+
];
|
|
44870
|
+
|
|
44871
|
+
class RoomLiveCollectionController extends LiveCollectionController {
|
|
44872
|
+
constructor(query, callback) {
|
|
44873
|
+
const queryStreamId = hash(query);
|
|
44874
|
+
const cacheKey = ['rooms', 'collection', queryStreamId];
|
|
44875
|
+
const paginationController = new RoomPaginationController(query);
|
|
44876
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
44877
|
+
this.query = query;
|
|
44878
|
+
this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
|
|
44879
|
+
this.callback = callback.bind(this);
|
|
44880
|
+
this.loadPage({ initial: true });
|
|
44881
|
+
}
|
|
44882
|
+
setup() {
|
|
44883
|
+
var _a;
|
|
44884
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44885
|
+
if (!collection) {
|
|
44886
|
+
pushToCache(this.cacheKey, {
|
|
44887
|
+
data: [],
|
|
44888
|
+
params: {},
|
|
44889
|
+
});
|
|
44890
|
+
}
|
|
44891
|
+
}
|
|
44892
|
+
async persistModel(queryPayload) {
|
|
44893
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
44894
|
+
}
|
|
44895
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
44896
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
44897
|
+
}
|
|
44898
|
+
startSubscription() {
|
|
44899
|
+
return this.queryStreamController.subscribeRTE(getRoomSubscription());
|
|
44900
|
+
}
|
|
44901
|
+
notifyChange({ origin, loading, error }) {
|
|
44902
|
+
var _a, _b;
|
|
44903
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44904
|
+
if (!collection)
|
|
44905
|
+
return;
|
|
44906
|
+
const data = this.applyFilter((_b = collection.data
|
|
44907
|
+
.map(id => pullFromCache(['room', 'get', id]))
|
|
44908
|
+
.filter(isNonNullable)
|
|
44909
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
|
|
44910
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
44911
|
+
return;
|
|
44912
|
+
this.callback({
|
|
44913
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
44914
|
+
data,
|
|
44915
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
44916
|
+
loading,
|
|
44917
|
+
error,
|
|
44918
|
+
});
|
|
44919
|
+
}
|
|
44920
|
+
applyFilter(data) {
|
|
44921
|
+
let rooms = data;
|
|
44922
|
+
if (!this.query.includeDeleted) {
|
|
44923
|
+
rooms = filterByPropEquality(rooms, 'isDeleted', false);
|
|
44924
|
+
}
|
|
44925
|
+
if (this.query.statuses && this.query.statuses.length > 0) {
|
|
44926
|
+
rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
|
|
44927
|
+
}
|
|
44928
|
+
if (this.query.type) {
|
|
44929
|
+
rooms = filterByPropEquality(rooms, 'type', this.query.type);
|
|
44930
|
+
}
|
|
44931
|
+
switch (this.query.sortBy) {
|
|
44932
|
+
case 'firstCreated':
|
|
44933
|
+
rooms = rooms.sort(sortByFirstCreated);
|
|
44934
|
+
break;
|
|
44935
|
+
case 'lastCreated':
|
|
44936
|
+
default:
|
|
44937
|
+
rooms = rooms.sort(sortByLastCreated);
|
|
44938
|
+
break;
|
|
44939
|
+
}
|
|
44940
|
+
return rooms;
|
|
44941
|
+
}
|
|
44942
|
+
}
|
|
44943
|
+
|
|
44944
|
+
/* begin_public_function
|
|
44945
|
+
id: room.get_rooms
|
|
44946
|
+
*/
|
|
44947
|
+
/**
|
|
44948
|
+
* ```js
|
|
44949
|
+
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
44950
|
+
*
|
|
44951
|
+
* let rooms = []
|
|
44952
|
+
* const unsub = RoomRepository.getRooms({
|
|
44953
|
+
* type: 'direct_streaming',
|
|
44954
|
+
* statuses: ['live', 'idle'],
|
|
44955
|
+
* sortBy: 'lastCreated',
|
|
44956
|
+
* limit: 20,
|
|
44957
|
+
* includeDeleted: false
|
|
44958
|
+
* }, response => merge(rooms, response.data))
|
|
44959
|
+
* ```
|
|
44960
|
+
*
|
|
44961
|
+
* Observe all mutations on a list of {@link Amity.Room} for a given query
|
|
44962
|
+
*
|
|
44963
|
+
* @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
|
|
44964
|
+
* @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
|
|
44965
|
+
* @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
|
|
44966
|
+
* @param params.limit maximum number of rooms to retrieve per page
|
|
44967
|
+
* @param params.includeDeleted whether to include deleted rooms in the results
|
|
44968
|
+
* @param callback the function to call when new data are available
|
|
44969
|
+
* @param config optional configuration for the live collection
|
|
44970
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
|
|
44971
|
+
*
|
|
44972
|
+
* @category Rooms Live Collection
|
|
44973
|
+
*/
|
|
44974
|
+
const getRooms = (params, callback, config) => {
|
|
44975
|
+
const { log, cache } = getActiveClient();
|
|
44976
|
+
if (!cache) {
|
|
44977
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
44978
|
+
}
|
|
44979
|
+
const timestamp = Date.now();
|
|
44980
|
+
log(`getRooms(tmpid: ${timestamp}) > listen`);
|
|
44981
|
+
const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
|
|
44982
|
+
const disposers = roomsLiveCollection.startSubscription();
|
|
44983
|
+
const cacheKey = roomsLiveCollection.getCacheKey();
|
|
44984
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
44985
|
+
return () => {
|
|
44986
|
+
log(`getRooms(tmpid: ${timestamp}) > dispose`);
|
|
44987
|
+
disposers.forEach(fn => fn());
|
|
44988
|
+
};
|
|
44989
|
+
};
|
|
44990
|
+
/* end_public_function */
|
|
44991
|
+
|
|
44992
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
44993
|
+
__proto__: null,
|
|
44994
|
+
createRoom: createRoom,
|
|
44995
|
+
updateRoom: updateRoom,
|
|
44996
|
+
deleteRoom: deleteRoom,
|
|
44997
|
+
stopRoom: stopRoom,
|
|
44998
|
+
getBroadcasterData: getBroadcasterData,
|
|
44999
|
+
getRecordedUrl: getRecordedUrl,
|
|
45000
|
+
removeParticipant: removeParticipant,
|
|
45001
|
+
leaveRoom: leaveRoom,
|
|
45002
|
+
onRoomStartBroadcasting: onRoomStartBroadcasting,
|
|
45003
|
+
onRoomWaitingReconnect: onRoomWaitingReconnect,
|
|
45004
|
+
onRoomEndBroadcasting: onRoomEndBroadcasting,
|
|
45005
|
+
onRoomRecordedAvailable: onRoomRecordedAvailable,
|
|
45006
|
+
onRoomCoHostInvited: onRoomCoHostInvited,
|
|
45007
|
+
onRoomCoHostInviteAccepted: onRoomCoHostInviteAccepted,
|
|
45008
|
+
onRoomCoHostInviteRejected: onRoomCoHostInviteRejected,
|
|
45009
|
+
onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
|
|
45010
|
+
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
45011
|
+
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
45012
|
+
onRoomParticipantStageLeft: onRoomParticipantStageLeft,
|
|
45013
|
+
onRoomParticipantStageJoined: onRoomParticipantStageJoined,
|
|
45014
|
+
onRoomTerminated: onRoomTerminated,
|
|
45015
|
+
onRoomCreated: onRoomCreated,
|
|
45016
|
+
onRoomUpdated: onRoomUpdated,
|
|
45017
|
+
onRoomDeleted: onRoomDeleted,
|
|
45018
|
+
onRoomStopped: onRoomStopped,
|
|
45019
|
+
onRoomParticipantRemoved: onRoomParticipantRemoved,
|
|
45020
|
+
onRoomLeft: onRoomLeft,
|
|
45021
|
+
getRoom: getRoom,
|
|
45022
|
+
getRooms: getRooms
|
|
45023
|
+
});
|
|
45024
|
+
|
|
45025
|
+
class LiveRoomPostLiveCollectionController extends LiveCollectionController {
|
|
45026
|
+
constructor(callback) {
|
|
45027
|
+
const query = { limit: 100 };
|
|
45028
|
+
const queryStreamId = hash(query);
|
|
45029
|
+
const cacheKey = ['liveRoomPosts', 'collection', queryStreamId];
|
|
45030
|
+
const paginationController = new LiveRoomPostPaginationController(query);
|
|
45031
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
45032
|
+
this.query = query;
|
|
45033
|
+
this.queryStreamController = new LiveRoomPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
45034
|
+
this.callback = callback.bind(this);
|
|
45035
|
+
this.loadPage({ initial: true });
|
|
45036
|
+
}
|
|
45037
|
+
setup() {
|
|
45038
|
+
var _a;
|
|
45039
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45040
|
+
if (!collection) {
|
|
45041
|
+
pushToCache(this.cacheKey, {
|
|
45042
|
+
data: [],
|
|
45043
|
+
params: {},
|
|
45044
|
+
});
|
|
45045
|
+
}
|
|
45046
|
+
}
|
|
45047
|
+
async persistModel(queryPayload) {
|
|
45048
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
45049
|
+
}
|
|
45050
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
45051
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
45052
|
+
}
|
|
45053
|
+
startSubscription() {
|
|
45054
|
+
return this.queryStreamController.subscribeRTE([
|
|
45055
|
+
{ fn: onRoomEndBroadcasting, action: EnumPostActions.OnPostUpdated },
|
|
43311
45056
|
]);
|
|
43312
45057
|
}
|
|
43313
45058
|
notifyChange({ origin, loading, error }) {
|
|
@@ -43322,74 +45067,221 @@ class SearchPostLiveCollectionController extends LiveCollectionController {
|
|
|
43322
45067
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
43323
45068
|
return;
|
|
43324
45069
|
this.callback({
|
|
43325
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
43326
45070
|
data,
|
|
43327
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
43328
45071
|
loading,
|
|
43329
45072
|
error,
|
|
43330
45073
|
});
|
|
43331
45074
|
}
|
|
45075
|
+
// eslint-disable-next-line class-methods-use-this
|
|
43332
45076
|
applyFilter(data) {
|
|
43333
|
-
|
|
43334
|
-
|
|
43335
|
-
|
|
43336
|
-
|
|
45077
|
+
// No additional filtering needed for live room posts
|
|
45078
|
+
// API handles all filtering based on targetId and targetType
|
|
45079
|
+
return data;
|
|
45080
|
+
}
|
|
45081
|
+
}
|
|
45082
|
+
|
|
45083
|
+
/* begin_public_function
|
|
45084
|
+
id: post.liveRoom.query
|
|
45085
|
+
*/
|
|
45086
|
+
/**
|
|
45087
|
+
* ```js
|
|
45088
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
45089
|
+
*
|
|
45090
|
+
* let posts = []
|
|
45091
|
+
* const unsub = PostRepository.getLiveRoomPosts({
|
|
45092
|
+
* targetType: Amity.PostTargetType,
|
|
45093
|
+
* targetId: Amity.Post['targetId'],
|
|
45094
|
+
* }, response => merge(posts, response.data))
|
|
45095
|
+
* ```
|
|
45096
|
+
*
|
|
45097
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given live room
|
|
45098
|
+
*
|
|
45099
|
+
* @param params.targetType the type of the target
|
|
45100
|
+
* @param params.targetId the ID of the target
|
|
45101
|
+
* @param callback the function to call when new data are available
|
|
45102
|
+
* @param config
|
|
45103
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the posts
|
|
45104
|
+
*
|
|
45105
|
+
* @category Posts Live Collection
|
|
45106
|
+
*/
|
|
45107
|
+
const getLiveRoomPosts = (callback) => {
|
|
45108
|
+
const { log, cache } = getActiveClient();
|
|
45109
|
+
if (!cache) {
|
|
45110
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
45111
|
+
}
|
|
45112
|
+
const timestamp = Date.now();
|
|
45113
|
+
log(`getLiveRoomPosts(tmpid: ${timestamp}) > listen`);
|
|
45114
|
+
const liveRoomPostsLiveCollection = new LiveRoomPostLiveCollectionController(callback);
|
|
45115
|
+
const disposers = liveRoomPostsLiveCollection.startSubscription();
|
|
45116
|
+
const cacheKey = liveRoomPostsLiveCollection.getCacheKey();
|
|
45117
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
45118
|
+
return () => {
|
|
45119
|
+
log(`getLiveRoomPosts(tmpid: ${timestamp}) > dispose`);
|
|
45120
|
+
disposers.forEach(fn => fn());
|
|
45121
|
+
};
|
|
45122
|
+
};
|
|
45123
|
+
/* end_public_function */
|
|
45124
|
+
|
|
45125
|
+
class CommunityLiveRoomPostPaginationController extends PaginationNoPageController {
|
|
45126
|
+
async getRequest(queryParams) {
|
|
45127
|
+
const { limit = 100, communityIds } = queryParams;
|
|
45128
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/rooms/lives`, {
|
|
45129
|
+
params: {
|
|
45130
|
+
targetTypes: ['community'],
|
|
45131
|
+
targetIds: communityIds,
|
|
45132
|
+
options: {
|
|
45133
|
+
limit,
|
|
45134
|
+
sortBy: 'lastCreated',
|
|
45135
|
+
},
|
|
45136
|
+
},
|
|
45137
|
+
});
|
|
45138
|
+
return queryResponse;
|
|
45139
|
+
}
|
|
45140
|
+
}
|
|
45141
|
+
|
|
45142
|
+
class CommunityLiveRoomPostQueryStreamController extends QueryStreamController {
|
|
45143
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
45144
|
+
super(query, cacheKey);
|
|
45145
|
+
this.notifyChange = notifyChange;
|
|
45146
|
+
this.preparePayload = preparePayload;
|
|
45147
|
+
}
|
|
45148
|
+
async saveToMainDB(response) {
|
|
45149
|
+
const processedPayload = await this.preparePayload(response);
|
|
45150
|
+
const client = getActiveClient();
|
|
45151
|
+
const cachedAt = client.cache && Date.now();
|
|
45152
|
+
if (client.cache) {
|
|
45153
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
43337
45154
|
}
|
|
43338
|
-
|
|
43339
|
-
|
|
43340
|
-
|
|
43341
|
-
|
|
43342
|
-
|
|
43343
|
-
|
|
43344
|
-
|
|
43345
|
-
break;
|
|
45155
|
+
}
|
|
45156
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
45157
|
+
var _a, _b;
|
|
45158
|
+
if (refresh) {
|
|
45159
|
+
pushToCache(this.cacheKey, {
|
|
45160
|
+
data: resolvePostIdsFromRooms(response.rooms, response.posts),
|
|
45161
|
+
});
|
|
43346
45162
|
}
|
|
43347
|
-
|
|
45163
|
+
else {
|
|
45164
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45165
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
45166
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...resolvePostIdsFromRooms(response.rooms, response.posts)])] }));
|
|
45167
|
+
}
|
|
45168
|
+
}
|
|
45169
|
+
reactor(action) {
|
|
45170
|
+
return (room) => {
|
|
45171
|
+
var _a;
|
|
45172
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45173
|
+
if (!collection)
|
|
45174
|
+
return;
|
|
45175
|
+
if (room.status === 'ended') {
|
|
45176
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: collection.data.filter(postId => room.referenceId !== postId) }));
|
|
45177
|
+
}
|
|
45178
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
45179
|
+
};
|
|
45180
|
+
}
|
|
45181
|
+
subscribeRTE(createSubscriber) {
|
|
45182
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
45183
|
+
}
|
|
45184
|
+
}
|
|
45185
|
+
|
|
45186
|
+
class CommunityLiveRoomPostLiveCollectionController extends LiveCollectionController {
|
|
45187
|
+
constructor(query, callback) {
|
|
45188
|
+
const queryStreamId = hash(query);
|
|
45189
|
+
const cacheKey = ['communityLiveRoomPosts', 'collection', queryStreamId];
|
|
45190
|
+
const paginationController = new CommunityLiveRoomPostPaginationController(query);
|
|
45191
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
45192
|
+
this.query = query;
|
|
45193
|
+
this.queryStreamController = new CommunityLiveRoomPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
45194
|
+
this.callback = callback.bind(this);
|
|
45195
|
+
this.loadPage({ initial: true });
|
|
45196
|
+
}
|
|
45197
|
+
setup() {
|
|
45198
|
+
var _a;
|
|
45199
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45200
|
+
if (!collection) {
|
|
45201
|
+
pushToCache(this.cacheKey, {
|
|
45202
|
+
data: [],
|
|
45203
|
+
params: {},
|
|
45204
|
+
});
|
|
45205
|
+
}
|
|
45206
|
+
}
|
|
45207
|
+
async persistModel(queryPayload) {
|
|
45208
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
45209
|
+
}
|
|
45210
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
45211
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
45212
|
+
}
|
|
45213
|
+
startSubscription() {
|
|
45214
|
+
return this.queryStreamController.subscribeRTE([
|
|
45215
|
+
{ fn: onRoomEndBroadcasting, action: EnumPostActions.OnPostUpdated },
|
|
45216
|
+
]);
|
|
45217
|
+
}
|
|
45218
|
+
notifyChange({ origin, loading, error }) {
|
|
45219
|
+
var _a, _b;
|
|
45220
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45221
|
+
if (!collection)
|
|
45222
|
+
return;
|
|
45223
|
+
const data = this.applyFilter((_b = collection.data
|
|
45224
|
+
.map((id) => pullFromCache(['post', 'get', id]))
|
|
45225
|
+
.filter(isNonNullable)
|
|
45226
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
45227
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
45228
|
+
return;
|
|
45229
|
+
this.callback({
|
|
45230
|
+
data,
|
|
45231
|
+
loading,
|
|
45232
|
+
error,
|
|
45233
|
+
});
|
|
45234
|
+
}
|
|
45235
|
+
// eslint-disable-next-line class-methods-use-this
|
|
45236
|
+
applyFilter(data) {
|
|
45237
|
+
// No additional filtering needed for live room posts
|
|
45238
|
+
// API handles all filtering based on targetId and targetType
|
|
45239
|
+
return data;
|
|
43348
45240
|
}
|
|
43349
45241
|
}
|
|
43350
45242
|
|
|
43351
45243
|
/* begin_public_function
|
|
43352
|
-
id: post.query
|
|
45244
|
+
id: post.communityLiveRoom.query
|
|
43353
45245
|
*/
|
|
43354
45246
|
/**
|
|
43355
45247
|
* ```js
|
|
43356
45248
|
* import { PostRepository } from '@amityco/ts-sdk'
|
|
43357
45249
|
*
|
|
43358
45250
|
* let posts = []
|
|
43359
|
-
* const unsub = PostRepository.
|
|
43360
|
-
*
|
|
43361
|
-
* limit: 10,
|
|
45251
|
+
* const unsub = PostRepository.getCommunityLiveRoomPosts({
|
|
45252
|
+
* targetId: 'communityId',
|
|
43362
45253
|
* }, response => merge(posts, response.data))
|
|
43363
45254
|
* ```
|
|
43364
45255
|
*
|
|
43365
|
-
* Observe all mutations on a list of {@link Amity.Post} for a
|
|
45256
|
+
* Observe all mutations on a list of {@link Amity.Post} for live rooms in a specific community
|
|
43366
45257
|
*
|
|
43367
|
-
* @param params.
|
|
45258
|
+
* @param params.targetId the ID of the community
|
|
45259
|
+
* @param params.limit optional limit for the number of posts to fetch
|
|
43368
45260
|
* @param callback the function to call when new data are available
|
|
43369
45261
|
* @param config
|
|
43370
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the
|
|
45262
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the posts
|
|
43371
45263
|
*
|
|
43372
45264
|
* @category Posts Live Collection
|
|
43373
45265
|
*/
|
|
43374
|
-
const
|
|
45266
|
+
const getCommunityLiveRoomPosts = (params, callback, config) => {
|
|
43375
45267
|
const { log, cache } = getActiveClient();
|
|
43376
45268
|
if (!cache) {
|
|
43377
45269
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
43378
45270
|
}
|
|
43379
45271
|
const timestamp = Date.now();
|
|
43380
|
-
log(`
|
|
43381
|
-
const
|
|
43382
|
-
const disposers =
|
|
43383
|
-
const cacheKey =
|
|
45272
|
+
log(`getCommunityLiveRoomPosts(tmpid: ${timestamp}) > listen`);
|
|
45273
|
+
const communityLiveRoomPostsLiveCollection = new CommunityLiveRoomPostLiveCollectionController(params, callback);
|
|
45274
|
+
const disposers = communityLiveRoomPostsLiveCollection.startSubscription();
|
|
45275
|
+
const cacheKey = communityLiveRoomPostsLiveCollection.getCacheKey();
|
|
43384
45276
|
disposers.push(() => dropFromCache(cacheKey));
|
|
43385
45277
|
return () => {
|
|
43386
|
-
log(`
|
|
45278
|
+
log(`getCommunityLiveRoomPosts(tmpid: ${timestamp}) > dispose`);
|
|
43387
45279
|
disposers.forEach(fn => fn());
|
|
43388
45280
|
};
|
|
43389
45281
|
};
|
|
43390
45282
|
/* end_public_function */
|
|
43391
45283
|
|
|
43392
|
-
var index$
|
|
45284
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
43393
45285
|
__proto__: null,
|
|
43394
45286
|
getPostByIds: getPostByIds,
|
|
43395
45287
|
createPost: createPost,
|
|
@@ -43419,7 +45311,9 @@ var index$9 = /*#__PURE__*/Object.freeze({
|
|
|
43419
45311
|
getPinnedPosts: getPinnedPosts,
|
|
43420
45312
|
getGlobalPinnedPosts: getGlobalPinnedPosts,
|
|
43421
45313
|
semanticSearchPosts: semanticSearchPosts,
|
|
43422
|
-
searchPostsByHashtag: searchPostsByHashtag
|
|
45314
|
+
searchPostsByHashtag: searchPostsByHashtag,
|
|
45315
|
+
getLiveRoomPosts: getLiveRoomPosts,
|
|
45316
|
+
getCommunityLiveRoomPosts: getCommunityLiveRoomPosts
|
|
43423
45317
|
});
|
|
43424
45318
|
|
|
43425
45319
|
/* begin_public_function
|
|
@@ -43997,7 +45891,7 @@ const getStreams = (params, callback, config) => {
|
|
|
43997
45891
|
};
|
|
43998
45892
|
};
|
|
43999
45893
|
|
|
44000
|
-
var index$
|
|
45894
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
44001
45895
|
__proto__: null,
|
|
44002
45896
|
createStream: createStream,
|
|
44003
45897
|
updateStream: updateStream,
|
|
@@ -44015,6 +45909,299 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
44015
45909
|
getStreams: getStreams
|
|
44016
45910
|
});
|
|
44017
45911
|
|
|
45912
|
+
/* begin_public_function
|
|
45913
|
+
id: roomPresence.getRoomOnlineUsers
|
|
45914
|
+
*/
|
|
45915
|
+
/**
|
|
45916
|
+
* ```js
|
|
45917
|
+
* import { getRoomOnlineUsers } from '@amityco/ts-sdk'
|
|
45918
|
+
* const result = await getRoomOnlineUsers('roomId')
|
|
45919
|
+
* ```
|
|
45920
|
+
*
|
|
45921
|
+
* Retrieves the list of users currently online in a specific room.
|
|
45922
|
+
* This function fetches all users who are actively watching or present in the room,
|
|
45923
|
+
* handling pagination automatically for large numbers of users.
|
|
45924
|
+
*
|
|
45925
|
+
* @param roomId The ID of the room to get online users for
|
|
45926
|
+
* @returns Promise that resolves with a cached list of online users
|
|
45927
|
+
*
|
|
45928
|
+
* @category Room Presence API
|
|
45929
|
+
* @async
|
|
45930
|
+
*/
|
|
45931
|
+
const getRoomOnlineUsers = async (roomId) => {
|
|
45932
|
+
var _a, _b, _c;
|
|
45933
|
+
const client = getActiveClient();
|
|
45934
|
+
client.log('room/getWatchingUsers', { roomId });
|
|
45935
|
+
const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users`);
|
|
45936
|
+
const viewerIds = (_a = data === null || data === void 0 ? void 0 : data.viewers.map(viewer => viewer.userId)) !== null && _a !== void 0 ? _a : [];
|
|
45937
|
+
// getUserByIds has a maximum limit of 100 users per call
|
|
45938
|
+
// Split into chunks of 100 if we have more than 100 users
|
|
45939
|
+
const BATCH_SIZE = 100;
|
|
45940
|
+
const batches = [];
|
|
45941
|
+
for (let i = 0; i < viewerIds.length; i += BATCH_SIZE) {
|
|
45942
|
+
batches.push(viewerIds.slice(i, i + BATCH_SIZE));
|
|
45943
|
+
}
|
|
45944
|
+
// Fetch all batches in parallel
|
|
45945
|
+
const batchResults = await Promise.all(batches.map(batch => getUserByIds(batch)));
|
|
45946
|
+
// Merge all results
|
|
45947
|
+
const allViewers = [];
|
|
45948
|
+
batchResults.forEach(result => {
|
|
45949
|
+
if (result.data) {
|
|
45950
|
+
allViewers.push(...result.data);
|
|
45951
|
+
}
|
|
45952
|
+
});
|
|
45953
|
+
// Return in the same format as getUserByIds
|
|
45954
|
+
return {
|
|
45955
|
+
data: allViewers,
|
|
45956
|
+
cachedAt: (_c = (_b = batchResults[0]) === null || _b === void 0 ? void 0 : _b.cachedAt) !== null && _c !== void 0 ? _c : Date.now(),
|
|
45957
|
+
};
|
|
45958
|
+
};
|
|
45959
|
+
/* end_public_function */
|
|
45960
|
+
|
|
45961
|
+
/* begin_public_function
|
|
45962
|
+
id: roomPresence.getRoomUserCount
|
|
45963
|
+
*/
|
|
45964
|
+
/**
|
|
45965
|
+
* ```js
|
|
45966
|
+
* import { getRoomUserCount } from '@amityco/ts-sdk'
|
|
45967
|
+
* const count = await getRoomUserCount('roomId')
|
|
45968
|
+
* ```
|
|
45969
|
+
*
|
|
45970
|
+
* Retrieves the count of users currently watching or present in a specific room.
|
|
45971
|
+
* This function returns the total number of online users without fetching their full user data.
|
|
45972
|
+
*
|
|
45973
|
+
* @param roomId The ID of the room to get the user count for
|
|
45974
|
+
* @returns Promise that resolves with the room watching count data
|
|
45975
|
+
*
|
|
45976
|
+
* @category Room Presence API
|
|
45977
|
+
* @async
|
|
45978
|
+
*/
|
|
45979
|
+
const getRoomUserCount = async (roomId) => {
|
|
45980
|
+
const client = getActiveClient();
|
|
45981
|
+
client.log('roomPresence/getRoomUserCount', { roomId });
|
|
45982
|
+
const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
|
|
45983
|
+
pushToCache(['get', 'watchingCount', roomId], data);
|
|
45984
|
+
return data;
|
|
45985
|
+
};
|
|
45986
|
+
/* end_public_function */
|
|
45987
|
+
|
|
45988
|
+
const getPresenceSetting = async () => {
|
|
45989
|
+
const client = getActiveClient();
|
|
45990
|
+
client.log('presence/getPresenceSetting');
|
|
45991
|
+
const { data } = await client.http.get('/api/v1/presence/settings');
|
|
45992
|
+
pushToCache(['get', 'presenceSetting'], data);
|
|
45993
|
+
return data;
|
|
45994
|
+
};
|
|
45995
|
+
|
|
45996
|
+
class RoomPresenceSyncEngine {
|
|
45997
|
+
constructor(roomId) {
|
|
45998
|
+
this.isEnabled = false;
|
|
45999
|
+
this.config = {
|
|
46000
|
+
heartbeatInterval: 30 * SECOND$1,
|
|
46001
|
+
};
|
|
46002
|
+
this.roomId = roomId;
|
|
46003
|
+
// Initialize config asynchronously - don't await in constructor
|
|
46004
|
+
this.initializeConfig().catch(error => {
|
|
46005
|
+
console.error('Failed to initialize RoomPresenceSyncEngine config in constructor:', error);
|
|
46006
|
+
});
|
|
46007
|
+
}
|
|
46008
|
+
async initializeConfig() {
|
|
46009
|
+
try {
|
|
46010
|
+
// Get presence settings from API with retry logic
|
|
46011
|
+
const presenceSettings = await RoomPresenceSyncEngine.getPresenceSettingWithRetry();
|
|
46012
|
+
if (presenceSettings) {
|
|
46013
|
+
// Set intervals from network settings (convert from minutes to milliseconds)
|
|
46014
|
+
this.config = {
|
|
46015
|
+
heartbeatInterval: (presenceSettings.network.heartbeatInterval || 5) * 60 * 1000,
|
|
46016
|
+
};
|
|
46017
|
+
}
|
|
46018
|
+
else {
|
|
46019
|
+
// Use default intervals if all retries failed
|
|
46020
|
+
this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
|
|
46021
|
+
}
|
|
46022
|
+
}
|
|
46023
|
+
catch (error) {
|
|
46024
|
+
console.error('Failed to initialize RoomPresenceSyncEngine config:', error);
|
|
46025
|
+
// Use default intervals if settings fetch fails
|
|
46026
|
+
this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
|
|
46027
|
+
}
|
|
46028
|
+
}
|
|
46029
|
+
static async getPresenceSettingWithRetry(maxRetries = 5) {
|
|
46030
|
+
for (let attempt = 0; attempt < maxRetries; attempt += 1) {
|
|
46031
|
+
try {
|
|
46032
|
+
// eslint-disable-next-line no-await-in-loop
|
|
46033
|
+
const presenceSettings = await getPresenceSetting();
|
|
46034
|
+
return presenceSettings;
|
|
46035
|
+
}
|
|
46036
|
+
catch (error) {
|
|
46037
|
+
if (attempt >= maxRetries - 1) {
|
|
46038
|
+
console.error(`Failed to get presence setting after ${maxRetries} attempts:`, error);
|
|
46039
|
+
return null;
|
|
46040
|
+
}
|
|
46041
|
+
// Calculate delay: 20 seconds + random jitter (0-5 seconds)
|
|
46042
|
+
const jitter = Math.random() * 5000; // 0-5 seconds in milliseconds
|
|
46043
|
+
const delay = 20000 + jitter; // 20 seconds + jitter
|
|
46044
|
+
console.warn(`Failed to get presence setting (attempt ${attempt + 1}/${maxRetries}), retrying in ${Math.round(delay / 1000)}s:`, error);
|
|
46045
|
+
// Wait before retry
|
|
46046
|
+
// eslint-disable-next-line no-await-in-loop
|
|
46047
|
+
await new Promise(resolve => {
|
|
46048
|
+
setTimeout(resolve, delay);
|
|
46049
|
+
});
|
|
46050
|
+
}
|
|
46051
|
+
}
|
|
46052
|
+
return null;
|
|
46053
|
+
}
|
|
46054
|
+
/**
|
|
46055
|
+
* Start heartbeat for the room
|
|
46056
|
+
*/
|
|
46057
|
+
start() {
|
|
46058
|
+
if (this.isEnabled)
|
|
46059
|
+
return;
|
|
46060
|
+
this.isEnabled = true;
|
|
46061
|
+
// Send immediate heartbeat
|
|
46062
|
+
this.sendHeartbeat();
|
|
46063
|
+
// Start heartbeat timer
|
|
46064
|
+
this.heartbeatTimer = setInterval(() => {
|
|
46065
|
+
this.sendHeartbeat();
|
|
46066
|
+
}, this.config.heartbeatInterval);
|
|
46067
|
+
}
|
|
46068
|
+
/**
|
|
46069
|
+
* Stop heartbeat for the room
|
|
46070
|
+
*/
|
|
46071
|
+
stop() {
|
|
46072
|
+
this.isEnabled = false;
|
|
46073
|
+
// Stop heartbeat timer
|
|
46074
|
+
if (this.heartbeatTimer) {
|
|
46075
|
+
clearInterval(this.heartbeatTimer);
|
|
46076
|
+
this.heartbeatTimer = undefined;
|
|
46077
|
+
}
|
|
46078
|
+
}
|
|
46079
|
+
/**
|
|
46080
|
+
* Send heartbeat to the room
|
|
46081
|
+
*/
|
|
46082
|
+
async sendHeartbeat() {
|
|
46083
|
+
try {
|
|
46084
|
+
const client = getActiveClient();
|
|
46085
|
+
await client.http.post(`/api/v1/presence/rooms/${this.roomId}/heartbeat`);
|
|
46086
|
+
}
|
|
46087
|
+
catch (error) {
|
|
46088
|
+
console.error(`Heartbeat failed for room ${this.roomId}:`, error);
|
|
46089
|
+
}
|
|
46090
|
+
}
|
|
46091
|
+
/**
|
|
46092
|
+
* Get the room ID
|
|
46093
|
+
*/
|
|
46094
|
+
getRoomId() {
|
|
46095
|
+
return this.roomId;
|
|
46096
|
+
}
|
|
46097
|
+
/**
|
|
46098
|
+
* Check if the engine is enabled
|
|
46099
|
+
*/
|
|
46100
|
+
isActive() {
|
|
46101
|
+
return this.isEnabled;
|
|
46102
|
+
}
|
|
46103
|
+
/**
|
|
46104
|
+
* Cleanup method to stop all timers and release resources
|
|
46105
|
+
* Call this when the engine instance is no longer needed
|
|
46106
|
+
*/
|
|
46107
|
+
destroy() {
|
|
46108
|
+
// Stop the engine
|
|
46109
|
+
this.stop();
|
|
46110
|
+
}
|
|
46111
|
+
// Session Management
|
|
46112
|
+
onSessionDestroyed() {
|
|
46113
|
+
// Stop all timers when session is destroyed and cleanup
|
|
46114
|
+
this.destroy();
|
|
46115
|
+
}
|
|
46116
|
+
onTokenExpired() {
|
|
46117
|
+
// Stop engine when token expires
|
|
46118
|
+
this.stop();
|
|
46119
|
+
}
|
|
46120
|
+
}
|
|
46121
|
+
|
|
46122
|
+
// Map to store engine instances per roomId
|
|
46123
|
+
const engineInstances = new Map();
|
|
46124
|
+
/**
|
|
46125
|
+
* Get or create a RoomPresenceSyncEngine instance for a specific room
|
|
46126
|
+
*
|
|
46127
|
+
* @param roomId The room ID to get/create engine for
|
|
46128
|
+
* @returns RoomPresenceSyncEngine instance for the room
|
|
46129
|
+
*/
|
|
46130
|
+
const getRoomPresenceSyncEngine = (roomId) => {
|
|
46131
|
+
let engine = engineInstances.get(roomId);
|
|
46132
|
+
if (!engine) {
|
|
46133
|
+
engine = new RoomPresenceSyncEngine(roomId);
|
|
46134
|
+
engineInstances.set(roomId, engine);
|
|
46135
|
+
}
|
|
46136
|
+
return engine;
|
|
46137
|
+
};
|
|
46138
|
+
/**
|
|
46139
|
+
* Destroy the engine instance for a specific room
|
|
46140
|
+
*
|
|
46141
|
+
* @param roomId The room ID to destroy engine for
|
|
46142
|
+
*/
|
|
46143
|
+
const destroyRoomPresenceSyncEngine = (roomId) => {
|
|
46144
|
+
const engine = engineInstances.get(roomId);
|
|
46145
|
+
if (engine) {
|
|
46146
|
+
engine.destroy();
|
|
46147
|
+
engineInstances.delete(roomId);
|
|
46148
|
+
}
|
|
46149
|
+
};
|
|
46150
|
+
|
|
46151
|
+
/* begin_public_function
|
|
46152
|
+
id: roomPresence.startHeartbeat
|
|
46153
|
+
*/
|
|
46154
|
+
/**
|
|
46155
|
+
* ```js
|
|
46156
|
+
* import { startHeartbeat } from '@amityco/ts-sdk'
|
|
46157
|
+
* startHeartbeat('roomId')
|
|
46158
|
+
* ```
|
|
46159
|
+
*
|
|
46160
|
+
* Starts sending heartbeat signals for a specific room to maintain presence status.
|
|
46161
|
+
* This enables the room presence tracking and notifies the server that the user is actively viewing the room.
|
|
46162
|
+
*
|
|
46163
|
+
* @param roomId The ID of the room to start heartbeat for
|
|
46164
|
+
*
|
|
46165
|
+
* @category Room Presence API
|
|
46166
|
+
*/
|
|
46167
|
+
const startHeartbeat = (roomId) => {
|
|
46168
|
+
const engine = getRoomPresenceSyncEngine(roomId);
|
|
46169
|
+
engine.start();
|
|
46170
|
+
};
|
|
46171
|
+
/* end_public_function */
|
|
46172
|
+
|
|
46173
|
+
/* begin_public_function
|
|
46174
|
+
id: roomPresence.stopHeartbeat
|
|
46175
|
+
*/
|
|
46176
|
+
/**
|
|
46177
|
+
* ```js
|
|
46178
|
+
* import { stopHeartbeat } from '@amityco/ts-sdk'
|
|
46179
|
+
* stopHeartbeat('roomId')
|
|
46180
|
+
* ```
|
|
46181
|
+
*
|
|
46182
|
+
* Stops sending heartbeat signals for a specific room.
|
|
46183
|
+
* This disables the room presence tracking for the specified room and stops notifying the server of the user's presence.
|
|
46184
|
+
*
|
|
46185
|
+
* @param roomId The ID of the room to stop heartbeat for
|
|
46186
|
+
*
|
|
46187
|
+
* @category Room Presence API
|
|
46188
|
+
*/
|
|
46189
|
+
const stopHeartbeat = (roomId) => {
|
|
46190
|
+
const engine = getRoomPresenceSyncEngine(roomId);
|
|
46191
|
+
engine.stop();
|
|
46192
|
+
// Clean up the engine instance
|
|
46193
|
+
destroyRoomPresenceSyncEngine(roomId);
|
|
46194
|
+
};
|
|
46195
|
+
/* end_public_function */
|
|
46196
|
+
|
|
46197
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
46198
|
+
__proto__: null,
|
|
46199
|
+
getRoomOnlineUsers: getRoomOnlineUsers,
|
|
46200
|
+
getRoomUserCount: getRoomUserCount,
|
|
46201
|
+
startHeartbeat: startHeartbeat,
|
|
46202
|
+
stopHeartbeat: stopHeartbeat
|
|
46203
|
+
});
|
|
46204
|
+
|
|
44018
46205
|
/* begin_public_function
|
|
44019
46206
|
id: poll.create
|
|
44020
46207
|
*/
|
|
@@ -46308,6 +48495,40 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
46308
48495
|
onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
|
|
46309
48496
|
});
|
|
46310
48497
|
|
|
48498
|
+
/* begin_public_function
|
|
48499
|
+
id: invitation.reject
|
|
48500
|
+
*/
|
|
48501
|
+
/**
|
|
48502
|
+
* ```js
|
|
48503
|
+
* import { rejectInvitation } from '@amityco/ts-sdk'
|
|
48504
|
+
* const isRejected = await rejectInvitation(invitationId)
|
|
48505
|
+
* ```
|
|
48506
|
+
*
|
|
48507
|
+
* Rejects a {@link Amity.Invitation} object
|
|
48508
|
+
*
|
|
48509
|
+
* @param invitationId the {@link Amity.Invitation} to reject
|
|
48510
|
+
* @returns A success boolean if the {@link Amity.Invitation} was rejected
|
|
48511
|
+
*
|
|
48512
|
+
* @category Invitation API
|
|
48513
|
+
* @async
|
|
48514
|
+
*/
|
|
48515
|
+
const cancelInvitation = async (invitationId) => {
|
|
48516
|
+
var _a;
|
|
48517
|
+
const client = getActiveClient();
|
|
48518
|
+
client.log('invitation/cancelInvitation', invitationId);
|
|
48519
|
+
const { data } = await client.http.delete(`/api/v1/invitations/${invitationId}`);
|
|
48520
|
+
const invitation = (_a = pullFromCache([
|
|
48521
|
+
'invitation',
|
|
48522
|
+
'get',
|
|
48523
|
+
invitationId,
|
|
48524
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
48525
|
+
pushToTombstone('invitation', invitationId);
|
|
48526
|
+
if (invitation)
|
|
48527
|
+
fireEvent('local.invitation.canceled', [invitation]);
|
|
48528
|
+
return data.success;
|
|
48529
|
+
};
|
|
48530
|
+
/* end_public_function */
|
|
48531
|
+
|
|
46311
48532
|
class MyInvitationsPaginationController extends PaginationController {
|
|
46312
48533
|
async getRequest(queryParams, token) {
|
|
46313
48534
|
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
@@ -46368,7 +48589,7 @@ class MyInvitationsQueryStreamController extends QueryStreamController {
|
|
|
46368
48589
|
]),
|
|
46369
48590
|
];
|
|
46370
48591
|
}
|
|
46371
|
-
if (action === InvitationActionsEnum.
|
|
48592
|
+
if (action === InvitationActionsEnum.OnLocalInvitationCanceled) {
|
|
46372
48593
|
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
46373
48594
|
}
|
|
46374
48595
|
pushToCache(this.cacheKey, collection);
|
|
@@ -46418,8 +48639,8 @@ class MyInvitationsLiveCollectionController extends LiveCollectionController {
|
|
|
46418
48639
|
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
46419
48640
|
},
|
|
46420
48641
|
{
|
|
46421
|
-
fn:
|
|
46422
|
-
action: InvitationActionsEnum.
|
|
48642
|
+
fn: onLocalInvitationCanceled,
|
|
48643
|
+
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
46423
48644
|
},
|
|
46424
48645
|
]);
|
|
46425
48646
|
}
|
|
@@ -46500,12 +48721,77 @@ const getMyCommunityInvitations = (params, callback, config) => {
|
|
|
46500
48721
|
};
|
|
46501
48722
|
};
|
|
46502
48723
|
|
|
48724
|
+
/* begin_public_function
|
|
48725
|
+
id: invitation.get_invitations
|
|
48726
|
+
*/
|
|
48727
|
+
/**
|
|
48728
|
+
*
|
|
48729
|
+
* ```js
|
|
48730
|
+
* import { InvitationRepository } from '@amityco/ts-sdk';
|
|
48731
|
+
*
|
|
48732
|
+
* // For room invitations
|
|
48733
|
+
* const unsubscribe = InvitationRepository.getInvitations(
|
|
48734
|
+
* { targetId: 'room123', targetType: 'room' },
|
|
48735
|
+
* response => {
|
|
48736
|
+
* console.log('Room invitation event:', response.room, response.users, response.eventType)
|
|
48737
|
+
* }
|
|
48738
|
+
* );
|
|
48739
|
+
*
|
|
48740
|
+
* // For community invitations (when implemented)
|
|
48741
|
+
* const unsubscribe2 = observeInvitations(
|
|
48742
|
+
* { targetId: 'community456', targetType: 'community' },
|
|
48743
|
+
* response => {
|
|
48744
|
+
* console.log('Community invitation event:', response.community, response.users, response.eventType)
|
|
48745
|
+
* }
|
|
48746
|
+
* );
|
|
48747
|
+
* ```
|
|
48748
|
+
*
|
|
48749
|
+
* Observe invitations events including invited, accepted, rejected, and canceled
|
|
48750
|
+
*
|
|
48751
|
+
* @param params The target ID and type to observe invitations for
|
|
48752
|
+
* @param callback The function to call when new invitation events are available
|
|
48753
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the events
|
|
48754
|
+
*
|
|
48755
|
+
* @category Invitation Observable
|
|
48756
|
+
*/
|
|
48757
|
+
const getInvitations = (params, callback) => {
|
|
48758
|
+
const { _id: userId } = getCurrentUser();
|
|
48759
|
+
if (!userId)
|
|
48760
|
+
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
48761
|
+
const { log } = getActiveClient();
|
|
48762
|
+
const { targetId, targetType } = params;
|
|
48763
|
+
const timestamp = Date.now();
|
|
48764
|
+
log(`observeInvitations(tmpid: ${timestamp}) > listen for ${targetType}: ${targetId}`);
|
|
48765
|
+
const disposers = [];
|
|
48766
|
+
const dispatcher = (data) => {
|
|
48767
|
+
callback(data.map(LinkedObject.invitation));
|
|
48768
|
+
};
|
|
48769
|
+
const realtimeRouter = (data) => {
|
|
48770
|
+
const invitations = (Array.isArray(data) ? data : [data]).filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
|
|
48771
|
+
dispatcher(invitations);
|
|
48772
|
+
};
|
|
48773
|
+
// Only subscribe to room co-host events for now (since that's what we have implemented)
|
|
48774
|
+
if (targetType === 'room') {
|
|
48775
|
+
// Create custom event subscribers that receive the full payload
|
|
48776
|
+
disposers.push(onRoomCoHostInvited(realtimeRouter));
|
|
48777
|
+
disposers.push(onRoomCoHostInviteAccepted(realtimeRouter));
|
|
48778
|
+
disposers.push(onRoomCoHostInviteRejected(realtimeRouter));
|
|
48779
|
+
disposers.push(onRoomCoHostInviteCanceled(realtimeRouter));
|
|
48780
|
+
}
|
|
48781
|
+
return () => {
|
|
48782
|
+
log(`getInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
|
|
48783
|
+
disposers.forEach(fn => fn());
|
|
48784
|
+
};
|
|
48785
|
+
};
|
|
48786
|
+
|
|
46503
48787
|
var index$2 = /*#__PURE__*/Object.freeze({
|
|
46504
48788
|
__proto__: null,
|
|
48789
|
+
cancelInvitation: cancelInvitation,
|
|
46505
48790
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
46506
48791
|
onLocalInvitationUpdated: onLocalInvitationUpdated,
|
|
46507
|
-
|
|
46508
|
-
getMyCommunityInvitations: getMyCommunityInvitations
|
|
48792
|
+
onLocalInvitationCanceled: onLocalInvitationCanceled,
|
|
48793
|
+
getMyCommunityInvitations: getMyCommunityInvitations,
|
|
48794
|
+
getInvitations: getInvitations
|
|
46509
48795
|
});
|
|
46510
48796
|
|
|
46511
48797
|
// TODO: confirm id
|
|
@@ -46533,7 +48819,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
46533
48819
|
* @category Live Reaction API
|
|
46534
48820
|
* @async
|
|
46535
48821
|
*/
|
|
46536
|
-
const createReaction = async ({ referenceId, referenceType, reactionName,
|
|
48822
|
+
const createReaction = async ({ referenceId, referenceType, reactionName, roomId, }) => {
|
|
46537
48823
|
const client = getActiveClient();
|
|
46538
48824
|
client.log('live_reaction/createReaction', {
|
|
46539
48825
|
referenceId,
|
|
@@ -46545,7 +48831,7 @@ const createReaction = async ({ referenceId, referenceType, reactionName, stream
|
|
|
46545
48831
|
reactionName,
|
|
46546
48832
|
referencePublicId: referenceId,
|
|
46547
48833
|
referenceType,
|
|
46548
|
-
|
|
48834
|
+
roomId,
|
|
46549
48835
|
occurredAt: new Date().toISOString(),
|
|
46550
48836
|
};
|
|
46551
48837
|
reactionSynceEngine.createLiveReaction(reaction);
|
|
@@ -46735,15 +49021,32 @@ const updateEvent = async (eventId, bundle) => {
|
|
|
46735
49021
|
const getEvent$1 = async (eventId) => {
|
|
46736
49022
|
const client = getActiveClient();
|
|
46737
49023
|
client.log('event/getEvent', eventId);
|
|
46738
|
-
|
|
46739
|
-
|
|
46740
|
-
|
|
46741
|
-
|
|
46742
|
-
|
|
46743
|
-
|
|
46744
|
-
|
|
46745
|
-
|
|
46746
|
-
|
|
49024
|
+
try {
|
|
49025
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
49026
|
+
const data = prepareEventPayload(payload);
|
|
49027
|
+
const cachedAt = client.cache && Date.now();
|
|
49028
|
+
if (client.cache)
|
|
49029
|
+
ingestInCache(data, { cachedAt });
|
|
49030
|
+
return {
|
|
49031
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
49032
|
+
cachedAt,
|
|
49033
|
+
};
|
|
49034
|
+
}
|
|
49035
|
+
catch (error) {
|
|
49036
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
49037
|
+
const event = getEvent$1.locally(eventId);
|
|
49038
|
+
if (!event)
|
|
49039
|
+
throw error;
|
|
49040
|
+
const deletedEvent = Object.assign(Object.assign({}, event === null || event === void 0 ? void 0 : event.data), { isDeleted: true });
|
|
49041
|
+
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
49042
|
+
const cachedAt = client.cache && Date.now();
|
|
49043
|
+
return {
|
|
49044
|
+
data: deletedEvent,
|
|
49045
|
+
cachedAt,
|
|
49046
|
+
};
|
|
49047
|
+
}
|
|
49048
|
+
throw error;
|
|
49049
|
+
}
|
|
46747
49050
|
};
|
|
46748
49051
|
/* end_public_function */
|
|
46749
49052
|
/**
|
|
@@ -46800,183 +49103,13 @@ const deleteEvent = async (eventId) => {
|
|
|
46800
49103
|
users: [],
|
|
46801
49104
|
files: [],
|
|
46802
49105
|
communities: [],
|
|
46803
|
-
|
|
49106
|
+
posts: [],
|
|
49107
|
+
rooms: [],
|
|
46804
49108
|
events: [deletedEvent],
|
|
46805
|
-
discussionCommunities: [],
|
|
46806
49109
|
});
|
|
46807
49110
|
};
|
|
46808
49111
|
/* end_public_function */
|
|
46809
49112
|
|
|
46810
|
-
/**
|
|
46811
|
-
* ```js
|
|
46812
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46813
|
-
* const dispose = EventRepository.onEventCreated(event => {
|
|
46814
|
-
* // ...
|
|
46815
|
-
* })
|
|
46816
|
-
* ```
|
|
46817
|
-
*
|
|
46818
|
-
* Fired when a {@link Amity.Event} has been created
|
|
46819
|
-
*
|
|
46820
|
-
* @param callback The function to call when the event was fired
|
|
46821
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46822
|
-
*
|
|
46823
|
-
* @category Event Events
|
|
46824
|
-
*/
|
|
46825
|
-
const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
|
|
46826
|
-
|
|
46827
|
-
/**
|
|
46828
|
-
* ```js
|
|
46829
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46830
|
-
* const dispose = EventRepository.onEventUpdated(event => {
|
|
46831
|
-
* // ...
|
|
46832
|
-
* })
|
|
46833
|
-
* ```
|
|
46834
|
-
*
|
|
46835
|
-
* Fired when a {@link Amity.Event} has been updated
|
|
46836
|
-
*
|
|
46837
|
-
* @param callback The function to call when the event was fired
|
|
46838
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46839
|
-
*
|
|
46840
|
-
* @category Event Events
|
|
46841
|
-
*/
|
|
46842
|
-
const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
|
|
46843
|
-
|
|
46844
|
-
/**
|
|
46845
|
-
* ```js
|
|
46846
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46847
|
-
* const dispose = EventRepository.onEventDeleted(event => {
|
|
46848
|
-
* // ...
|
|
46849
|
-
* })
|
|
46850
|
-
* ```
|
|
46851
|
-
*
|
|
46852
|
-
* Fired when a {@link Amity.Event} has been deleted
|
|
46853
|
-
*
|
|
46854
|
-
* @param callback The function to call when the event was fired
|
|
46855
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46856
|
-
*
|
|
46857
|
-
* @category Event Events
|
|
46858
|
-
*/
|
|
46859
|
-
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
46860
|
-
|
|
46861
|
-
/**
|
|
46862
|
-
* ```js
|
|
46863
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46864
|
-
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
46865
|
-
* // ...
|
|
46866
|
-
* })
|
|
46867
|
-
* ```
|
|
46868
|
-
*
|
|
46869
|
-
* Fired when a {@link Amity.Event} has been created
|
|
46870
|
-
*
|
|
46871
|
-
* @param callback The function to call when the event was fired
|
|
46872
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46873
|
-
*
|
|
46874
|
-
* @category Event Events
|
|
46875
|
-
*/
|
|
46876
|
-
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
46877
|
-
|
|
46878
|
-
/**
|
|
46879
|
-
* ```js
|
|
46880
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46881
|
-
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
46882
|
-
* // ...
|
|
46883
|
-
* })
|
|
46884
|
-
* ```
|
|
46885
|
-
*
|
|
46886
|
-
* Fired when a {@link Amity.Event} has been updated
|
|
46887
|
-
*
|
|
46888
|
-
* @param callback The function to call when the event was fired
|
|
46889
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46890
|
-
*
|
|
46891
|
-
* @category Event Events
|
|
46892
|
-
*/
|
|
46893
|
-
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
46894
|
-
|
|
46895
|
-
/**
|
|
46896
|
-
* ```js
|
|
46897
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46898
|
-
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
46899
|
-
* // ...
|
|
46900
|
-
* })
|
|
46901
|
-
* ```
|
|
46902
|
-
*
|
|
46903
|
-
* Fired when a {@link Amity.Event} has been deleted
|
|
46904
|
-
*
|
|
46905
|
-
* @param callback The function to call when the event was fired
|
|
46906
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46907
|
-
*
|
|
46908
|
-
* @category Event Events
|
|
46909
|
-
*/
|
|
46910
|
-
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
46911
|
-
|
|
46912
|
-
/**
|
|
46913
|
-
* ```js
|
|
46914
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46915
|
-
* const dispose = EventRepository.onRSVPCreated(event => {
|
|
46916
|
-
* // ...
|
|
46917
|
-
* })
|
|
46918
|
-
* ```
|
|
46919
|
-
*
|
|
46920
|
-
* Fired when a {@link Amity.Event} has been created
|
|
46921
|
-
*
|
|
46922
|
-
* @param callback The function to call when the event was fired
|
|
46923
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46924
|
-
*
|
|
46925
|
-
* @category Event Events
|
|
46926
|
-
*/
|
|
46927
|
-
const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
|
|
46928
|
-
|
|
46929
|
-
/**
|
|
46930
|
-
* ```js
|
|
46931
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46932
|
-
* const dispose = EventRepository.onRSVPUpdated(event => {
|
|
46933
|
-
* // ...
|
|
46934
|
-
* })
|
|
46935
|
-
* ```
|
|
46936
|
-
*
|
|
46937
|
-
* Fired when a {@link Amity.InternalEventResponse} has been updated
|
|
46938
|
-
*
|
|
46939
|
-
* @param callback The function to call when the event was fired
|
|
46940
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46941
|
-
*
|
|
46942
|
-
* @category Event Events
|
|
46943
|
-
*/
|
|
46944
|
-
const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
|
|
46945
|
-
|
|
46946
|
-
/**
|
|
46947
|
-
* ```js
|
|
46948
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46949
|
-
* const dispose = EventRepository.onLocalRSVPCreated(event => {
|
|
46950
|
-
* // ...
|
|
46951
|
-
* })
|
|
46952
|
-
* ```
|
|
46953
|
-
*
|
|
46954
|
-
* Fired when a {@link Amity.Event} has been created
|
|
46955
|
-
*
|
|
46956
|
-
* @param callback The function to call when the event was fired
|
|
46957
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46958
|
-
*
|
|
46959
|
-
* @category Event Events
|
|
46960
|
-
*/
|
|
46961
|
-
const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
|
|
46962
|
-
|
|
46963
|
-
/**
|
|
46964
|
-
* ```js
|
|
46965
|
-
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46966
|
-
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
46967
|
-
* // ...
|
|
46968
|
-
* })
|
|
46969
|
-
* ```
|
|
46970
|
-
*
|
|
46971
|
-
* Fired when a {@link Amity.Event} has been updated
|
|
46972
|
-
*
|
|
46973
|
-
* @param callback The function to call when the event was fired
|
|
46974
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46975
|
-
*
|
|
46976
|
-
* @category Event Events
|
|
46977
|
-
*/
|
|
46978
|
-
const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
|
|
46979
|
-
|
|
46980
49113
|
/* begin_public_function
|
|
46981
49114
|
id: event.get
|
|
46982
49115
|
*/
|
|
@@ -47006,15 +49139,6 @@ const getEvent = (eventId, callback) => {
|
|
|
47006
49139
|
};
|
|
47007
49140
|
/* end_public_function */
|
|
47008
49141
|
|
|
47009
|
-
var EventActionsEnum;
|
|
47010
|
-
(function (EventActionsEnum) {
|
|
47011
|
-
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
47012
|
-
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
47013
|
-
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
47014
|
-
EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
|
|
47015
|
-
EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
|
|
47016
|
-
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
47017
|
-
|
|
47018
49142
|
class EventPaginationController extends PaginationController {
|
|
47019
49143
|
async getRequest(queryParams, token) {
|
|
47020
49144
|
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
@@ -47286,141 +49410,6 @@ const getMyEvents = (params, callback, config) => {
|
|
|
47286
49410
|
};
|
|
47287
49411
|
};
|
|
47288
49412
|
|
|
47289
|
-
class RSVPPaginationController extends PaginationController {
|
|
47290
|
-
async getRequest(queryParams, token) {
|
|
47291
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
|
|
47292
|
-
const options = token ? { token } : { limit };
|
|
47293
|
-
const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
47294
|
-
return response;
|
|
47295
|
-
}
|
|
47296
|
-
}
|
|
47297
|
-
|
|
47298
|
-
class RSVPQueryStreamController extends QueryStreamController {
|
|
47299
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
47300
|
-
super(query, cacheKey);
|
|
47301
|
-
this.notifyChange = notifyChange;
|
|
47302
|
-
this.preparePayload = preparePayload;
|
|
47303
|
-
}
|
|
47304
|
-
async saveToMainDB(response) {
|
|
47305
|
-
const processedPayload = this.preparePayload(response);
|
|
47306
|
-
const client = getActiveClient();
|
|
47307
|
-
const cachedAt = client.cache && Date.now();
|
|
47308
|
-
if (client.cache)
|
|
47309
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
47310
|
-
}
|
|
47311
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
47312
|
-
var _a, _b;
|
|
47313
|
-
if (refresh) {
|
|
47314
|
-
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
47315
|
-
}
|
|
47316
|
-
else {
|
|
47317
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47318
|
-
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
47319
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
47320
|
-
}
|
|
47321
|
-
}
|
|
47322
|
-
reactor(action) {
|
|
47323
|
-
return (event) => {
|
|
47324
|
-
var _a;
|
|
47325
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47326
|
-
if (!collection)
|
|
47327
|
-
return;
|
|
47328
|
-
if (action === EventActionsEnum.OnEventCreated) {
|
|
47329
|
-
const client = getActiveClient();
|
|
47330
|
-
if (client.userId !== event.userId)
|
|
47331
|
-
return;
|
|
47332
|
-
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
47333
|
-
}
|
|
47334
|
-
if (action === EventActionsEnum.OnEventDeleted) {
|
|
47335
|
-
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
47336
|
-
}
|
|
47337
|
-
pushToCache(this.cacheKey, collection);
|
|
47338
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
47339
|
-
};
|
|
47340
|
-
}
|
|
47341
|
-
subscribeRTE(createSubscriber) {
|
|
47342
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
47343
|
-
}
|
|
47344
|
-
}
|
|
47345
|
-
|
|
47346
|
-
class RSVPLiveCollectionController extends LiveCollectionController {
|
|
47347
|
-
constructor(query, callback) {
|
|
47348
|
-
const queryStreamId = hash(query);
|
|
47349
|
-
const cacheKey = ['event', 'collection', queryStreamId];
|
|
47350
|
-
const paginationController = new RSVPPaginationController(query);
|
|
47351
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
47352
|
-
this.query = query;
|
|
47353
|
-
this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
47354
|
-
this.callback = callback.bind(this);
|
|
47355
|
-
this.loadPage({ initial: true });
|
|
47356
|
-
}
|
|
47357
|
-
setup() {
|
|
47358
|
-
var _a;
|
|
47359
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47360
|
-
if (!collection)
|
|
47361
|
-
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
47362
|
-
}
|
|
47363
|
-
async persistModel(queryPayload) {
|
|
47364
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
47365
|
-
}
|
|
47366
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
47367
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
47368
|
-
}
|
|
47369
|
-
startSubscription() {
|
|
47370
|
-
return this.queryStreamController.subscribeRTE([
|
|
47371
|
-
{ fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
47372
|
-
{ fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
47373
|
-
{ fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
47374
|
-
{ fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
47375
|
-
]);
|
|
47376
|
-
}
|
|
47377
|
-
notifyChange({ origin, loading, error }) {
|
|
47378
|
-
var _a, _b;
|
|
47379
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47380
|
-
if (!collection)
|
|
47381
|
-
return;
|
|
47382
|
-
const data = ((_b = collection.data
|
|
47383
|
-
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
47384
|
-
.filter(isNonNullable)
|
|
47385
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
47386
|
-
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
47387
|
-
return;
|
|
47388
|
-
this.callback({
|
|
47389
|
-
data,
|
|
47390
|
-
error,
|
|
47391
|
-
loading,
|
|
47392
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
47393
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
47394
|
-
});
|
|
47395
|
-
}
|
|
47396
|
-
}
|
|
47397
|
-
|
|
47398
|
-
/**
|
|
47399
|
-
* Get events
|
|
47400
|
-
*
|
|
47401
|
-
* @param params the query parameters
|
|
47402
|
-
* @param callback the callback to be called when the events are updated
|
|
47403
|
-
* @returns events
|
|
47404
|
-
*
|
|
47405
|
-
* @category RSVP Live Collection
|
|
47406
|
-
*
|
|
47407
|
-
*/
|
|
47408
|
-
const getRSVPs = (params, callback, config) => {
|
|
47409
|
-
const { log, cache } = getActiveClient();
|
|
47410
|
-
if (!cache)
|
|
47411
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
47412
|
-
const timestamp = Date.now();
|
|
47413
|
-
log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
|
|
47414
|
-
const eventLiveCollection = new RSVPLiveCollectionController(params, callback);
|
|
47415
|
-
const disposers = eventLiveCollection.startSubscription();
|
|
47416
|
-
const cacheKey = eventLiveCollection.getCacheKey();
|
|
47417
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
47418
|
-
return () => {
|
|
47419
|
-
log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
|
|
47420
|
-
disposers.forEach(fn => fn());
|
|
47421
|
-
};
|
|
47422
|
-
};
|
|
47423
|
-
|
|
47424
49413
|
var index = /*#__PURE__*/Object.freeze({
|
|
47425
49414
|
__proto__: null,
|
|
47426
49415
|
createEvent: createEvent,
|
|
@@ -47442,4 +49431,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
47442
49431
|
getRSVPs: getRSVPs
|
|
47443
49432
|
});
|
|
47444
49433
|
|
|
47445
|
-
export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, index$
|
|
49434
|
+
export { API_REGIONS, index$4 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$e as CategoryRepository, index$i as ChannelRepository, index$r as Client, index$d as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$f as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$c as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$o as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$m as MessageRepository, index$7 as PollRepository, PostContentType, index$a as PostRepository, PostStructureType, index$n as ReactionRepository, index$8 as RoomPresenceRepository, index$b as RoomRepository, index$5 as StoryRepository, index$9 as StreamRepository, index$l as SubChannelRepository, SubscriptionLevels, index$p as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, 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$3 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, wipeCache };
|