@amityco/ts-sdk 7.11.1-ec3d3468.0 → 7.11.1-f05493be.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 +4 -3
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +2 -2
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +20 -4
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +10 -7
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +20 -8
- package/dist/@types/domains/event.d.ts.map +1 -1
- package/dist/@types/domains/room.d.ts +18 -3
- package/dist/@types/domains/room.d.ts.map +1 -1
- package/dist/client/api/getPresenceSetting.d.ts +2 -0
- package/dist/client/api/getPresenceSetting.d.ts.map +1 -0
- 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/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/eventRepository/observers/index.d.ts +0 -1
- package/dist/eventRepository/observers/index.d.ts.map +1 -1
- package/dist/index.cjs.js +464 -285
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +450 -272
- package/dist/index.umd.js +3 -3
- package/dist/invitationRepository/api/index.d.ts +0 -1
- package/dist/invitationRepository/api/index.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/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 -1
- package/dist/invitationRepository/observers/index.d.ts.map +1 -1
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +2 -2
- package/dist/liveReactionRepository/internalApi/createLiveReaction.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/removeParticipant.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts +1 -1
- package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +1 -1
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +1 -1
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +1 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +1 -1
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +1 -1
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +1 -1
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -1
- package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
- package/dist/roomRepository/observers/utils.d.ts +1 -1
- package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +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/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +0 -13
- package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +0 -1
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +0 -5
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +0 -1
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +0 -15
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +0 -1
- package/dist/eventRepository/observers/getMyEvents.d.ts +0 -12
- package/dist/eventRepository/observers/getMyEvents.d.ts.map +0 -1
- package/dist/invitationRepository/api/acceptInvitation.d.ts +0 -16
- package/dist/invitationRepository/api/acceptInvitation.d.ts.map +0 -1
- package/dist/invitationRepository/api/getMyInvitation.d.ts +0 -16
- package/dist/invitationRepository/api/getMyInvitation.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/invitationRepository/observers/observeInvitations.d.ts +0 -34
- package/dist/invitationRepository/observers/observeInvitations.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/invitationRepository/{observers → internalObservers}/getInvitations/enums.d.ts +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -88,6 +88,11 @@ const CommunityPostSettingMaps = Object.freeze({
|
|
|
88
88
|
},
|
|
89
89
|
});
|
|
90
90
|
const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
|
|
91
|
+
exports.AmityCommunityType = void 0;
|
|
92
|
+
(function (AmityCommunityType) {
|
|
93
|
+
AmityCommunityType["Default"] = "default";
|
|
94
|
+
AmityCommunityType["Event"] = "event";
|
|
95
|
+
})(exports.AmityCommunityType || (exports.AmityCommunityType = {}));
|
|
91
96
|
|
|
92
97
|
const ContentFeedType = Object.freeze({
|
|
93
98
|
STORY: 'story',
|
|
@@ -222,6 +227,16 @@ exports.AmityEventResponseStatus = void 0;
|
|
|
222
227
|
AmityEventResponseStatus["Interested"] = "interested";
|
|
223
228
|
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
224
229
|
})(exports.AmityEventResponseStatus || (exports.AmityEventResponseStatus = {}));
|
|
230
|
+
exports.AmityEventSortOption = void 0;
|
|
231
|
+
(function (AmityEventSortOption) {
|
|
232
|
+
AmityEventSortOption["StartTime"] = "startTime";
|
|
233
|
+
AmityEventSortOption["CreatedAt"] = "createdAt";
|
|
234
|
+
})(exports.AmityEventSortOption || (exports.AmityEventSortOption = {}));
|
|
235
|
+
exports.AmityEventOrderOption = void 0;
|
|
236
|
+
(function (AmityEventOrderOption) {
|
|
237
|
+
AmityEventOrderOption["Ascending"] = "asc";
|
|
238
|
+
AmityEventOrderOption["Descending"] = "desc";
|
|
239
|
+
})(exports.AmityEventOrderOption || (exports.AmityEventOrderOption = {}));
|
|
225
240
|
|
|
226
241
|
function getVersion() {
|
|
227
242
|
try {
|
|
@@ -673,7 +688,6 @@ const idResolvers = {
|
|
|
673
688
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
674
689
|
room: ({ roomId }) => roomId,
|
|
675
690
|
event: ({ eventId }) => eventId,
|
|
676
|
-
discussionCommunity: ({ communityId }) => communityId,
|
|
677
691
|
};
|
|
678
692
|
/**
|
|
679
693
|
* Retrieve the id resolver matching a domain name
|
|
@@ -731,7 +745,7 @@ const PAYLOAD2MODEL = {
|
|
|
731
745
|
joinRequests: 'joinRequest',
|
|
732
746
|
rooms: 'room',
|
|
733
747
|
events: 'event',
|
|
734
|
-
|
|
748
|
+
viewers: 'viewer',
|
|
735
749
|
};
|
|
736
750
|
/** hidden */
|
|
737
751
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -1462,14 +1476,12 @@ const createEventEmitter = () => {
|
|
|
1462
1476
|
const proxyMqttEvents = (mqttClient, emitter) => {
|
|
1463
1477
|
MQTT_EVENTS.forEach(event => {
|
|
1464
1478
|
mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.on(event, (...params) => {
|
|
1465
|
-
console.log('global event received => ', event);
|
|
1466
1479
|
emitter.emit(event, params.length === 1 ? params[0] : params);
|
|
1467
1480
|
});
|
|
1468
1481
|
});
|
|
1469
1482
|
// @ts-ignore
|
|
1470
1483
|
mqttClient.on('message', (topic, payload) => {
|
|
1471
1484
|
const message = JSON.parse(payload.toString());
|
|
1472
|
-
console.log('message event received => ', message.eventType, message.data);
|
|
1473
1485
|
emitter.emit(message.eventType, message.data);
|
|
1474
1486
|
});
|
|
1475
1487
|
};
|
|
@@ -8511,11 +8523,11 @@ var objectResolverEngineOnLoginHandler = () => {
|
|
|
8511
8523
|
* @category Live Reaction API
|
|
8512
8524
|
* @async
|
|
8513
8525
|
*/
|
|
8514
|
-
const createLiveReaction = async ({ reactions,
|
|
8526
|
+
const createLiveReaction = async ({ reactions, liveStreamId, }) => {
|
|
8515
8527
|
const client = getActiveClient();
|
|
8516
8528
|
client.log('live_reaction/addReaction', reactions);
|
|
8517
8529
|
const { data } = await client.http.post(`/api/v1/reactions/live`, {
|
|
8518
|
-
|
|
8530
|
+
liveStreamId,
|
|
8519
8531
|
reactions,
|
|
8520
8532
|
});
|
|
8521
8533
|
return data;
|
|
@@ -8585,7 +8597,7 @@ class LiveReactionSyncEngine {
|
|
|
8585
8597
|
// Call server api `POST /api/v1/reactions/live` to sync live reactions
|
|
8586
8598
|
Object.entries(payloads).forEach(([roomId, reactions]) => {
|
|
8587
8599
|
createLiveReaction({
|
|
8588
|
-
roomId,
|
|
8600
|
+
liveStreamId: roomId,
|
|
8589
8601
|
reactions,
|
|
8590
8602
|
});
|
|
8591
8603
|
});
|
|
@@ -10507,7 +10519,7 @@ const getUserUnread = (callback) => {
|
|
|
10507
10519
|
};
|
|
10508
10520
|
};
|
|
10509
10521
|
|
|
10510
|
-
var index$
|
|
10522
|
+
var index$r = /*#__PURE__*/Object.freeze({
|
|
10511
10523
|
__proto__: null,
|
|
10512
10524
|
getActiveClient: getActiveClient,
|
|
10513
10525
|
getActiveUser: getActiveUser,
|
|
@@ -11726,7 +11738,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
11726
11738
|
};
|
|
11727
11739
|
/* end_public_function */
|
|
11728
11740
|
|
|
11729
|
-
var index$
|
|
11741
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
11730
11742
|
__proto__: null,
|
|
11731
11743
|
blockUser: blockUser,
|
|
11732
11744
|
unBlockUser: unBlockUser,
|
|
@@ -12371,7 +12383,7 @@ const createInvitations = async (bundle) => {
|
|
|
12371
12383
|
* @category Invitation API
|
|
12372
12384
|
* @async
|
|
12373
12385
|
*/
|
|
12374
|
-
const acceptInvitation
|
|
12386
|
+
const acceptInvitation = async (invitationId) => {
|
|
12375
12387
|
var _a;
|
|
12376
12388
|
const client = getActiveClient();
|
|
12377
12389
|
client.log('invitation/acceptInvitation', invitationId);
|
|
@@ -12457,7 +12469,7 @@ const invitationLinkedObject = (invitation) => {
|
|
|
12457
12469
|
}
|
|
12458
12470
|
return undefined;
|
|
12459
12471
|
}, accept: async () => {
|
|
12460
|
-
await acceptInvitation
|
|
12472
|
+
await acceptInvitation(invitation._id);
|
|
12461
12473
|
}, reject: async () => {
|
|
12462
12474
|
await rejectInvitation(invitation._id);
|
|
12463
12475
|
} });
|
|
@@ -12708,7 +12720,7 @@ class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
|
12708
12720
|
* @category Invitation Live Collection
|
|
12709
12721
|
*
|
|
12710
12722
|
*/
|
|
12711
|
-
const getInvitations = (params, callback, config) => {
|
|
12723
|
+
const getInvitations$1 = (params, callback, config) => {
|
|
12712
12724
|
const { log, cache } = getActiveClient();
|
|
12713
12725
|
if (!cache) {
|
|
12714
12726
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
@@ -12783,7 +12795,8 @@ const roomLinkedObject = (room) => {
|
|
|
12783
12795
|
},
|
|
12784
12796
|
get user() {
|
|
12785
12797
|
var _a;
|
|
12786
|
-
|
|
12798
|
+
const user = (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12799
|
+
return user ? userLinkedObject(user) : user;
|
|
12787
12800
|
},
|
|
12788
12801
|
get childRooms() {
|
|
12789
12802
|
if (!room.childRoomIds || room.childRoomIds.length === 0)
|
|
@@ -12797,12 +12810,16 @@ const roomLinkedObject = (room) => {
|
|
|
12797
12810
|
return roomLinkedObject(roomCache);
|
|
12798
12811
|
})
|
|
12799
12812
|
.filter(isNonNullable);
|
|
12800
|
-
},
|
|
12813
|
+
}, participants: room.participants.map(participant => (Object.assign(Object.assign({}, participant), { get user() {
|
|
12814
|
+
var _a;
|
|
12815
|
+
const user = (_a = pullFromCache(['user', 'get', participant.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12816
|
+
return user ? userLinkedObject(user) : user;
|
|
12817
|
+
} }))), getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
|
|
12801
12818
|
type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
|
|
12802
12819
|
targetType: 'room',
|
|
12803
12820
|
targetId: room.roomId,
|
|
12804
12821
|
userIds: [userId],
|
|
12805
|
-
}), getInvitations: (params, callback) => getInvitations(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
|
|
12822
|
+
}), getInvitations: (params, callback) => getInvitations$1(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
|
|
12806
12823
|
const { data } = await getInvitation({
|
|
12807
12824
|
targetId: room.roomId,
|
|
12808
12825
|
targetType: 'room',
|
|
@@ -13801,7 +13818,7 @@ const communityLinkedObject = (community) => {
|
|
|
13801
13818
|
userIds,
|
|
13802
13819
|
});
|
|
13803
13820
|
}, getMemberInvitations: (params, callback) => {
|
|
13804
|
-
return getInvitations(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
|
|
13821
|
+
return getInvitations$1(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
|
|
13805
13822
|
}, getInvitation: async () => {
|
|
13806
13823
|
const { data } = await getInvitation({
|
|
13807
13824
|
targetType: 'community',
|
|
@@ -13823,18 +13840,6 @@ const eventLinkedObject = (event) => {
|
|
|
13823
13840
|
return;
|
|
13824
13841
|
return userLinkedObject(cacheData.data);
|
|
13825
13842
|
},
|
|
13826
|
-
get discussionCommunity() {
|
|
13827
|
-
if (!event.discussionCommunityId)
|
|
13828
|
-
return;
|
|
13829
|
-
const cacheData = pullFromCache([
|
|
13830
|
-
'discussionCommunity',
|
|
13831
|
-
'get',
|
|
13832
|
-
event.discussionCommunityId,
|
|
13833
|
-
]);
|
|
13834
|
-
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13835
|
-
return;
|
|
13836
|
-
return communityLinkedObject(cacheData.data);
|
|
13837
|
-
},
|
|
13838
13843
|
get targetCommunity() {
|
|
13839
13844
|
if (!event.originId)
|
|
13840
13845
|
return;
|
|
@@ -13851,13 +13856,22 @@ const eventLinkedObject = (event) => {
|
|
|
13851
13856
|
return;
|
|
13852
13857
|
return cacheData.data;
|
|
13853
13858
|
},
|
|
13854
|
-
get
|
|
13855
|
-
if (!event.
|
|
13859
|
+
get post() {
|
|
13860
|
+
if (!event.postId)
|
|
13856
13861
|
return;
|
|
13857
|
-
const cacheData = pullFromCache(['
|
|
13862
|
+
const cacheData = pullFromCache(['post', 'get', event.postId]);
|
|
13858
13863
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13859
13864
|
return;
|
|
13860
|
-
return cacheData.data;
|
|
13865
|
+
return postLinkedObject(cacheData.data);
|
|
13866
|
+
},
|
|
13867
|
+
get room() {
|
|
13868
|
+
var _a;
|
|
13869
|
+
if (!event.postId)
|
|
13870
|
+
return;
|
|
13871
|
+
const cacheData = (_a = queryCache(['room', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(room => room.data.referenceId === event.postId);
|
|
13872
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length) || !cacheData[0].data)
|
|
13873
|
+
return;
|
|
13874
|
+
return roomLinkedObject(cacheData[0].data);
|
|
13861
13875
|
} });
|
|
13862
13876
|
};
|
|
13863
13877
|
|
|
@@ -14871,9 +14885,9 @@ var AmityUserSearchMatchType;
|
|
|
14871
14885
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
14872
14886
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
14873
14887
|
|
|
14874
|
-
var index$
|
|
14888
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
14875
14889
|
__proto__: null,
|
|
14876
|
-
Relationship: index$
|
|
14890
|
+
Relationship: index$q,
|
|
14877
14891
|
getUserByIds: getUserByIds,
|
|
14878
14892
|
updateUser: updateUser,
|
|
14879
14893
|
flagUser: flagUser,
|
|
@@ -15276,7 +15290,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
15276
15290
|
};
|
|
15277
15291
|
/* end_public_function */
|
|
15278
15292
|
|
|
15279
|
-
var index$
|
|
15293
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
15280
15294
|
__proto__: null,
|
|
15281
15295
|
getFile: getFile,
|
|
15282
15296
|
uploadFile: uploadFile,
|
|
@@ -17088,7 +17102,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
17088
17102
|
};
|
|
17089
17103
|
/* end_public_function */
|
|
17090
17104
|
|
|
17091
|
-
var index$
|
|
17105
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
17092
17106
|
__proto__: null,
|
|
17093
17107
|
addReaction: addReaction,
|
|
17094
17108
|
removeReaction: removeReaction,
|
|
@@ -18860,7 +18874,7 @@ const getMessages = (params, callback, config) => {
|
|
|
18860
18874
|
};
|
|
18861
18875
|
/* end_public_function */
|
|
18862
18876
|
|
|
18863
|
-
var index$
|
|
18877
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
18864
18878
|
__proto__: null,
|
|
18865
18879
|
createMessage: createMessage,
|
|
18866
18880
|
updateMessage: updateMessage,
|
|
@@ -19386,7 +19400,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
19386
19400
|
};
|
|
19387
19401
|
/* end_public_function */
|
|
19388
19402
|
|
|
19389
|
-
var index$
|
|
19403
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
19390
19404
|
__proto__: null,
|
|
19391
19405
|
getSubChannelByIds: getSubChannels$1,
|
|
19392
19406
|
createSubChannel: createSubChannel,
|
|
@@ -20713,7 +20727,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
20713
20727
|
};
|
|
20714
20728
|
/* end_public_function */
|
|
20715
20729
|
|
|
20716
|
-
var index$
|
|
20730
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
20717
20731
|
__proto__: null,
|
|
20718
20732
|
addMembers: addMembers$1,
|
|
20719
20733
|
removeMembers: removeMembers$1,
|
|
@@ -20916,7 +20930,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
20916
20930
|
};
|
|
20917
20931
|
/* end_public_function */
|
|
20918
20932
|
|
|
20919
|
-
var index$
|
|
20933
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
20920
20934
|
__proto__: null,
|
|
20921
20935
|
addRole: addRole,
|
|
20922
20936
|
removeRole: removeRole,
|
|
@@ -20926,10 +20940,10 @@ var index$i = /*#__PURE__*/Object.freeze({
|
|
|
20926
20940
|
unmuteMembers: unmuteMembers
|
|
20927
20941
|
});
|
|
20928
20942
|
|
|
20929
|
-
var index$
|
|
20943
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
20930
20944
|
__proto__: null,
|
|
20931
|
-
Membership: index$
|
|
20932
|
-
Moderation: index$
|
|
20945
|
+
Membership: index$k,
|
|
20946
|
+
Moderation: index$j,
|
|
20933
20947
|
getChannelByIds: getChannelByIds$1,
|
|
20934
20948
|
createChannel: createChannel,
|
|
20935
20949
|
updateChannel: updateChannel,
|
|
@@ -22332,7 +22346,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
22332
22346
|
};
|
|
22333
22347
|
/* end_public_function */
|
|
22334
22348
|
|
|
22335
|
-
var index$
|
|
22349
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
22336
22350
|
__proto__: null,
|
|
22337
22351
|
addMembers: addMembers,
|
|
22338
22352
|
removeMembers: removeMembers,
|
|
@@ -23583,7 +23597,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
23583
23597
|
};
|
|
23584
23598
|
/* end_public_function */
|
|
23585
23599
|
|
|
23586
|
-
var index$
|
|
23600
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
23587
23601
|
__proto__: null,
|
|
23588
23602
|
addRoles: addRoles,
|
|
23589
23603
|
removeRoles: removeRoles,
|
|
@@ -23591,10 +23605,10 @@ var index$f = /*#__PURE__*/Object.freeze({
|
|
|
23591
23605
|
unbanMembers: unbanMembers
|
|
23592
23606
|
});
|
|
23593
23607
|
|
|
23594
|
-
var index$
|
|
23608
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
23595
23609
|
__proto__: null,
|
|
23596
|
-
Moderation: index$
|
|
23597
|
-
Membership: index$
|
|
23610
|
+
Moderation: index$g,
|
|
23611
|
+
Membership: index$h,
|
|
23598
23612
|
getCommunityByIds: getCommunities$1,
|
|
23599
23613
|
createCommunity: createCommunity,
|
|
23600
23614
|
updateCommunity: updateCommunity,
|
|
@@ -23828,7 +23842,7 @@ const getCategories = (params, callback, config) => {
|
|
|
23828
23842
|
};
|
|
23829
23843
|
/* end_public_function */
|
|
23830
23844
|
|
|
23831
|
-
var index$
|
|
23845
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
23832
23846
|
__proto__: null,
|
|
23833
23847
|
getCategory: getCategory,
|
|
23834
23848
|
getCategories: getCategories
|
|
@@ -24887,7 +24901,7 @@ const getComments = (params, callback, config) => {
|
|
|
24887
24901
|
};
|
|
24888
24902
|
/* end_public_function */
|
|
24889
24903
|
|
|
24890
|
-
var index$
|
|
24904
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
24891
24905
|
__proto__: null,
|
|
24892
24906
|
getCommentByIds: getCommentByIds,
|
|
24893
24907
|
createComment: createComment,
|
|
@@ -25558,7 +25572,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
25558
25572
|
};
|
|
25559
25573
|
/* end_public_function */
|
|
25560
25574
|
|
|
25561
|
-
var index$
|
|
25575
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
25562
25576
|
__proto__: null,
|
|
25563
25577
|
queryGlobalFeed: queryGlobalFeed,
|
|
25564
25578
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -27239,7 +27253,7 @@ const searchPostsByHashtag = (params, callback, config) => {
|
|
|
27239
27253
|
};
|
|
27240
27254
|
/* end_public_function */
|
|
27241
27255
|
|
|
27242
|
-
var index$
|
|
27256
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
27243
27257
|
__proto__: null,
|
|
27244
27258
|
getPostByIds: getPostByIds,
|
|
27245
27259
|
createPost: createPost,
|
|
@@ -27847,7 +27861,7 @@ const getStreams = (params, callback, config) => {
|
|
|
27847
27861
|
};
|
|
27848
27862
|
};
|
|
27849
27863
|
|
|
27850
|
-
var index$
|
|
27864
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
27851
27865
|
__proto__: null,
|
|
27852
27866
|
createStream: createStream,
|
|
27853
27867
|
updateStream: updateStream,
|
|
@@ -28062,9 +28076,7 @@ const getRecordedUrl = async (roomId) => {
|
|
|
28062
28076
|
const removeParticipant = async (roomId, participantUserId) => {
|
|
28063
28077
|
const client = getActiveClient();
|
|
28064
28078
|
client.log('room/removeParticipant', { roomId, participantUserId });
|
|
28065
|
-
await client.http.delete(`/api/v1/rooms/${roomId}/participants
|
|
28066
|
-
data: { participantUserId },
|
|
28067
|
-
});
|
|
28079
|
+
await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
|
|
28068
28080
|
fireEvent('local.room.participantRemoved', {
|
|
28069
28081
|
rooms: [{ _id: roomId }],
|
|
28070
28082
|
users: [{ _id: participantUserId }],
|
|
@@ -28220,6 +28232,46 @@ const onRoomCoHostInvited = (callback) => {
|
|
|
28220
28232
|
return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
|
|
28221
28233
|
};
|
|
28222
28234
|
|
|
28235
|
+
const getRoomById = async (roomId) => {
|
|
28236
|
+
const client = getActiveClient();
|
|
28237
|
+
client.log('room/getRoomById', roomId);
|
|
28238
|
+
// Check if room is in tombstone
|
|
28239
|
+
isInTombstone('room', roomId);
|
|
28240
|
+
let data;
|
|
28241
|
+
try {
|
|
28242
|
+
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
28243
|
+
data = response.data;
|
|
28244
|
+
}
|
|
28245
|
+
catch (error) {
|
|
28246
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
28247
|
+
pushToTombstone('room', roomId);
|
|
28248
|
+
}
|
|
28249
|
+
throw error;
|
|
28250
|
+
}
|
|
28251
|
+
const cachedAt = client.cache && Date.now();
|
|
28252
|
+
if (client.cache) {
|
|
28253
|
+
ingestInCache(data, { cachedAt });
|
|
28254
|
+
}
|
|
28255
|
+
return {
|
|
28256
|
+
data: data.rooms[0],
|
|
28257
|
+
cachedAt,
|
|
28258
|
+
};
|
|
28259
|
+
};
|
|
28260
|
+
getRoomById.locally = (roomId) => {
|
|
28261
|
+
const client = getActiveClient();
|
|
28262
|
+
client.log('room/getRoomById.locally', roomId);
|
|
28263
|
+
// Check if room is in tombstone
|
|
28264
|
+
isInTombstone('room', roomId);
|
|
28265
|
+
const cachedAt = client.cache && Date.now();
|
|
28266
|
+
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
28267
|
+
if (!roomCache)
|
|
28268
|
+
return;
|
|
28269
|
+
return {
|
|
28270
|
+
data: roomCache.data,
|
|
28271
|
+
cachedAt,
|
|
28272
|
+
};
|
|
28273
|
+
};
|
|
28274
|
+
|
|
28223
28275
|
/**
|
|
28224
28276
|
* ```js
|
|
28225
28277
|
* import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
|
|
@@ -28237,12 +28289,14 @@ const onRoomCoHostInvited = (callback) => {
|
|
|
28237
28289
|
*/
|
|
28238
28290
|
const onRoomCoHostInviteAccepted = (callback) => {
|
|
28239
28291
|
const client = getActiveClient();
|
|
28240
|
-
const filter = (payload) => {
|
|
28292
|
+
const filter = async (payload) => {
|
|
28293
|
+
var _a;
|
|
28241
28294
|
const data = prepareMyInvitationsPayload(payload);
|
|
28295
|
+
await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
|
|
28242
28296
|
ingestInCache(data);
|
|
28243
|
-
callback(data.invitations);
|
|
28297
|
+
callback(data.invitations[0]);
|
|
28244
28298
|
};
|
|
28245
|
-
return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.
|
|
28299
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
|
|
28246
28300
|
};
|
|
28247
28301
|
|
|
28248
28302
|
/**
|
|
@@ -28267,7 +28321,7 @@ const onRoomCoHostInviteRejected = (callback) => {
|
|
|
28267
28321
|
ingestInCache(data);
|
|
28268
28322
|
callback(data.invitations);
|
|
28269
28323
|
};
|
|
28270
|
-
return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.
|
|
28324
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
|
|
28271
28325
|
};
|
|
28272
28326
|
|
|
28273
28327
|
/**
|
|
@@ -28292,7 +28346,7 @@ const onRoomCoHostInviteCanceled = (callback) => {
|
|
|
28292
28346
|
ingestInCache(data);
|
|
28293
28347
|
callback(data.invitations);
|
|
28294
28348
|
};
|
|
28295
|
-
return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.
|
|
28349
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
|
|
28296
28350
|
};
|
|
28297
28351
|
|
|
28298
28352
|
/**
|
|
@@ -28460,7 +28514,7 @@ const onRoomParticipantRemoved = (callback) => {
|
|
|
28460
28514
|
ingestInCache(payload);
|
|
28461
28515
|
callback(payload.rooms[0]);
|
|
28462
28516
|
};
|
|
28463
|
-
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', '
|
|
28517
|
+
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
|
|
28464
28518
|
};
|
|
28465
28519
|
|
|
28466
28520
|
/**
|
|
@@ -28487,44 +28541,28 @@ const onRoomLeft = (callback) => {
|
|
|
28487
28541
|
return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
|
|
28488
28542
|
};
|
|
28489
28543
|
|
|
28490
|
-
|
|
28491
|
-
|
|
28492
|
-
|
|
28493
|
-
|
|
28494
|
-
|
|
28495
|
-
|
|
28496
|
-
|
|
28497
|
-
|
|
28498
|
-
|
|
28499
|
-
|
|
28500
|
-
|
|
28501
|
-
|
|
28502
|
-
|
|
28503
|
-
|
|
28504
|
-
|
|
28505
|
-
|
|
28506
|
-
const cachedAt = client.cache && Date.now();
|
|
28507
|
-
if (client.cache) {
|
|
28508
|
-
ingestInCache(data, { cachedAt });
|
|
28509
|
-
}
|
|
28510
|
-
return {
|
|
28511
|
-
data: data.rooms[0],
|
|
28512
|
-
cachedAt,
|
|
28513
|
-
};
|
|
28514
|
-
};
|
|
28515
|
-
getRoomById.locally = (roomId) => {
|
|
28544
|
+
/**
|
|
28545
|
+
* ```js
|
|
28546
|
+
* import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
|
|
28547
|
+
* const dispose = onRoomParticipantRemoved(room => {
|
|
28548
|
+
* // ...
|
|
28549
|
+
* })
|
|
28550
|
+
* ```
|
|
28551
|
+
*
|
|
28552
|
+
* Fired when a participant has been removed from a {@link Amity.Room} locally
|
|
28553
|
+
*
|
|
28554
|
+
* @param callback The function to call when the event was fired
|
|
28555
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28556
|
+
*
|
|
28557
|
+
* @category Room Events
|
|
28558
|
+
*/
|
|
28559
|
+
const onRoomParticipantRemovedLocal = (callback) => {
|
|
28516
28560
|
const client = getActiveClient();
|
|
28517
|
-
|
|
28518
|
-
|
|
28519
|
-
|
|
28520
|
-
const cachedAt = client.cache && Date.now();
|
|
28521
|
-
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
28522
|
-
if (!roomCache)
|
|
28523
|
-
return;
|
|
28524
|
-
return {
|
|
28525
|
-
data: roomCache.data,
|
|
28526
|
-
cachedAt,
|
|
28561
|
+
const filter = (payload) => {
|
|
28562
|
+
ingestInCache(payload);
|
|
28563
|
+
callback(payload.rooms[0]);
|
|
28527
28564
|
};
|
|
28565
|
+
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
|
|
28528
28566
|
};
|
|
28529
28567
|
|
|
28530
28568
|
const getRoom = (roomId, callback) => {
|
|
@@ -28534,7 +28572,11 @@ const getRoom = (roomId, callback) => {
|
|
|
28534
28572
|
onRoomStartBroadcasting,
|
|
28535
28573
|
onRoomWaitingReconnect,
|
|
28536
28574
|
onRoomRecordedAvailable,
|
|
28537
|
-
|
|
28575
|
+
onRoomParticipantJoined,
|
|
28576
|
+
onRoomParticipantLeft,
|
|
28577
|
+
onRoomParticipantRemoved,
|
|
28578
|
+
onRoomParticipantRemovedLocal,
|
|
28579
|
+
convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
|
|
28538
28580
|
], {
|
|
28539
28581
|
callbackDataSelector: (data) => {
|
|
28540
28582
|
if (!data)
|
|
@@ -28754,7 +28796,7 @@ const getRooms = (params, callback, config) => {
|
|
|
28754
28796
|
};
|
|
28755
28797
|
/* end_public_function */
|
|
28756
28798
|
|
|
28757
|
-
var index$
|
|
28799
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
28758
28800
|
__proto__: null,
|
|
28759
28801
|
createRoom: createRoom,
|
|
28760
28802
|
updateRoom: updateRoom,
|
|
@@ -28784,6 +28826,300 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
28784
28826
|
getRooms: getRooms
|
|
28785
28827
|
});
|
|
28786
28828
|
|
|
28829
|
+
/* begin_public_function
|
|
28830
|
+
id: roomPresence.getRoomOnlineUsers
|
|
28831
|
+
*/
|
|
28832
|
+
/**
|
|
28833
|
+
* ```js
|
|
28834
|
+
* import { getRoomOnlineUsers } from '@amityco/ts-sdk'
|
|
28835
|
+
* const result = await getRoomOnlineUsers('roomId')
|
|
28836
|
+
* ```
|
|
28837
|
+
*
|
|
28838
|
+
* Retrieves the list of users currently online in a specific room.
|
|
28839
|
+
* This function fetches all users who are actively watching or present in the room,
|
|
28840
|
+
* handling pagination automatically for large numbers of users.
|
|
28841
|
+
*
|
|
28842
|
+
* @param roomId The ID of the room to get online users for
|
|
28843
|
+
* @returns Promise that resolves with a cached list of online users
|
|
28844
|
+
*
|
|
28845
|
+
* @category Room Presence API
|
|
28846
|
+
* @async
|
|
28847
|
+
*/
|
|
28848
|
+
const getRoomOnlineUsers = async (roomId) => {
|
|
28849
|
+
var _a, _b, _c;
|
|
28850
|
+
const client = getActiveClient();
|
|
28851
|
+
client.log('room/getWatchingUsers', { roomId });
|
|
28852
|
+
const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users`);
|
|
28853
|
+
const viewerIds = (_a = data === null || data === void 0 ? void 0 : data.viewers.map(viewer => viewer.userId)) !== null && _a !== void 0 ? _a : [];
|
|
28854
|
+
// getUserByIds has a maximum limit of 100 users per call
|
|
28855
|
+
// Split into chunks of 100 if we have more than 100 users
|
|
28856
|
+
const BATCH_SIZE = 100;
|
|
28857
|
+
const batches = [];
|
|
28858
|
+
for (let i = 0; i < viewerIds.length; i += BATCH_SIZE) {
|
|
28859
|
+
batches.push(viewerIds.slice(i, i + BATCH_SIZE));
|
|
28860
|
+
}
|
|
28861
|
+
// Fetch all batches in parallel
|
|
28862
|
+
const batchResults = await Promise.all(batches.map(batch => getUserByIds(batch)));
|
|
28863
|
+
// Merge all results
|
|
28864
|
+
const allViewers = [];
|
|
28865
|
+
batchResults.forEach(result => {
|
|
28866
|
+
if (result.data) {
|
|
28867
|
+
allViewers.push(...result.data);
|
|
28868
|
+
}
|
|
28869
|
+
});
|
|
28870
|
+
// Return in the same format as getUserByIds
|
|
28871
|
+
return {
|
|
28872
|
+
data: allViewers,
|
|
28873
|
+
cachedAt: (_c = (_b = batchResults[0]) === null || _b === void 0 ? void 0 : _b.cachedAt) !== null && _c !== void 0 ? _c : Date.now(),
|
|
28874
|
+
};
|
|
28875
|
+
};
|
|
28876
|
+
/* end_public_function */
|
|
28877
|
+
|
|
28878
|
+
/* begin_public_function
|
|
28879
|
+
id: roomPresence.getRoomUserCount
|
|
28880
|
+
*/
|
|
28881
|
+
/**
|
|
28882
|
+
* ```js
|
|
28883
|
+
* import { getRoomUserCount } from '@amityco/ts-sdk'
|
|
28884
|
+
* const count = await getRoomUserCount('roomId')
|
|
28885
|
+
* ```
|
|
28886
|
+
*
|
|
28887
|
+
* Retrieves the count of users currently watching or present in a specific room.
|
|
28888
|
+
* This function returns the total number of online users without fetching their full user data.
|
|
28889
|
+
*
|
|
28890
|
+
* @param roomId The ID of the room to get the user count for
|
|
28891
|
+
* @returns Promise that resolves with the room watching count data
|
|
28892
|
+
*
|
|
28893
|
+
* @category Room Presence API
|
|
28894
|
+
* @async
|
|
28895
|
+
*/
|
|
28896
|
+
const getRoomUserCount = async (roomId) => {
|
|
28897
|
+
const client = getActiveClient();
|
|
28898
|
+
client.log('roomPresence/getRoomUserCount', { roomId });
|
|
28899
|
+
const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
|
|
28900
|
+
pushToCache(['get', 'watchingCount', roomId], data);
|
|
28901
|
+
fireEvent('local.room.watchingCountUpdated', data);
|
|
28902
|
+
return data;
|
|
28903
|
+
};
|
|
28904
|
+
/* end_public_function */
|
|
28905
|
+
|
|
28906
|
+
const getPresenceSetting = async () => {
|
|
28907
|
+
const client = getActiveClient();
|
|
28908
|
+
client.log('presence/getPresenceSetting');
|
|
28909
|
+
const { data } = await client.http.get('/api/v1/presence/settings');
|
|
28910
|
+
pushToCache(['get', 'presenceSetting'], data);
|
|
28911
|
+
return data;
|
|
28912
|
+
};
|
|
28913
|
+
|
|
28914
|
+
class RoomPresenceSyncEngine {
|
|
28915
|
+
constructor(roomId) {
|
|
28916
|
+
this.isEnabled = false;
|
|
28917
|
+
this.config = {
|
|
28918
|
+
heartbeatInterval: 30 * SECOND$1,
|
|
28919
|
+
};
|
|
28920
|
+
this.roomId = roomId;
|
|
28921
|
+
// Initialize config asynchronously - don't await in constructor
|
|
28922
|
+
this.initializeConfig().catch(error => {
|
|
28923
|
+
console.error('Failed to initialize RoomPresenceSyncEngine config in constructor:', error);
|
|
28924
|
+
});
|
|
28925
|
+
}
|
|
28926
|
+
async initializeConfig() {
|
|
28927
|
+
try {
|
|
28928
|
+
// Get presence settings from API with retry logic
|
|
28929
|
+
const presenceSettings = await RoomPresenceSyncEngine.getPresenceSettingWithRetry();
|
|
28930
|
+
if (presenceSettings) {
|
|
28931
|
+
// Set intervals from network settings (convert from minutes to milliseconds)
|
|
28932
|
+
this.config = {
|
|
28933
|
+
heartbeatInterval: (presenceSettings.network.heartbeatInterval || 5) * 60 * 1000,
|
|
28934
|
+
};
|
|
28935
|
+
}
|
|
28936
|
+
else {
|
|
28937
|
+
// Use default intervals if all retries failed
|
|
28938
|
+
this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
|
|
28939
|
+
}
|
|
28940
|
+
}
|
|
28941
|
+
catch (error) {
|
|
28942
|
+
console.error('Failed to initialize RoomPresenceSyncEngine config:', error);
|
|
28943
|
+
// Use default intervals if settings fetch fails
|
|
28944
|
+
this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
|
|
28945
|
+
}
|
|
28946
|
+
}
|
|
28947
|
+
static async getPresenceSettingWithRetry(maxRetries = 5) {
|
|
28948
|
+
for (let attempt = 0; attempt < maxRetries; attempt += 1) {
|
|
28949
|
+
try {
|
|
28950
|
+
// eslint-disable-next-line no-await-in-loop
|
|
28951
|
+
const presenceSettings = await getPresenceSetting();
|
|
28952
|
+
return presenceSettings;
|
|
28953
|
+
}
|
|
28954
|
+
catch (error) {
|
|
28955
|
+
if (attempt >= maxRetries - 1) {
|
|
28956
|
+
console.error(`Failed to get presence setting after ${maxRetries} attempts:`, error);
|
|
28957
|
+
return null;
|
|
28958
|
+
}
|
|
28959
|
+
// Calculate delay: 20 seconds + random jitter (0-5 seconds)
|
|
28960
|
+
const jitter = Math.random() * 5000; // 0-5 seconds in milliseconds
|
|
28961
|
+
const delay = 20000 + jitter; // 20 seconds + jitter
|
|
28962
|
+
console.warn(`Failed to get presence setting (attempt ${attempt + 1}/${maxRetries}), retrying in ${Math.round(delay / 1000)}s:`, error);
|
|
28963
|
+
// Wait before retry
|
|
28964
|
+
// eslint-disable-next-line no-await-in-loop
|
|
28965
|
+
await new Promise(resolve => {
|
|
28966
|
+
setTimeout(resolve, delay);
|
|
28967
|
+
});
|
|
28968
|
+
}
|
|
28969
|
+
}
|
|
28970
|
+
return null;
|
|
28971
|
+
}
|
|
28972
|
+
/**
|
|
28973
|
+
* Start heartbeat for the room
|
|
28974
|
+
*/
|
|
28975
|
+
start() {
|
|
28976
|
+
if (this.isEnabled)
|
|
28977
|
+
return;
|
|
28978
|
+
this.isEnabled = true;
|
|
28979
|
+
// Send immediate heartbeat
|
|
28980
|
+
this.sendHeartbeat();
|
|
28981
|
+
// Start heartbeat timer
|
|
28982
|
+
this.heartbeatTimer = setInterval(() => {
|
|
28983
|
+
this.sendHeartbeat();
|
|
28984
|
+
}, this.config.heartbeatInterval);
|
|
28985
|
+
}
|
|
28986
|
+
/**
|
|
28987
|
+
* Stop heartbeat for the room
|
|
28988
|
+
*/
|
|
28989
|
+
stop() {
|
|
28990
|
+
this.isEnabled = false;
|
|
28991
|
+
// Stop heartbeat timer
|
|
28992
|
+
if (this.heartbeatTimer) {
|
|
28993
|
+
clearInterval(this.heartbeatTimer);
|
|
28994
|
+
this.heartbeatTimer = undefined;
|
|
28995
|
+
}
|
|
28996
|
+
}
|
|
28997
|
+
/**
|
|
28998
|
+
* Send heartbeat to the room
|
|
28999
|
+
*/
|
|
29000
|
+
async sendHeartbeat() {
|
|
29001
|
+
try {
|
|
29002
|
+
const client = getActiveClient();
|
|
29003
|
+
await client.http.post(`/api/v1/presence/rooms/${this.roomId}/heartbeat`);
|
|
29004
|
+
}
|
|
29005
|
+
catch (error) {
|
|
29006
|
+
console.error(`Heartbeat failed for room ${this.roomId}:`, error);
|
|
29007
|
+
}
|
|
29008
|
+
}
|
|
29009
|
+
/**
|
|
29010
|
+
* Get the room ID
|
|
29011
|
+
*/
|
|
29012
|
+
getRoomId() {
|
|
29013
|
+
return this.roomId;
|
|
29014
|
+
}
|
|
29015
|
+
/**
|
|
29016
|
+
* Check if the engine is enabled
|
|
29017
|
+
*/
|
|
29018
|
+
isActive() {
|
|
29019
|
+
return this.isEnabled;
|
|
29020
|
+
}
|
|
29021
|
+
/**
|
|
29022
|
+
* Cleanup method to stop all timers and release resources
|
|
29023
|
+
* Call this when the engine instance is no longer needed
|
|
29024
|
+
*/
|
|
29025
|
+
destroy() {
|
|
29026
|
+
// Stop the engine
|
|
29027
|
+
this.stop();
|
|
29028
|
+
}
|
|
29029
|
+
// Session Management
|
|
29030
|
+
onSessionDestroyed() {
|
|
29031
|
+
// Stop all timers when session is destroyed and cleanup
|
|
29032
|
+
this.destroy();
|
|
29033
|
+
}
|
|
29034
|
+
onTokenExpired() {
|
|
29035
|
+
// Stop engine when token expires
|
|
29036
|
+
this.stop();
|
|
29037
|
+
}
|
|
29038
|
+
}
|
|
29039
|
+
|
|
29040
|
+
// Map to store engine instances per roomId
|
|
29041
|
+
const engineInstances = new Map();
|
|
29042
|
+
/**
|
|
29043
|
+
* Get or create a RoomPresenceSyncEngine instance for a specific room
|
|
29044
|
+
*
|
|
29045
|
+
* @param roomId The room ID to get/create engine for
|
|
29046
|
+
* @returns RoomPresenceSyncEngine instance for the room
|
|
29047
|
+
*/
|
|
29048
|
+
const getRoomPresenceSyncEngine = (roomId) => {
|
|
29049
|
+
let engine = engineInstances.get(roomId);
|
|
29050
|
+
if (!engine) {
|
|
29051
|
+
engine = new RoomPresenceSyncEngine(roomId);
|
|
29052
|
+
engineInstances.set(roomId, engine);
|
|
29053
|
+
}
|
|
29054
|
+
return engine;
|
|
29055
|
+
};
|
|
29056
|
+
/**
|
|
29057
|
+
* Destroy the engine instance for a specific room
|
|
29058
|
+
*
|
|
29059
|
+
* @param roomId The room ID to destroy engine for
|
|
29060
|
+
*/
|
|
29061
|
+
const destroyRoomPresenceSyncEngine = (roomId) => {
|
|
29062
|
+
const engine = engineInstances.get(roomId);
|
|
29063
|
+
if (engine) {
|
|
29064
|
+
engine.destroy();
|
|
29065
|
+
engineInstances.delete(roomId);
|
|
29066
|
+
}
|
|
29067
|
+
};
|
|
29068
|
+
|
|
29069
|
+
/* begin_public_function
|
|
29070
|
+
id: roomPresence.startHeartbeat
|
|
29071
|
+
*/
|
|
29072
|
+
/**
|
|
29073
|
+
* ```js
|
|
29074
|
+
* import { startHeartbeat } from '@amityco/ts-sdk'
|
|
29075
|
+
* startHeartbeat('roomId')
|
|
29076
|
+
* ```
|
|
29077
|
+
*
|
|
29078
|
+
* Starts sending heartbeat signals for a specific room to maintain presence status.
|
|
29079
|
+
* This enables the room presence tracking and notifies the server that the user is actively viewing the room.
|
|
29080
|
+
*
|
|
29081
|
+
* @param roomId The ID of the room to start heartbeat for
|
|
29082
|
+
*
|
|
29083
|
+
* @category Room Presence API
|
|
29084
|
+
*/
|
|
29085
|
+
const startHeartbeat = (roomId) => {
|
|
29086
|
+
const engine = getRoomPresenceSyncEngine(roomId);
|
|
29087
|
+
engine.start();
|
|
29088
|
+
};
|
|
29089
|
+
/* end_public_function */
|
|
29090
|
+
|
|
29091
|
+
/* begin_public_function
|
|
29092
|
+
id: roomPresence.stopHeartbeat
|
|
29093
|
+
*/
|
|
29094
|
+
/**
|
|
29095
|
+
* ```js
|
|
29096
|
+
* import { stopHeartbeat } from '@amityco/ts-sdk'
|
|
29097
|
+
* stopHeartbeat('roomId')
|
|
29098
|
+
* ```
|
|
29099
|
+
*
|
|
29100
|
+
* Stops sending heartbeat signals for a specific room.
|
|
29101
|
+
* This disables the room presence tracking for the specified room and stops notifying the server of the user's presence.
|
|
29102
|
+
*
|
|
29103
|
+
* @param roomId The ID of the room to stop heartbeat for
|
|
29104
|
+
*
|
|
29105
|
+
* @category Room Presence API
|
|
29106
|
+
*/
|
|
29107
|
+
const stopHeartbeat = (roomId) => {
|
|
29108
|
+
const engine = getRoomPresenceSyncEngine(roomId);
|
|
29109
|
+
engine.stop();
|
|
29110
|
+
// Clean up the engine instance
|
|
29111
|
+
destroyRoomPresenceSyncEngine(roomId);
|
|
29112
|
+
};
|
|
29113
|
+
/* end_public_function */
|
|
29114
|
+
|
|
29115
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
29116
|
+
__proto__: null,
|
|
29117
|
+
getRoomOnlineUsers: getRoomOnlineUsers,
|
|
29118
|
+
getRoomUserCount: getRoomUserCount,
|
|
29119
|
+
startHeartbeat: startHeartbeat,
|
|
29120
|
+
stopHeartbeat: stopHeartbeat
|
|
29121
|
+
});
|
|
29122
|
+
|
|
28787
29123
|
/* begin_public_function
|
|
28788
29124
|
id: poll.create
|
|
28789
29125
|
*/
|
|
@@ -31111,28 +31447,6 @@ const cancelInvitation = async (invitationId) => {
|
|
|
31111
31447
|
};
|
|
31112
31448
|
/* end_public_function */
|
|
31113
31449
|
|
|
31114
|
-
/* begin_public_function
|
|
31115
|
-
id: invitation.accept
|
|
31116
|
-
*/
|
|
31117
|
-
/**
|
|
31118
|
-
* ```js
|
|
31119
|
-
* import { acceptInvitation } from '@amityco/ts-sdk'
|
|
31120
|
-
* const isAccepted = await acceptInvitation(invitationId)
|
|
31121
|
-
* ```
|
|
31122
|
-
*
|
|
31123
|
-
* Accepts a {@link Amity.Invitation} object
|
|
31124
|
-
*
|
|
31125
|
-
* @param invitationId the {@link Amity.Invitation} to accept
|
|
31126
|
-
* @returns A success boolean if the {@link Amity.Invitation} was accepted
|
|
31127
|
-
*
|
|
31128
|
-
* @category Invitation API
|
|
31129
|
-
* @async
|
|
31130
|
-
*/
|
|
31131
|
-
const acceptInvitation = async (invitationId) => {
|
|
31132
|
-
return acceptInvitation$1(invitationId);
|
|
31133
|
-
};
|
|
31134
|
-
/* end_public_function */
|
|
31135
|
-
|
|
31136
31450
|
class MyInvitationsPaginationController extends PaginationController {
|
|
31137
31451
|
async getRequest(queryParams, token) {
|
|
31138
31452
|
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
@@ -31193,7 +31507,7 @@ class MyInvitationsQueryStreamController extends QueryStreamController {
|
|
|
31193
31507
|
]),
|
|
31194
31508
|
];
|
|
31195
31509
|
}
|
|
31196
|
-
if (action === InvitationActionsEnum.
|
|
31510
|
+
if (action === InvitationActionsEnum.OnLocalInvitationCanceled) {
|
|
31197
31511
|
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
31198
31512
|
}
|
|
31199
31513
|
pushToCache(this.cacheKey, collection);
|
|
@@ -31325,13 +31639,16 @@ const getMyCommunityInvitations = (params, callback, config) => {
|
|
|
31325
31639
|
};
|
|
31326
31640
|
};
|
|
31327
31641
|
|
|
31642
|
+
/* begin_public_function
|
|
31643
|
+
id: invitation.get_invitations
|
|
31644
|
+
*/
|
|
31328
31645
|
/**
|
|
31329
31646
|
*
|
|
31330
31647
|
* ```js
|
|
31331
|
-
* import {
|
|
31648
|
+
* import { InvitationRepository } from '@amityco/ts-sdk';
|
|
31332
31649
|
*
|
|
31333
31650
|
* // For room invitations
|
|
31334
|
-
* const unsubscribe =
|
|
31651
|
+
* const unsubscribe = InvitationRepository.getInvitations(
|
|
31335
31652
|
* { targetId: 'room123', targetType: 'room' },
|
|
31336
31653
|
* response => {
|
|
31337
31654
|
* console.log('Room invitation event:', response.room, response.users, response.eventType)
|
|
@@ -31355,7 +31672,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
|
|
|
31355
31672
|
*
|
|
31356
31673
|
* @category Invitation Observable
|
|
31357
31674
|
*/
|
|
31358
|
-
const
|
|
31675
|
+
const getInvitations = (params, callback) => {
|
|
31359
31676
|
const { _id: userId } = getCurrentUser();
|
|
31360
31677
|
if (!userId)
|
|
31361
31678
|
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
@@ -31368,7 +31685,7 @@ const observeInvitations = (params, callback) => {
|
|
|
31368
31685
|
callback(data.map(LinkedObject.invitation));
|
|
31369
31686
|
};
|
|
31370
31687
|
const realtimeRouter = (data) => {
|
|
31371
|
-
const invitations = data.filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
|
|
31688
|
+
const invitations = (Array.isArray(data) ? data : [data]).filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
|
|
31372
31689
|
dispatcher(invitations);
|
|
31373
31690
|
};
|
|
31374
31691
|
// Only subscribe to room co-host events for now (since that's what we have implemented)
|
|
@@ -31380,7 +31697,7 @@ const observeInvitations = (params, callback) => {
|
|
|
31380
31697
|
disposers.push(onRoomCoHostInviteCanceled(realtimeRouter));
|
|
31381
31698
|
}
|
|
31382
31699
|
return () => {
|
|
31383
|
-
log(`
|
|
31700
|
+
log(`getInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
|
|
31384
31701
|
disposers.forEach(fn => fn());
|
|
31385
31702
|
};
|
|
31386
31703
|
};
|
|
@@ -31388,12 +31705,11 @@ const observeInvitations = (params, callback) => {
|
|
|
31388
31705
|
var index$2 = /*#__PURE__*/Object.freeze({
|
|
31389
31706
|
__proto__: null,
|
|
31390
31707
|
cancelInvitation: cancelInvitation,
|
|
31391
|
-
acceptInvitation: acceptInvitation,
|
|
31392
31708
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
31393
31709
|
onLocalInvitationUpdated: onLocalInvitationUpdated,
|
|
31394
31710
|
onLocalInvitationCanceled: onLocalInvitationCanceled,
|
|
31395
31711
|
getMyCommunityInvitations: getMyCommunityInvitations,
|
|
31396
|
-
|
|
31712
|
+
getInvitations: getInvitations
|
|
31397
31713
|
});
|
|
31398
31714
|
|
|
31399
31715
|
// TODO: confirm id
|
|
@@ -31712,9 +32028,9 @@ const deleteEvent = async (eventId) => {
|
|
|
31712
32028
|
users: [],
|
|
31713
32029
|
files: [],
|
|
31714
32030
|
communities: [],
|
|
31715
|
-
|
|
32031
|
+
posts: [],
|
|
32032
|
+
rooms: [],
|
|
31716
32033
|
events: [deletedEvent],
|
|
31717
|
-
discussionCommunities: [],
|
|
31718
32034
|
});
|
|
31719
32035
|
};
|
|
31720
32036
|
/* end_public_function */
|
|
@@ -31991,143 +32307,6 @@ const getEvents = (params, callback, config) => {
|
|
|
31991
32307
|
};
|
|
31992
32308
|
};
|
|
31993
32309
|
|
|
31994
|
-
class MyEventPaginationController extends PaginationController {
|
|
31995
|
-
async getRequest(queryParams, token) {
|
|
31996
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
31997
|
-
const options = token ? { token } : { limit };
|
|
31998
|
-
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
31999
|
-
return response;
|
|
32000
|
-
}
|
|
32001
|
-
}
|
|
32002
|
-
|
|
32003
|
-
class MyEventQueryStreamController extends QueryStreamController {
|
|
32004
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
32005
|
-
super(query, cacheKey);
|
|
32006
|
-
this.notifyChange = notifyChange;
|
|
32007
|
-
this.preparePayload = preparePayload;
|
|
32008
|
-
}
|
|
32009
|
-
async saveToMainDB(response) {
|
|
32010
|
-
const processedPayload = this.preparePayload(response);
|
|
32011
|
-
const client = getActiveClient();
|
|
32012
|
-
const cachedAt = client.cache && Date.now();
|
|
32013
|
-
if (client.cache)
|
|
32014
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
32015
|
-
}
|
|
32016
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
32017
|
-
var _a, _b;
|
|
32018
|
-
if (refresh) {
|
|
32019
|
-
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
32020
|
-
}
|
|
32021
|
-
else {
|
|
32022
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32023
|
-
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
32024
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
32025
|
-
}
|
|
32026
|
-
}
|
|
32027
|
-
reactor(action) {
|
|
32028
|
-
return (event) => {
|
|
32029
|
-
var _a;
|
|
32030
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32031
|
-
if (!collection)
|
|
32032
|
-
return;
|
|
32033
|
-
if (action === EventActionsEnum.OnEventCreated) {
|
|
32034
|
-
const client = getActiveClient();
|
|
32035
|
-
if (client.userId !== event.userId)
|
|
32036
|
-
return;
|
|
32037
|
-
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
32038
|
-
}
|
|
32039
|
-
if (action === EventActionsEnum.OnEventDeleted) {
|
|
32040
|
-
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
32041
|
-
}
|
|
32042
|
-
pushToCache(this.cacheKey, collection);
|
|
32043
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
32044
|
-
};
|
|
32045
|
-
}
|
|
32046
|
-
subscribeRTE(createSubscriber) {
|
|
32047
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
32048
|
-
}
|
|
32049
|
-
}
|
|
32050
|
-
|
|
32051
|
-
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
32052
|
-
constructor(query, callback) {
|
|
32053
|
-
const queryStreamId = hash__default["default"](query);
|
|
32054
|
-
const cacheKey = ['event', 'collection', queryStreamId];
|
|
32055
|
-
const paginationController = new MyEventPaginationController(query);
|
|
32056
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
32057
|
-
this.query = query;
|
|
32058
|
-
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
32059
|
-
this.callback = callback.bind(this);
|
|
32060
|
-
this.loadPage({ initial: true });
|
|
32061
|
-
}
|
|
32062
|
-
setup() {
|
|
32063
|
-
var _a;
|
|
32064
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32065
|
-
if (!collection)
|
|
32066
|
-
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
32067
|
-
}
|
|
32068
|
-
async persistModel(queryPayload) {
|
|
32069
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
32070
|
-
}
|
|
32071
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
32072
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
32073
|
-
}
|
|
32074
|
-
startSubscription() {
|
|
32075
|
-
return this.queryStreamController.subscribeRTE([
|
|
32076
|
-
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
32077
|
-
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
32078
|
-
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
32079
|
-
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
32080
|
-
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
32081
|
-
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
32082
|
-
]);
|
|
32083
|
-
}
|
|
32084
|
-
notifyChange({ origin, loading, error }) {
|
|
32085
|
-
var _a, _b;
|
|
32086
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32087
|
-
if (!collection)
|
|
32088
|
-
return;
|
|
32089
|
-
const data = ((_b = collection.data
|
|
32090
|
-
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
32091
|
-
.filter(isNonNullable)
|
|
32092
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
32093
|
-
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
32094
|
-
return;
|
|
32095
|
-
this.callback({
|
|
32096
|
-
data,
|
|
32097
|
-
error,
|
|
32098
|
-
loading,
|
|
32099
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
32100
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
32101
|
-
});
|
|
32102
|
-
}
|
|
32103
|
-
}
|
|
32104
|
-
|
|
32105
|
-
/**
|
|
32106
|
-
* Get my events
|
|
32107
|
-
*
|
|
32108
|
-
* @param params the query parameters
|
|
32109
|
-
* @param callback the callback to be called when the events are updated
|
|
32110
|
-
* @returns events
|
|
32111
|
-
*
|
|
32112
|
-
* @category Event Live Collection
|
|
32113
|
-
*
|
|
32114
|
-
*/
|
|
32115
|
-
const getMyEvents = (params, callback, config) => {
|
|
32116
|
-
const { log, cache } = getActiveClient();
|
|
32117
|
-
if (!cache)
|
|
32118
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
32119
|
-
const timestamp = Date.now();
|
|
32120
|
-
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
32121
|
-
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
32122
|
-
const disposers = myEventLiveCollection.startSubscription();
|
|
32123
|
-
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
32124
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
32125
|
-
return () => {
|
|
32126
|
-
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
32127
|
-
disposers.forEach(fn => fn());
|
|
32128
|
-
};
|
|
32129
|
-
};
|
|
32130
|
-
|
|
32131
32310
|
var index = /*#__PURE__*/Object.freeze({
|
|
32132
32311
|
__proto__: null,
|
|
32133
32312
|
createEvent: createEvent,
|
|
@@ -32140,41 +32319,41 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
32140
32319
|
onLocalEventUpdated: onLocalEventUpdated,
|
|
32141
32320
|
onLocalEventDeleted: onLocalEventDeleted,
|
|
32142
32321
|
getEvent: getEvent,
|
|
32143
|
-
getEvents: getEvents
|
|
32144
|
-
getMyEvents: getMyEvents
|
|
32322
|
+
getEvents: getEvents
|
|
32145
32323
|
});
|
|
32146
32324
|
|
|
32147
32325
|
exports.API_REGIONS = API_REGIONS;
|
|
32148
32326
|
exports.AdRepository = index$4;
|
|
32149
|
-
exports.CategoryRepository = index$
|
|
32150
|
-
exports.ChannelRepository = index$
|
|
32151
|
-
exports.Client = index$
|
|
32152
|
-
exports.CommentRepository = index$
|
|
32327
|
+
exports.CategoryRepository = index$e;
|
|
32328
|
+
exports.ChannelRepository = index$i;
|
|
32329
|
+
exports.Client = index$r;
|
|
32330
|
+
exports.CommentRepository = index$d;
|
|
32153
32331
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
32154
32332
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
32155
|
-
exports.CommunityRepository = index$
|
|
32333
|
+
exports.CommunityRepository = index$f;
|
|
32156
32334
|
exports.ContentFeedType = ContentFeedType;
|
|
32157
32335
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
32158
32336
|
exports.EventRepository = index;
|
|
32159
|
-
exports.FeedRepository = index$
|
|
32160
|
-
exports.FileRepository = index$
|
|
32337
|
+
exports.FeedRepository = index$c;
|
|
32338
|
+
exports.FileRepository = index$o;
|
|
32161
32339
|
exports.FileType = FileType;
|
|
32162
32340
|
exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
|
|
32163
32341
|
exports.InvitationRepository = index$2;
|
|
32164
32342
|
exports.LiveReactionRepository = index$1;
|
|
32165
32343
|
exports.LiveStreamPlayer = index$6;
|
|
32166
32344
|
exports.MessageContentType = MessageContentType;
|
|
32167
|
-
exports.MessageRepository = index$
|
|
32345
|
+
exports.MessageRepository = index$m;
|
|
32168
32346
|
exports.PollRepository = index$7;
|
|
32169
32347
|
exports.PostContentType = PostContentType;
|
|
32170
|
-
exports.PostRepository = index$
|
|
32348
|
+
exports.PostRepository = index$b;
|
|
32171
32349
|
exports.PostStructureType = PostStructureType;
|
|
32172
|
-
exports.ReactionRepository = index$
|
|
32173
|
-
exports.
|
|
32350
|
+
exports.ReactionRepository = index$n;
|
|
32351
|
+
exports.RoomPresenceRepository = index$8;
|
|
32352
|
+
exports.RoomRepository = index$9;
|
|
32174
32353
|
exports.StoryRepository = index$5;
|
|
32175
|
-
exports.StreamRepository = index$
|
|
32176
|
-
exports.SubChannelRepository = index$
|
|
32177
|
-
exports.UserRepository = index$
|
|
32354
|
+
exports.StreamRepository = index$a;
|
|
32355
|
+
exports.SubChannelRepository = index$l;
|
|
32356
|
+
exports.UserRepository = index$p;
|
|
32178
32357
|
exports.VERSION = VERSION;
|
|
32179
32358
|
exports.VideoResolution = VideoResolution;
|
|
32180
32359
|
exports.VideoSize = VideoSize;
|