@amityco/ts-sdk 7.11.1-4c0bf09.0 → 7.11.1-57ff288.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +1 -0
- 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 +1 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +1 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +1 -1
- package/dist/@types/domains/event.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +2 -1
- package/dist/@types/domains/notification.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +10 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/room.d.ts +9 -5
- package/dist/@types/domains/room.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/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/utils/setBotClientToken.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/eventRepository/internalApi/updateRSVP.d.ts.map +1 -1
- package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -1
- package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -1
- package/dist/index.cjs.js +554 -500
- package/dist/index.esm.js +356 -302
- package/dist/index.umd.js +2 -2
- 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/CommunityLiveRoomPostQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostQueryStreamController.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/getRoomUserCount.d.ts.map +1 -1
- package/dist/roomRepository/events/index.d.ts +1 -0
- package/dist/roomRepository/events/index.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomTerminated.d.ts +17 -0
- package/dist/roomRepository/events/onRoomTerminated.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
- package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -673,7 +673,7 @@ const idResolvers = {
|
|
|
673
673
|
room: ({ roomId }) => roomId,
|
|
674
674
|
viewer: ({ userId }) => userId,
|
|
675
675
|
event: ({ eventId }) => eventId,
|
|
676
|
-
eventResponse: ({
|
|
676
|
+
eventResponse: ({ userId }) => userId,
|
|
677
677
|
};
|
|
678
678
|
/**
|
|
679
679
|
* Retrieve the id resolver matching a domain name
|
|
@@ -1556,10 +1556,7 @@ const getCurrentUser = () => {
|
|
|
1556
1556
|
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
1557
1557
|
}
|
|
1558
1558
|
const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1559
|
-
|
|
1560
|
-
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
1561
|
-
}
|
|
1562
|
-
return userLinkedObject(cache);
|
|
1559
|
+
return cache ? userLinkedObject(cache) : null;
|
|
1563
1560
|
};
|
|
1564
1561
|
/* end_public_function */
|
|
1565
1562
|
|
|
@@ -23499,7 +23496,7 @@ const setVisitorClientToken = async (params) => {
|
|
|
23499
23496
|
const client = getActiveClient();
|
|
23500
23497
|
// begin establishing session
|
|
23501
23498
|
setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
|
|
23502
|
-
const { accessToken, users, expiresAt, issuedAt, userType } = await getVisitorToken(params);
|
|
23499
|
+
const { accessToken, users, expiresAt, issuedAt, userType, files } = await getVisitorToken(params);
|
|
23503
23500
|
// manually setup the token for http transport
|
|
23504
23501
|
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
23505
23502
|
client.http.defaults.metadata = {
|
|
@@ -23509,6 +23506,10 @@ const setVisitorClientToken = async (params) => {
|
|
|
23509
23506
|
};
|
|
23510
23507
|
client.token = { accessToken, issuedAt, expiresAt };
|
|
23511
23508
|
setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
|
|
23509
|
+
ingestInCache(prepareUserPayload({
|
|
23510
|
+
users,
|
|
23511
|
+
files,
|
|
23512
|
+
}));
|
|
23512
23513
|
return { accessToken, users, userType };
|
|
23513
23514
|
};
|
|
23514
23515
|
|
|
@@ -26086,6 +26087,9 @@ function setUploadedFileAccessType(accessType) {
|
|
|
26086
26087
|
GlobalFileAccessType$1.getInstance().setFileAccessType(accessType);
|
|
26087
26088
|
}
|
|
26088
26089
|
|
|
26090
|
+
/**
|
|
26091
|
+
* @deprecated This function will to be deprecated and use the new getLinkPreviewMetadata
|
|
26092
|
+
*/
|
|
26089
26093
|
/**
|
|
26090
26094
|
* ```js
|
|
26091
26095
|
* import { fetchLinkPreview } from '@amityco/ts-sdk'
|
|
@@ -26108,6 +26112,24 @@ const fetchLinkPreview = async (url) => {
|
|
|
26108
26112
|
return data;
|
|
26109
26113
|
};
|
|
26110
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
|
+
|
|
26111
26133
|
/**
|
|
26112
26134
|
* ```js
|
|
26113
26135
|
* import Client from '@amityco/ts-sdk'
|
|
@@ -26166,7 +26188,7 @@ const setBotClientToken = async (params) => {
|
|
|
26166
26188
|
const client = getActiveClient();
|
|
26167
26189
|
// begin establishing session
|
|
26168
26190
|
setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
|
|
26169
|
-
const { accessToken, users, expiresAt, issuedAt, userType } = await getBotToken(params);
|
|
26191
|
+
const { accessToken, users, expiresAt, issuedAt, userType, files } = await getBotToken(params);
|
|
26170
26192
|
// manually setup the token for http transport
|
|
26171
26193
|
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
26172
26194
|
client.http.defaults.metadata = {
|
|
@@ -26176,6 +26198,10 @@ const setBotClientToken = async (params) => {
|
|
|
26176
26198
|
};
|
|
26177
26199
|
client.token = { accessToken, issuedAt, expiresAt };
|
|
26178
26200
|
setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
|
|
26201
|
+
ingestInCache(prepareUserPayload({
|
|
26202
|
+
users,
|
|
26203
|
+
files,
|
|
26204
|
+
}));
|
|
26179
26205
|
return { accessToken, users, userType };
|
|
26180
26206
|
};
|
|
26181
26207
|
|
|
@@ -26633,6 +26659,7 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
26633
26659
|
enableUnreadCount: enableUnreadCount,
|
|
26634
26660
|
setUploadedFileAccessType: setUploadedFileAccessType,
|
|
26635
26661
|
fetchLinkPreview: fetchLinkPreview,
|
|
26662
|
+
getLinkPreviewMetadata: getLinkPreviewMetadata,
|
|
26636
26663
|
getSocialSettings: getSocialSettings,
|
|
26637
26664
|
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
26638
26665
|
loginAsVisitor: loginAsVisitor,
|
|
@@ -28533,12 +28560,9 @@ const rejectInvitation = async (invitationId) => {
|
|
|
28533
28560
|
};
|
|
28534
28561
|
/* end_public_function */
|
|
28535
28562
|
|
|
28536
|
-
|
|
28537
|
-
(
|
|
28538
|
-
|
|
28539
|
-
InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
|
|
28540
|
-
InvitationActionsEnum["OnLocalInvitationCanceled"] = "onLocalInvitationCanceled";
|
|
28541
|
-
})(InvitationActionsEnum || (InvitationActionsEnum = {}));
|
|
28563
|
+
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
28564
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
28565
|
+
};
|
|
28542
28566
|
|
|
28543
28567
|
const invitationLinkedObject = (invitation) => {
|
|
28544
28568
|
return Object.assign(Object.assign({}, invitation), { get user() {
|
|
@@ -28572,274 +28596,6 @@ const invitationLinkedObject = (invitation) => {
|
|
|
28572
28596
|
} });
|
|
28573
28597
|
};
|
|
28574
28598
|
|
|
28575
|
-
class InvitationsPaginationController extends PaginationController {
|
|
28576
|
-
async getRequest(queryParams, token) {
|
|
28577
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
28578
|
-
const options = token ? { token } : { limit };
|
|
28579
|
-
const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
|
|
28580
|
-
return data;
|
|
28581
|
-
}
|
|
28582
|
-
}
|
|
28583
|
-
|
|
28584
|
-
class InvitationsQueryStreamController extends QueryStreamController {
|
|
28585
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
28586
|
-
super(query, cacheKey);
|
|
28587
|
-
this.notifyChange = notifyChange;
|
|
28588
|
-
this.preparePayload = preparePayload;
|
|
28589
|
-
}
|
|
28590
|
-
async saveToMainDB(response) {
|
|
28591
|
-
const processedPayload = await this.preparePayload(response);
|
|
28592
|
-
const client = getActiveClient();
|
|
28593
|
-
const cachedAt = client.cache && Date.now();
|
|
28594
|
-
if (client.cache) {
|
|
28595
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
28596
|
-
}
|
|
28597
|
-
}
|
|
28598
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
28599
|
-
var _a, _b;
|
|
28600
|
-
if (refresh) {
|
|
28601
|
-
pushToCache(this.cacheKey, {
|
|
28602
|
-
data: response.invitations.map(getResolver('invitation')),
|
|
28603
|
-
});
|
|
28604
|
-
}
|
|
28605
|
-
else {
|
|
28606
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28607
|
-
const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28608
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
28609
|
-
...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
|
|
28610
|
-
] }));
|
|
28611
|
-
}
|
|
28612
|
-
}
|
|
28613
|
-
reactor(action) {
|
|
28614
|
-
return (invitations) => {
|
|
28615
|
-
var _a;
|
|
28616
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28617
|
-
if (!collection)
|
|
28618
|
-
return;
|
|
28619
|
-
if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
|
|
28620
|
-
const isExist = collection.data.find(id => id === invitations[0].invitationId);
|
|
28621
|
-
if (!isExist)
|
|
28622
|
-
return;
|
|
28623
|
-
}
|
|
28624
|
-
if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
|
|
28625
|
-
collection.data = [
|
|
28626
|
-
...new Set([
|
|
28627
|
-
...invitations.map(invitation => invitation.invitationId),
|
|
28628
|
-
...collection.data,
|
|
28629
|
-
]),
|
|
28630
|
-
];
|
|
28631
|
-
}
|
|
28632
|
-
if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
|
|
28633
|
-
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
28634
|
-
}
|
|
28635
|
-
pushToCache(this.cacheKey, collection);
|
|
28636
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
28637
|
-
};
|
|
28638
|
-
}
|
|
28639
|
-
subscribeRTE(createSubscriber) {
|
|
28640
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
28641
|
-
}
|
|
28642
|
-
}
|
|
28643
|
-
|
|
28644
|
-
/**
|
|
28645
|
-
* ```js
|
|
28646
|
-
* import { onLocalInvitationCreated } from '@amityco/ts-sdk'
|
|
28647
|
-
* const dispose = onLocalInvitationCreated(data => {
|
|
28648
|
-
* // ...
|
|
28649
|
-
* })
|
|
28650
|
-
* ```
|
|
28651
|
-
*
|
|
28652
|
-
* Fired when an {@link Amity.InvitationPayload} has been created
|
|
28653
|
-
*
|
|
28654
|
-
* @param callback The function to call when the event was fired
|
|
28655
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28656
|
-
*
|
|
28657
|
-
* @category Invitation Events
|
|
28658
|
-
*/
|
|
28659
|
-
const onLocalInvitationCreated = (callback) => {
|
|
28660
|
-
const client = getActiveClient();
|
|
28661
|
-
const disposers = [
|
|
28662
|
-
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
|
|
28663
|
-
];
|
|
28664
|
-
return () => {
|
|
28665
|
-
disposers.forEach(fn => fn());
|
|
28666
|
-
};
|
|
28667
|
-
};
|
|
28668
|
-
|
|
28669
|
-
/**
|
|
28670
|
-
* ```js
|
|
28671
|
-
* import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
|
|
28672
|
-
* const dispose = onLocalInvitationUpdated(data => {
|
|
28673
|
-
* // ...
|
|
28674
|
-
* })
|
|
28675
|
-
* ```
|
|
28676
|
-
*
|
|
28677
|
-
* Fired when an {@link Amity.InvitationPayload} has been updated
|
|
28678
|
-
*
|
|
28679
|
-
* @param callback The function to call when the event was fired
|
|
28680
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28681
|
-
*
|
|
28682
|
-
* @category Invitation Events
|
|
28683
|
-
*/
|
|
28684
|
-
const onLocalInvitationUpdated = (callback) => {
|
|
28685
|
-
const client = getActiveClient();
|
|
28686
|
-
const disposers = [
|
|
28687
|
-
createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
|
|
28688
|
-
];
|
|
28689
|
-
return () => {
|
|
28690
|
-
disposers.forEach(fn => fn());
|
|
28691
|
-
};
|
|
28692
|
-
};
|
|
28693
|
-
|
|
28694
|
-
/**
|
|
28695
|
-
* ```js
|
|
28696
|
-
* import { onLocalInvitationCanceled } from '@amityco/ts-sdk'
|
|
28697
|
-
* const dispose = onLocalInvitationCanceled(data => {
|
|
28698
|
-
* // ...
|
|
28699
|
-
* })
|
|
28700
|
-
* ```
|
|
28701
|
-
*
|
|
28702
|
-
* Fired when an {@link Amity.InvitationPayload} has been deleted
|
|
28703
|
-
*
|
|
28704
|
-
* @param callback The function to call when the event was fired
|
|
28705
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28706
|
-
*
|
|
28707
|
-
* @category Invitation Events
|
|
28708
|
-
*/
|
|
28709
|
-
const onLocalInvitationCanceled = (callback) => {
|
|
28710
|
-
const client = getActiveClient();
|
|
28711
|
-
const disposers = [
|
|
28712
|
-
createEventSubscriber(client, 'onLocalInvitationCanceled', 'local.invitation.canceled', payload => callback(payload)),
|
|
28713
|
-
];
|
|
28714
|
-
return () => {
|
|
28715
|
-
disposers.forEach(fn => fn());
|
|
28716
|
-
};
|
|
28717
|
-
};
|
|
28718
|
-
|
|
28719
|
-
class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
28720
|
-
constructor(query, callback) {
|
|
28721
|
-
const queryStreamId = hash(query);
|
|
28722
|
-
const cacheKey = ['invitation', 'collection', queryStreamId];
|
|
28723
|
-
const paginationController = new InvitationsPaginationController(query);
|
|
28724
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
28725
|
-
this.query = query;
|
|
28726
|
-
this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
|
|
28727
|
-
this.callback = callback.bind(this);
|
|
28728
|
-
this.loadPage({ initial: true });
|
|
28729
|
-
}
|
|
28730
|
-
setup() {
|
|
28731
|
-
var _a;
|
|
28732
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28733
|
-
if (!collection) {
|
|
28734
|
-
pushToCache(this.cacheKey, {
|
|
28735
|
-
data: [],
|
|
28736
|
-
params: this.query,
|
|
28737
|
-
});
|
|
28738
|
-
}
|
|
28739
|
-
}
|
|
28740
|
-
async persistModel(queryPayload) {
|
|
28741
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
28742
|
-
}
|
|
28743
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
28744
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
28745
|
-
}
|
|
28746
|
-
startSubscription() {
|
|
28747
|
-
return this.queryStreamController.subscribeRTE([
|
|
28748
|
-
{
|
|
28749
|
-
fn: onLocalInvitationCreated,
|
|
28750
|
-
action: InvitationActionsEnum.OnLocalInvitationCreated,
|
|
28751
|
-
},
|
|
28752
|
-
{
|
|
28753
|
-
fn: onLocalInvitationUpdated,
|
|
28754
|
-
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
28755
|
-
},
|
|
28756
|
-
{
|
|
28757
|
-
fn: onLocalInvitationCanceled,
|
|
28758
|
-
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
28759
|
-
},
|
|
28760
|
-
]);
|
|
28761
|
-
}
|
|
28762
|
-
notifyChange({ origin, loading, error }) {
|
|
28763
|
-
var _a, _b;
|
|
28764
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28765
|
-
if (!collection)
|
|
28766
|
-
return;
|
|
28767
|
-
const data = this.applyFilter((_b = collection.data
|
|
28768
|
-
.map(id => pullFromCache(['invitation', 'get', id]))
|
|
28769
|
-
.filter(isNonNullable)
|
|
28770
|
-
.map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
|
|
28771
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
28772
|
-
return;
|
|
28773
|
-
this.callback({
|
|
28774
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
28775
|
-
data,
|
|
28776
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
28777
|
-
loading,
|
|
28778
|
-
error,
|
|
28779
|
-
});
|
|
28780
|
-
}
|
|
28781
|
-
applyFilter(data) {
|
|
28782
|
-
let invitations = data;
|
|
28783
|
-
if (this.query.targetId) {
|
|
28784
|
-
invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
|
|
28785
|
-
}
|
|
28786
|
-
if (this.query.statuses) {
|
|
28787
|
-
invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
|
|
28788
|
-
}
|
|
28789
|
-
if (this.query.targetType) {
|
|
28790
|
-
invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
|
|
28791
|
-
}
|
|
28792
|
-
if (this.query.type) {
|
|
28793
|
-
invitations = invitations.filter(invitation => invitation.type === this.query.type);
|
|
28794
|
-
}
|
|
28795
|
-
const sortFn = (() => {
|
|
28796
|
-
switch (this.query.sortBy) {
|
|
28797
|
-
case 'firstCreated':
|
|
28798
|
-
return sortByFirstCreated;
|
|
28799
|
-
case 'lastCreated':
|
|
28800
|
-
return sortByLastCreated;
|
|
28801
|
-
default:
|
|
28802
|
-
return sortByLastCreated;
|
|
28803
|
-
}
|
|
28804
|
-
})();
|
|
28805
|
-
invitations = invitations.sort(sortFn);
|
|
28806
|
-
return invitations;
|
|
28807
|
-
}
|
|
28808
|
-
}
|
|
28809
|
-
|
|
28810
|
-
/**
|
|
28811
|
-
* Get invitations
|
|
28812
|
-
*
|
|
28813
|
-
* @param params the query parameters
|
|
28814
|
-
* @param callback the callback to be called when the invitations are updated
|
|
28815
|
-
* @returns invitations
|
|
28816
|
-
*
|
|
28817
|
-
* @category Invitation Live Collection
|
|
28818
|
-
*
|
|
28819
|
-
*/
|
|
28820
|
-
const getInvitations$1 = (params, callback, config) => {
|
|
28821
|
-
const { log, cache } = getActiveClient();
|
|
28822
|
-
if (!cache) {
|
|
28823
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
28824
|
-
}
|
|
28825
|
-
const timestamp = Date.now();
|
|
28826
|
-
log(`getInvitations: (tmpid: ${timestamp}) > listen`);
|
|
28827
|
-
const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
|
|
28828
|
-
const disposers = invitationsLiveCollection.startSubscription();
|
|
28829
|
-
const cacheKey = invitationsLiveCollection.getCacheKey();
|
|
28830
|
-
disposers.push(() => {
|
|
28831
|
-
dropFromCache(cacheKey);
|
|
28832
|
-
});
|
|
28833
|
-
return () => {
|
|
28834
|
-
log(`getInvitations (tmpid: ${timestamp}) > dispose`);
|
|
28835
|
-
disposers.forEach(fn => fn());
|
|
28836
|
-
};
|
|
28837
|
-
};
|
|
28838
|
-
|
|
28839
|
-
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
28840
|
-
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
28841
|
-
};
|
|
28842
|
-
|
|
28843
28599
|
/* begin_public_function
|
|
28844
28600
|
id: invitation.get
|
|
28845
28601
|
*/
|
|
@@ -28874,11 +28630,7 @@ const getInvitation = async (params) => {
|
|
|
28874
28630
|
/* end_public_function */
|
|
28875
28631
|
|
|
28876
28632
|
const roomLinkedObject = (room) => {
|
|
28877
|
-
return Object.assign(Object.assign({}, room), { get
|
|
28878
|
-
var _a;
|
|
28879
|
-
return (_a = pullFromCache(['roomModeration', 'get', room.roomId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28880
|
-
},
|
|
28881
|
-
get post() {
|
|
28633
|
+
return Object.assign(Object.assign({}, room), { get post() {
|
|
28882
28634
|
var _a;
|
|
28883
28635
|
if (room.referenceType !== 'post')
|
|
28884
28636
|
return;
|
|
@@ -28916,7 +28668,7 @@ const roomLinkedObject = (room) => {
|
|
|
28916
28668
|
targetType: 'room',
|
|
28917
28669
|
targetId: room.roomId,
|
|
28918
28670
|
userIds: [userId],
|
|
28919
|
-
}), getInvitations:
|
|
28671
|
+
}), getInvitations: async () => {
|
|
28920
28672
|
const { data } = await getInvitation({
|
|
28921
28673
|
targetId: room.roomId,
|
|
28922
28674
|
targetType: 'room',
|
|
@@ -29491,6 +29243,277 @@ const getJoinRequests = (params, callback, config) => {
|
|
|
29491
29243
|
};
|
|
29492
29244
|
};
|
|
29493
29245
|
|
|
29246
|
+
var InvitationActionsEnum;
|
|
29247
|
+
(function (InvitationActionsEnum) {
|
|
29248
|
+
InvitationActionsEnum["OnLocalInvitationCreated"] = "onLocalInvitationCreated";
|
|
29249
|
+
InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
|
|
29250
|
+
InvitationActionsEnum["OnLocalInvitationCanceled"] = "onLocalInvitationCanceled";
|
|
29251
|
+
})(InvitationActionsEnum || (InvitationActionsEnum = {}));
|
|
29252
|
+
|
|
29253
|
+
class InvitationsPaginationController extends PaginationController {
|
|
29254
|
+
async getRequest(queryParams, token) {
|
|
29255
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
29256
|
+
const options = token ? { token } : { limit };
|
|
29257
|
+
const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
|
|
29258
|
+
return data;
|
|
29259
|
+
}
|
|
29260
|
+
}
|
|
29261
|
+
|
|
29262
|
+
class InvitationsQueryStreamController extends QueryStreamController {
|
|
29263
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
29264
|
+
super(query, cacheKey);
|
|
29265
|
+
this.notifyChange = notifyChange;
|
|
29266
|
+
this.preparePayload = preparePayload;
|
|
29267
|
+
}
|
|
29268
|
+
async saveToMainDB(response) {
|
|
29269
|
+
const processedPayload = await this.preparePayload(response);
|
|
29270
|
+
const client = getActiveClient();
|
|
29271
|
+
const cachedAt = client.cache && Date.now();
|
|
29272
|
+
if (client.cache) {
|
|
29273
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
29274
|
+
}
|
|
29275
|
+
}
|
|
29276
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
29277
|
+
var _a, _b;
|
|
29278
|
+
if (refresh) {
|
|
29279
|
+
pushToCache(this.cacheKey, {
|
|
29280
|
+
data: response.invitations.map(getResolver('invitation')),
|
|
29281
|
+
});
|
|
29282
|
+
}
|
|
29283
|
+
else {
|
|
29284
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29285
|
+
const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29286
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
29287
|
+
...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
|
|
29288
|
+
] }));
|
|
29289
|
+
}
|
|
29290
|
+
}
|
|
29291
|
+
reactor(action) {
|
|
29292
|
+
return (invitations) => {
|
|
29293
|
+
var _a;
|
|
29294
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29295
|
+
if (!collection)
|
|
29296
|
+
return;
|
|
29297
|
+
if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
|
|
29298
|
+
const isExist = collection.data.find(id => id === invitations[0].invitationId);
|
|
29299
|
+
if (!isExist)
|
|
29300
|
+
return;
|
|
29301
|
+
}
|
|
29302
|
+
if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
|
|
29303
|
+
collection.data = [
|
|
29304
|
+
...new Set([
|
|
29305
|
+
...invitations.map(invitation => invitation.invitationId),
|
|
29306
|
+
...collection.data,
|
|
29307
|
+
]),
|
|
29308
|
+
];
|
|
29309
|
+
}
|
|
29310
|
+
if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
|
|
29311
|
+
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
29312
|
+
}
|
|
29313
|
+
pushToCache(this.cacheKey, collection);
|
|
29314
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
29315
|
+
};
|
|
29316
|
+
}
|
|
29317
|
+
subscribeRTE(createSubscriber) {
|
|
29318
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
29319
|
+
}
|
|
29320
|
+
}
|
|
29321
|
+
|
|
29322
|
+
/**
|
|
29323
|
+
* ```js
|
|
29324
|
+
* import { onLocalInvitationCreated } from '@amityco/ts-sdk'
|
|
29325
|
+
* const dispose = onLocalInvitationCreated(data => {
|
|
29326
|
+
* // ...
|
|
29327
|
+
* })
|
|
29328
|
+
* ```
|
|
29329
|
+
*
|
|
29330
|
+
* Fired when an {@link Amity.InvitationPayload} has been created
|
|
29331
|
+
*
|
|
29332
|
+
* @param callback The function to call when the event was fired
|
|
29333
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29334
|
+
*
|
|
29335
|
+
* @category Invitation Events
|
|
29336
|
+
*/
|
|
29337
|
+
const onLocalInvitationCreated = (callback) => {
|
|
29338
|
+
const client = getActiveClient();
|
|
29339
|
+
const disposers = [
|
|
29340
|
+
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
|
|
29341
|
+
];
|
|
29342
|
+
return () => {
|
|
29343
|
+
disposers.forEach(fn => fn());
|
|
29344
|
+
};
|
|
29345
|
+
};
|
|
29346
|
+
|
|
29347
|
+
/**
|
|
29348
|
+
* ```js
|
|
29349
|
+
* import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
|
|
29350
|
+
* const dispose = onLocalInvitationUpdated(data => {
|
|
29351
|
+
* // ...
|
|
29352
|
+
* })
|
|
29353
|
+
* ```
|
|
29354
|
+
*
|
|
29355
|
+
* Fired when an {@link Amity.InvitationPayload} has been updated
|
|
29356
|
+
*
|
|
29357
|
+
* @param callback The function to call when the event was fired
|
|
29358
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29359
|
+
*
|
|
29360
|
+
* @category Invitation Events
|
|
29361
|
+
*/
|
|
29362
|
+
const onLocalInvitationUpdated = (callback) => {
|
|
29363
|
+
const client = getActiveClient();
|
|
29364
|
+
const disposers = [
|
|
29365
|
+
createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
|
|
29366
|
+
];
|
|
29367
|
+
return () => {
|
|
29368
|
+
disposers.forEach(fn => fn());
|
|
29369
|
+
};
|
|
29370
|
+
};
|
|
29371
|
+
|
|
29372
|
+
/**
|
|
29373
|
+
* ```js
|
|
29374
|
+
* import { onLocalInvitationCanceled } from '@amityco/ts-sdk'
|
|
29375
|
+
* const dispose = onLocalInvitationCanceled(data => {
|
|
29376
|
+
* // ...
|
|
29377
|
+
* })
|
|
29378
|
+
* ```
|
|
29379
|
+
*
|
|
29380
|
+
* Fired when an {@link Amity.InvitationPayload} has been deleted
|
|
29381
|
+
*
|
|
29382
|
+
* @param callback The function to call when the event was fired
|
|
29383
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29384
|
+
*
|
|
29385
|
+
* @category Invitation Events
|
|
29386
|
+
*/
|
|
29387
|
+
const onLocalInvitationCanceled = (callback) => {
|
|
29388
|
+
const client = getActiveClient();
|
|
29389
|
+
const disposers = [
|
|
29390
|
+
createEventSubscriber(client, 'onLocalInvitationCanceled', 'local.invitation.canceled', payload => callback(payload)),
|
|
29391
|
+
];
|
|
29392
|
+
return () => {
|
|
29393
|
+
disposers.forEach(fn => fn());
|
|
29394
|
+
};
|
|
29395
|
+
};
|
|
29396
|
+
|
|
29397
|
+
class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
29398
|
+
constructor(query, callback) {
|
|
29399
|
+
const queryStreamId = hash(query);
|
|
29400
|
+
const cacheKey = ['invitation', 'collection', queryStreamId];
|
|
29401
|
+
const paginationController = new InvitationsPaginationController(query);
|
|
29402
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
29403
|
+
this.query = query;
|
|
29404
|
+
this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
|
|
29405
|
+
this.callback = callback.bind(this);
|
|
29406
|
+
this.loadPage({ initial: true });
|
|
29407
|
+
}
|
|
29408
|
+
setup() {
|
|
29409
|
+
var _a;
|
|
29410
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29411
|
+
if (!collection) {
|
|
29412
|
+
pushToCache(this.cacheKey, {
|
|
29413
|
+
data: [],
|
|
29414
|
+
params: this.query,
|
|
29415
|
+
});
|
|
29416
|
+
}
|
|
29417
|
+
}
|
|
29418
|
+
async persistModel(queryPayload) {
|
|
29419
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
29420
|
+
}
|
|
29421
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
29422
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
29423
|
+
}
|
|
29424
|
+
startSubscription() {
|
|
29425
|
+
return this.queryStreamController.subscribeRTE([
|
|
29426
|
+
{
|
|
29427
|
+
fn: onLocalInvitationCreated,
|
|
29428
|
+
action: InvitationActionsEnum.OnLocalInvitationCreated,
|
|
29429
|
+
},
|
|
29430
|
+
{
|
|
29431
|
+
fn: onLocalInvitationUpdated,
|
|
29432
|
+
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
29433
|
+
},
|
|
29434
|
+
{
|
|
29435
|
+
fn: onLocalInvitationCanceled,
|
|
29436
|
+
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
29437
|
+
},
|
|
29438
|
+
]);
|
|
29439
|
+
}
|
|
29440
|
+
notifyChange({ origin, loading, error }) {
|
|
29441
|
+
var _a, _b;
|
|
29442
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29443
|
+
if (!collection)
|
|
29444
|
+
return;
|
|
29445
|
+
const data = this.applyFilter((_b = collection.data
|
|
29446
|
+
.map(id => pullFromCache(['invitation', 'get', id]))
|
|
29447
|
+
.filter(isNonNullable)
|
|
29448
|
+
.map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
|
|
29449
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
29450
|
+
return;
|
|
29451
|
+
this.callback({
|
|
29452
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
29453
|
+
data,
|
|
29454
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
29455
|
+
loading,
|
|
29456
|
+
error,
|
|
29457
|
+
});
|
|
29458
|
+
}
|
|
29459
|
+
applyFilter(data) {
|
|
29460
|
+
let invitations = data;
|
|
29461
|
+
if (this.query.targetId) {
|
|
29462
|
+
invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
|
|
29463
|
+
}
|
|
29464
|
+
if (this.query.statuses) {
|
|
29465
|
+
invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
|
|
29466
|
+
}
|
|
29467
|
+
if (this.query.targetType) {
|
|
29468
|
+
invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
|
|
29469
|
+
}
|
|
29470
|
+
if (this.query.type) {
|
|
29471
|
+
invitations = invitations.filter(invitation => invitation.type === this.query.type);
|
|
29472
|
+
}
|
|
29473
|
+
const sortFn = (() => {
|
|
29474
|
+
switch (this.query.sortBy) {
|
|
29475
|
+
case 'firstCreated':
|
|
29476
|
+
return sortByFirstCreated;
|
|
29477
|
+
case 'lastCreated':
|
|
29478
|
+
return sortByLastCreated;
|
|
29479
|
+
default:
|
|
29480
|
+
return sortByLastCreated;
|
|
29481
|
+
}
|
|
29482
|
+
})();
|
|
29483
|
+
invitations = invitations.sort(sortFn);
|
|
29484
|
+
return invitations;
|
|
29485
|
+
}
|
|
29486
|
+
}
|
|
29487
|
+
|
|
29488
|
+
/**
|
|
29489
|
+
* Get invitations
|
|
29490
|
+
*
|
|
29491
|
+
* @param params the query parameters
|
|
29492
|
+
* @param callback the callback to be called when the invitations are updated
|
|
29493
|
+
* @returns invitations
|
|
29494
|
+
*
|
|
29495
|
+
* @category Invitation Live Collection
|
|
29496
|
+
*
|
|
29497
|
+
*/
|
|
29498
|
+
const getInvitations$1 = (params, callback, config) => {
|
|
29499
|
+
const { log, cache } = getActiveClient();
|
|
29500
|
+
if (!cache) {
|
|
29501
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
29502
|
+
}
|
|
29503
|
+
const timestamp = Date.now();
|
|
29504
|
+
log(`getInvitations: (tmpid: ${timestamp}) > listen`);
|
|
29505
|
+
const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
|
|
29506
|
+
const disposers = invitationsLiveCollection.startSubscription();
|
|
29507
|
+
const cacheKey = invitationsLiveCollection.getCacheKey();
|
|
29508
|
+
disposers.push(() => {
|
|
29509
|
+
dropFromCache(cacheKey);
|
|
29510
|
+
});
|
|
29511
|
+
return () => {
|
|
29512
|
+
log(`getInvitations (tmpid: ${timestamp}) > dispose`);
|
|
29513
|
+
disposers.forEach(fn => fn());
|
|
29514
|
+
};
|
|
29515
|
+
};
|
|
29516
|
+
|
|
29494
29517
|
const communityLinkedObject = (community) => {
|
|
29495
29518
|
return Object.assign(Object.assign({}, community), { get categories() {
|
|
29496
29519
|
var _a;
|
|
@@ -30187,7 +30210,7 @@ class RSVPQueryStreamController extends QueryStreamController {
|
|
|
30187
30210
|
const client = getActiveClient();
|
|
30188
30211
|
const cachedAt = client.cache && Date.now();
|
|
30189
30212
|
if (client.cache)
|
|
30190
|
-
ingestInCache(
|
|
30213
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
30191
30214
|
}
|
|
30192
30215
|
appendToQueryStream(response, direction, refresh = false) {
|
|
30193
30216
|
var _a, _b;
|
|
@@ -30211,10 +30234,7 @@ class RSVPQueryStreamController extends QueryStreamController {
|
|
|
30211
30234
|
if (!collection)
|
|
30212
30235
|
return;
|
|
30213
30236
|
if (action === EventActionsEnum.OnRSVPCreated) {
|
|
30214
|
-
|
|
30215
|
-
if (client.userId !== event.userId)
|
|
30216
|
-
return;
|
|
30217
|
-
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
30237
|
+
collection.data = [...new Set([event.userId, ...collection.data])];
|
|
30218
30238
|
}
|
|
30219
30239
|
if (action === EventActionsEnum.OnEventDeleted) {
|
|
30220
30240
|
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
@@ -30430,14 +30450,14 @@ class RSVPLiveCollectionController extends LiveCollectionController {
|
|
|
30430
30450
|
]);
|
|
30431
30451
|
}
|
|
30432
30452
|
notifyChange({ origin, loading, error }) {
|
|
30433
|
-
var _a
|
|
30453
|
+
var _a;
|
|
30434
30454
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30435
30455
|
if (!collection)
|
|
30436
30456
|
return;
|
|
30437
|
-
const data =
|
|
30438
|
-
.map(
|
|
30457
|
+
const data = collection.data
|
|
30458
|
+
.map(userId => pullFromCache(['eventResponse', 'get', userId]))
|
|
30439
30459
|
.filter(isNonNullable)
|
|
30440
|
-
.map(({ data }) => data))
|
|
30460
|
+
.map(({ data }) => eventResponseLinkedObject(data));
|
|
30441
30461
|
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
30442
30462
|
return;
|
|
30443
30463
|
this.callback({
|
|
@@ -43023,6 +43043,15 @@ const getPostSubscription = (cacheKey) => {
|
|
|
43023
43043
|
...generateCommentSubscriptions({ cacheKey }),
|
|
43024
43044
|
];
|
|
43025
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
|
+
};
|
|
43026
43055
|
|
|
43027
43056
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
43028
43057
|
constructor(query, callback) {
|
|
@@ -43916,7 +43945,7 @@ class LiveRoomPostPaginationController extends PaginationNoPageController {
|
|
|
43916
43945
|
targetTypes: ['all'],
|
|
43917
43946
|
options: {
|
|
43918
43947
|
limit,
|
|
43919
|
-
sortBy: '
|
|
43948
|
+
sortBy: 'lastCreated',
|
|
43920
43949
|
},
|
|
43921
43950
|
},
|
|
43922
43951
|
});
|
|
@@ -43942,13 +43971,13 @@ class LiveRoomPostQueryStreamController extends QueryStreamController {
|
|
|
43942
43971
|
var _a, _b;
|
|
43943
43972
|
if (refresh) {
|
|
43944
43973
|
pushToCache(this.cacheKey, {
|
|
43945
|
-
data: response.posts
|
|
43974
|
+
data: resolvePostIdsFromRooms(response.rooms, response.posts),
|
|
43946
43975
|
});
|
|
43947
43976
|
}
|
|
43948
43977
|
else {
|
|
43949
43978
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
43950
43979
|
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
43951
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts
|
|
43980
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...resolvePostIdsFromRooms(response.rooms, response.posts)])] }));
|
|
43952
43981
|
}
|
|
43953
43982
|
}
|
|
43954
43983
|
reactor(action) {
|
|
@@ -44486,6 +44515,30 @@ const onRoomParticipantLeft = (callback) => {
|
|
|
44486
44515
|
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
44487
44516
|
};
|
|
44488
44517
|
|
|
44518
|
+
/**
|
|
44519
|
+
* ```js
|
|
44520
|
+
* import { onRoomTerminated } from '@amityco/ts-sdk'
|
|
44521
|
+
* const dispose = onRoomTerminated(room => {
|
|
44522
|
+
* // ...
|
|
44523
|
+
* })
|
|
44524
|
+
* ```
|
|
44525
|
+
*
|
|
44526
|
+
* Fired when a {@link Amity.Room} has started broadcasting
|
|
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 onRoomTerminated = (callback) => {
|
|
44534
|
+
const client = getActiveClient();
|
|
44535
|
+
const filter = (payload) => {
|
|
44536
|
+
ingestInCache(payload);
|
|
44537
|
+
callback(payload.rooms[0]);
|
|
44538
|
+
};
|
|
44539
|
+
return createEventSubscriber(client, 'room/onRoomTerminated', 'room.terminated', filter);
|
|
44540
|
+
};
|
|
44541
|
+
|
|
44489
44542
|
/**
|
|
44490
44543
|
* ```js
|
|
44491
44544
|
* import { onRoomCreated } from '@amityco/ts-sdk'
|
|
@@ -44660,6 +44713,7 @@ const getRoom = (roomId, callback) => {
|
|
|
44660
44713
|
onRoomEndBroadcasting,
|
|
44661
44714
|
onRoomStartBroadcasting,
|
|
44662
44715
|
onRoomWaitingReconnect,
|
|
44716
|
+
onRoomTerminated,
|
|
44663
44717
|
onRoomRecordedAvailable,
|
|
44664
44718
|
onRoomParticipantJoined,
|
|
44665
44719
|
onRoomParticipantLeft,
|
|
@@ -44905,6 +44959,7 @@ var index$b = /*#__PURE__*/Object.freeze({
|
|
|
44905
44959
|
onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
|
|
44906
44960
|
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
44907
44961
|
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
44962
|
+
onRoomTerminated: onRoomTerminated,
|
|
44908
44963
|
onRoomCreated: onRoomCreated,
|
|
44909
44964
|
onRoomUpdated: onRoomUpdated,
|
|
44910
44965
|
onRoomDeleted: onRoomDeleted,
|
|
@@ -45050,13 +45105,13 @@ class CommunityLiveRoomPostQueryStreamController extends QueryStreamController {
|
|
|
45050
45105
|
var _a, _b;
|
|
45051
45106
|
if (refresh) {
|
|
45052
45107
|
pushToCache(this.cacheKey, {
|
|
45053
|
-
data: response.posts
|
|
45108
|
+
data: resolvePostIdsFromRooms(response.rooms, response.posts),
|
|
45054
45109
|
});
|
|
45055
45110
|
}
|
|
45056
45111
|
else {
|
|
45057
45112
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
45058
45113
|
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
45059
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts
|
|
45114
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...resolvePostIdsFromRooms(response.rooms, response.posts)])] }));
|
|
45060
45115
|
}
|
|
45061
45116
|
}
|
|
45062
45117
|
reactor(action) {
|
|
@@ -45874,7 +45929,6 @@ const getRoomUserCount = async (roomId) => {
|
|
|
45874
45929
|
client.log('roomPresence/getRoomUserCount', { roomId });
|
|
45875
45930
|
const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
|
|
45876
45931
|
pushToCache(['get', 'watchingCount', roomId], data);
|
|
45877
|
-
fireEvent('local.room.watchingCountUpdated', data);
|
|
45878
45932
|
return data;
|
|
45879
45933
|
};
|
|
45880
45934
|
/* end_public_function */
|