@amityco/ts-sdk 7.11.1-084e4b1c.0 → 7.11.1-0e55a3b4.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 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +10 -2
- package/dist/@types/domains/event.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +3 -1
- package/dist/@types/domains/notification.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/events/enums.d.ts +3 -1
- package/dist/eventRepository/events/enums.d.ts.map +1 -1
- package/dist/eventRepository/events/index.d.ts +4 -0
- package/dist/eventRepository/events/index.d.ts.map +1 -1
- package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalRSVPCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts.map +1 -0
- package/dist/eventRepository/events/onRSVPCreated.d.ts +17 -0
- package/dist/eventRepository/events/onRSVPCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onRSVPUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onRSVPUpdated.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/createRSVP.d.ts +16 -0
- package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/getMyRSVP.d.ts +32 -0
- package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/index.d.ts +3 -0
- package/dist/eventRepository/internalApi/index.d.ts.map +1 -1
- package/dist/eventRepository/internalApi/updateRSVP.d.ts +17 -0
- package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +13 -0
- package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +5 -0
- package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +15 -0
- package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs.d.ts +12 -0
- package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -0
- package/dist/eventRepository/observers/index.d.ts +1 -0
- package/dist/eventRepository/observers/index.d.ts.map +1 -1
- package/dist/index.cjs.js +369 -26
- package/dist/index.esm.js +369 -26
- package/dist/index.umd.js +3 -3
- package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -197,7 +197,6 @@ var AmityEventStatus;
|
|
|
197
197
|
var AmityEventResponseStatus;
|
|
198
198
|
(function (AmityEventResponseStatus) {
|
|
199
199
|
AmityEventResponseStatus["Going"] = "going";
|
|
200
|
-
AmityEventResponseStatus["Interested"] = "interested";
|
|
201
200
|
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
202
201
|
})(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
|
|
203
202
|
|
|
@@ -29778,6 +29777,155 @@ const communityLinkedObject = (community) => {
|
|
|
29778
29777
|
} });
|
|
29779
29778
|
};
|
|
29780
29779
|
|
|
29780
|
+
const prepareEventPayload = (rawPayload) => {
|
|
29781
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
29782
|
+
};
|
|
29783
|
+
|
|
29784
|
+
const createEventEventSubscriber = (event, callback) => {
|
|
29785
|
+
const client = getActiveClient();
|
|
29786
|
+
const filter = (payload) => {
|
|
29787
|
+
const unpackedPayload = prepareEventPayload(payload);
|
|
29788
|
+
if (!client.cache) {
|
|
29789
|
+
callback(unpackedPayload.events[0]);
|
|
29790
|
+
}
|
|
29791
|
+
else {
|
|
29792
|
+
ingestInCache(unpackedPayload);
|
|
29793
|
+
const event = pullFromCache([
|
|
29794
|
+
'event',
|
|
29795
|
+
'get',
|
|
29796
|
+
unpackedPayload.events[0].eventId,
|
|
29797
|
+
]);
|
|
29798
|
+
callback(event.data);
|
|
29799
|
+
}
|
|
29800
|
+
};
|
|
29801
|
+
return createEventSubscriber(client, event, event, filter);
|
|
29802
|
+
};
|
|
29803
|
+
|
|
29804
|
+
/* begin_public_function
|
|
29805
|
+
id: event.rsvp.create
|
|
29806
|
+
*/
|
|
29807
|
+
/**
|
|
29808
|
+
* ```js
|
|
29809
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29810
|
+
* const response = await event.createRSVP(eventId, status)
|
|
29811
|
+
* ```
|
|
29812
|
+
*
|
|
29813
|
+
* Creates an {@link Amity.InternalEvent}
|
|
29814
|
+
*
|
|
29815
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalEvent}
|
|
29816
|
+
* @returns The newly created {@link Amity.InternalEvent}
|
|
29817
|
+
*
|
|
29818
|
+
* @category Event API
|
|
29819
|
+
* @async
|
|
29820
|
+
*/
|
|
29821
|
+
const createRSVP = async (eventId, status) => {
|
|
29822
|
+
const client = getActiveClient();
|
|
29823
|
+
client.log('event/createRSVP', eventId, status);
|
|
29824
|
+
const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
29825
|
+
fireEvent('local.rsvp.created', payload);
|
|
29826
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
29827
|
+
const cachedAt = client.cache && Date.now();
|
|
29828
|
+
if (client.cache)
|
|
29829
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
29830
|
+
return {
|
|
29831
|
+
data: preparedPayload.events[0],
|
|
29832
|
+
cachedAt,
|
|
29833
|
+
};
|
|
29834
|
+
};
|
|
29835
|
+
/* end_public_function */
|
|
29836
|
+
|
|
29837
|
+
/* begin_public_function
|
|
29838
|
+
id: event.update
|
|
29839
|
+
*/
|
|
29840
|
+
/**
|
|
29841
|
+
* ```js
|
|
29842
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29843
|
+
* const response = await event.updateRSVP(eventId, status)
|
|
29844
|
+
* ```
|
|
29845
|
+
*
|
|
29846
|
+
* Updates an {@link Amity.InternalEvent}
|
|
29847
|
+
*
|
|
29848
|
+
* @param eventId The ID of the {@link Amity.InternalEvent} to edit
|
|
29849
|
+
* @param bundle The data necessary to update an existing {@link Amity.InternalEvent}
|
|
29850
|
+
* @returns the updated {@link Amity.InternalEvent}
|
|
29851
|
+
*
|
|
29852
|
+
* @category Event API
|
|
29853
|
+
* @async
|
|
29854
|
+
*/
|
|
29855
|
+
const updateRSVP = async (eventId, status) => {
|
|
29856
|
+
const client = getActiveClient();
|
|
29857
|
+
client.log('event/updateRSVP', eventId, status);
|
|
29858
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
29859
|
+
fireEvent('local.rsvp.updated', payload);
|
|
29860
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
29861
|
+
const cachedAt = client.cache && Date.now();
|
|
29862
|
+
if (client.cache)
|
|
29863
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
29864
|
+
return {
|
|
29865
|
+
data: preparedPayload.events.find(event => event.eventId === eventId),
|
|
29866
|
+
cachedAt,
|
|
29867
|
+
};
|
|
29868
|
+
};
|
|
29869
|
+
/* end_public_function */
|
|
29870
|
+
|
|
29871
|
+
/* begin_public_function
|
|
29872
|
+
id: event.rsvp.me
|
|
29873
|
+
*/
|
|
29874
|
+
/**
|
|
29875
|
+
* ```js
|
|
29876
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29877
|
+
* const myRSVP = await event.getMyRSVP(eventId)
|
|
29878
|
+
* ```
|
|
29879
|
+
*
|
|
29880
|
+
* Joins a {@link Amity.InternalEvent} object
|
|
29881
|
+
*
|
|
29882
|
+
* @param eventId the {@link Amity.InternalEvent} to get RSVP for
|
|
29883
|
+
* @returns A success boolean if the {@link Amity.InternalEvent} RSVP was retrieved
|
|
29884
|
+
*
|
|
29885
|
+
* @category Event API
|
|
29886
|
+
* @async
|
|
29887
|
+
*/
|
|
29888
|
+
const getMyRSVP = async (eventId) => {
|
|
29889
|
+
const client = getActiveClient();
|
|
29890
|
+
client.log('event/getMyRSVP', eventId);
|
|
29891
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
|
|
29892
|
+
const data = prepareEventPayload(payload);
|
|
29893
|
+
const cachedAt = client.cache && Date.now();
|
|
29894
|
+
if (client.cache)
|
|
29895
|
+
ingestInCache(data, { cachedAt });
|
|
29896
|
+
return {
|
|
29897
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
29898
|
+
cachedAt,
|
|
29899
|
+
};
|
|
29900
|
+
};
|
|
29901
|
+
/* end_public_function */
|
|
29902
|
+
/**
|
|
29903
|
+
* ```js
|
|
29904
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29905
|
+
* const event = event.getMyRSVP.locally(eventId)
|
|
29906
|
+
* ```
|
|
29907
|
+
*
|
|
29908
|
+
* Fetches a {@link Amity.InternalEvent} object in cache
|
|
29909
|
+
*
|
|
29910
|
+
* @param eventId the ID of the {@link Amity.InternalEvent} to fetch
|
|
29911
|
+
* @returns the associated {@link Amity.InternalEvent} object
|
|
29912
|
+
*
|
|
29913
|
+
* @category Event API
|
|
29914
|
+
*/
|
|
29915
|
+
getMyRSVP.locally = (eventId) => {
|
|
29916
|
+
const client = getActiveClient();
|
|
29917
|
+
client.log('event/getMyRSVP.locally', eventId);
|
|
29918
|
+
if (!client.cache)
|
|
29919
|
+
return;
|
|
29920
|
+
const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
|
|
29921
|
+
if (!cache)
|
|
29922
|
+
return;
|
|
29923
|
+
return {
|
|
29924
|
+
data: cache.data,
|
|
29925
|
+
cachedAt: cache.cachedAt,
|
|
29926
|
+
};
|
|
29927
|
+
};
|
|
29928
|
+
|
|
29781
29929
|
const eventLinkedObject = (event) => {
|
|
29782
29930
|
return Object.assign(Object.assign({}, event), { get creator() {
|
|
29783
29931
|
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
@@ -29820,6 +29968,15 @@ const eventLinkedObject = (event) => {
|
|
|
29820
29968
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29821
29969
|
return;
|
|
29822
29970
|
return cacheData.data;
|
|
29971
|
+
}, createRSVP: async (status) => {
|
|
29972
|
+
const { data } = await createRSVP(event.eventId, status);
|
|
29973
|
+
return data;
|
|
29974
|
+
}, updateRSVP: async (status) => {
|
|
29975
|
+
const { data } = await updateRSVP(event.eventId, status);
|
|
29976
|
+
return data;
|
|
29977
|
+
}, getMyRSVP: async () => {
|
|
29978
|
+
const { data } = await getMyRSVP(event.eventId);
|
|
29979
|
+
return data;
|
|
29823
29980
|
} });
|
|
29824
29981
|
};
|
|
29825
29982
|
|
|
@@ -46459,30 +46616,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
46459
46616
|
getReactions: getReactions
|
|
46460
46617
|
});
|
|
46461
46618
|
|
|
46462
|
-
const prepareEventPayload = (rawPayload) => {
|
|
46463
|
-
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
46464
|
-
};
|
|
46465
|
-
|
|
46466
|
-
const createEventEventSubscriber = (event, callback) => {
|
|
46467
|
-
const client = getActiveClient();
|
|
46468
|
-
const filter = (payload) => {
|
|
46469
|
-
const unpackedPayload = prepareEventPayload(payload);
|
|
46470
|
-
if (!client.cache) {
|
|
46471
|
-
callback(unpackedPayload.events[0]);
|
|
46472
|
-
}
|
|
46473
|
-
else {
|
|
46474
|
-
ingestInCache(unpackedPayload);
|
|
46475
|
-
const event = pullFromCache([
|
|
46476
|
-
'event',
|
|
46477
|
-
'get',
|
|
46478
|
-
unpackedPayload.events[0].eventId,
|
|
46479
|
-
]);
|
|
46480
|
-
callback(event.data);
|
|
46481
|
-
}
|
|
46482
|
-
};
|
|
46483
|
-
return createEventSubscriber(client, event, event, filter);
|
|
46484
|
-
};
|
|
46485
|
-
|
|
46486
46619
|
/* begin_public_function
|
|
46487
46620
|
id: event.create
|
|
46488
46621
|
*/
|
|
@@ -46744,6 +46877,74 @@ const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.even
|
|
|
46744
46877
|
*/
|
|
46745
46878
|
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
46746
46879
|
|
|
46880
|
+
/**
|
|
46881
|
+
* ```js
|
|
46882
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46883
|
+
* const dispose = EventRepository.onRSVPCreated(event => {
|
|
46884
|
+
* // ...
|
|
46885
|
+
* })
|
|
46886
|
+
* ```
|
|
46887
|
+
*
|
|
46888
|
+
* Fired when a {@link Amity.Event} has been created
|
|
46889
|
+
*
|
|
46890
|
+
* @param callback The function to call when the event was fired
|
|
46891
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46892
|
+
*
|
|
46893
|
+
* @category Event Events
|
|
46894
|
+
*/
|
|
46895
|
+
const onRSVPCreated = (callback) => createEventEventSubscriber('event.rsvp.created', callback);
|
|
46896
|
+
|
|
46897
|
+
/**
|
|
46898
|
+
* ```js
|
|
46899
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46900
|
+
* const dispose = EventRepository.onRSVPUpdated(event => {
|
|
46901
|
+
* // ...
|
|
46902
|
+
* })
|
|
46903
|
+
* ```
|
|
46904
|
+
*
|
|
46905
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
46906
|
+
*
|
|
46907
|
+
* @param callback The function to call when the event was fired
|
|
46908
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46909
|
+
*
|
|
46910
|
+
* @category Event Events
|
|
46911
|
+
*/
|
|
46912
|
+
const onRSVPUpdated = (callback) => createEventEventSubscriber('event.rsvp.updated', callback);
|
|
46913
|
+
|
|
46914
|
+
/**
|
|
46915
|
+
* ```js
|
|
46916
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46917
|
+
* const dispose = EventRepository.onLocalRSVPCreated(event => {
|
|
46918
|
+
* // ...
|
|
46919
|
+
* })
|
|
46920
|
+
* ```
|
|
46921
|
+
*
|
|
46922
|
+
* Fired when a {@link Amity.Event} has been created
|
|
46923
|
+
*
|
|
46924
|
+
* @param callback The function to call when the event was fired
|
|
46925
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46926
|
+
*
|
|
46927
|
+
* @category Event Events
|
|
46928
|
+
*/
|
|
46929
|
+
const onLocalRSVPCreated = (callback) => createEventEventSubscriber('local.rsvp.created', callback);
|
|
46930
|
+
|
|
46931
|
+
/**
|
|
46932
|
+
* ```js
|
|
46933
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46934
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
46935
|
+
* // ...
|
|
46936
|
+
* })
|
|
46937
|
+
* ```
|
|
46938
|
+
*
|
|
46939
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
46940
|
+
*
|
|
46941
|
+
* @param callback The function to call when the event was fired
|
|
46942
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46943
|
+
*
|
|
46944
|
+
* @category Event Events
|
|
46945
|
+
*/
|
|
46946
|
+
const onLocalRSVPUpdated = (callback) => createEventEventSubscriber('local.rsvp.updated', callback);
|
|
46947
|
+
|
|
46747
46948
|
/* begin_public_function
|
|
46748
46949
|
id: event.get
|
|
46749
46950
|
*/
|
|
@@ -46778,6 +46979,8 @@ var EventActionsEnum;
|
|
|
46778
46979
|
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
46779
46980
|
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
46780
46981
|
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
46982
|
+
EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
|
|
46983
|
+
EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
|
|
46781
46984
|
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
46782
46985
|
|
|
46783
46986
|
class EventPaginationController extends PaginationController {
|
|
@@ -47051,6 +47254,141 @@ const getMyEvents = (params, callback, config) => {
|
|
|
47051
47254
|
};
|
|
47052
47255
|
};
|
|
47053
47256
|
|
|
47257
|
+
class RSVPPaginationController extends PaginationController {
|
|
47258
|
+
async getRequest(queryParams, token) {
|
|
47259
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
|
|
47260
|
+
const options = token ? { token } : { limit };
|
|
47261
|
+
const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
47262
|
+
return response;
|
|
47263
|
+
}
|
|
47264
|
+
}
|
|
47265
|
+
|
|
47266
|
+
class RSVPQueryStreamController extends QueryStreamController {
|
|
47267
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
47268
|
+
super(query, cacheKey);
|
|
47269
|
+
this.notifyChange = notifyChange;
|
|
47270
|
+
this.preparePayload = preparePayload;
|
|
47271
|
+
}
|
|
47272
|
+
async saveToMainDB(response) {
|
|
47273
|
+
const processedPayload = this.preparePayload(response);
|
|
47274
|
+
const client = getActiveClient();
|
|
47275
|
+
const cachedAt = client.cache && Date.now();
|
|
47276
|
+
if (client.cache)
|
|
47277
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
47278
|
+
}
|
|
47279
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
47280
|
+
var _a, _b;
|
|
47281
|
+
if (refresh) {
|
|
47282
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
47283
|
+
}
|
|
47284
|
+
else {
|
|
47285
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47286
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
47287
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
47288
|
+
}
|
|
47289
|
+
}
|
|
47290
|
+
reactor(action) {
|
|
47291
|
+
return (event) => {
|
|
47292
|
+
var _a;
|
|
47293
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47294
|
+
if (!collection)
|
|
47295
|
+
return;
|
|
47296
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
47297
|
+
const client = getActiveClient();
|
|
47298
|
+
if (client.userId !== event.userId)
|
|
47299
|
+
return;
|
|
47300
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
47301
|
+
}
|
|
47302
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
47303
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
47304
|
+
}
|
|
47305
|
+
pushToCache(this.cacheKey, collection);
|
|
47306
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
47307
|
+
};
|
|
47308
|
+
}
|
|
47309
|
+
subscribeRTE(createSubscriber) {
|
|
47310
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
47311
|
+
}
|
|
47312
|
+
}
|
|
47313
|
+
|
|
47314
|
+
class RSVPLiveCollectionController extends LiveCollectionController {
|
|
47315
|
+
constructor(query, callback) {
|
|
47316
|
+
const queryStreamId = hash(query);
|
|
47317
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
47318
|
+
const paginationController = new RSVPPaginationController(query);
|
|
47319
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
47320
|
+
this.query = query;
|
|
47321
|
+
this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
47322
|
+
this.callback = callback.bind(this);
|
|
47323
|
+
this.loadPage({ initial: true });
|
|
47324
|
+
}
|
|
47325
|
+
setup() {
|
|
47326
|
+
var _a;
|
|
47327
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47328
|
+
if (!collection)
|
|
47329
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
47330
|
+
}
|
|
47331
|
+
async persistModel(queryPayload) {
|
|
47332
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
47333
|
+
}
|
|
47334
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
47335
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
47336
|
+
}
|
|
47337
|
+
startSubscription() {
|
|
47338
|
+
return this.queryStreamController.subscribeRTE([
|
|
47339
|
+
{ fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
47340
|
+
{ fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
47341
|
+
{ fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
47342
|
+
{ fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
47343
|
+
]);
|
|
47344
|
+
}
|
|
47345
|
+
notifyChange({ origin, loading, error }) {
|
|
47346
|
+
var _a, _b;
|
|
47347
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47348
|
+
if (!collection)
|
|
47349
|
+
return;
|
|
47350
|
+
const data = ((_b = collection.data
|
|
47351
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
47352
|
+
.filter(isNonNullable)
|
|
47353
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
47354
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
47355
|
+
return;
|
|
47356
|
+
this.callback({
|
|
47357
|
+
data,
|
|
47358
|
+
error,
|
|
47359
|
+
loading,
|
|
47360
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
47361
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
47362
|
+
});
|
|
47363
|
+
}
|
|
47364
|
+
}
|
|
47365
|
+
|
|
47366
|
+
/**
|
|
47367
|
+
* Get events
|
|
47368
|
+
*
|
|
47369
|
+
* @param params the query parameters
|
|
47370
|
+
* @param callback the callback to be called when the events are updated
|
|
47371
|
+
* @returns events
|
|
47372
|
+
*
|
|
47373
|
+
* @category RSVP Live Collection
|
|
47374
|
+
*
|
|
47375
|
+
*/
|
|
47376
|
+
const getRSVPs = (params, callback, config) => {
|
|
47377
|
+
const { log, cache } = getActiveClient();
|
|
47378
|
+
if (!cache)
|
|
47379
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
47380
|
+
const timestamp = Date.now();
|
|
47381
|
+
log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
|
|
47382
|
+
const eventLiveCollection = new RSVPLiveCollectionController(params, callback);
|
|
47383
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
47384
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
47385
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
47386
|
+
return () => {
|
|
47387
|
+
log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
|
|
47388
|
+
disposers.forEach(fn => fn());
|
|
47389
|
+
};
|
|
47390
|
+
};
|
|
47391
|
+
|
|
47054
47392
|
var index = /*#__PURE__*/Object.freeze({
|
|
47055
47393
|
__proto__: null,
|
|
47056
47394
|
createEvent: createEvent,
|
|
@@ -47062,9 +47400,14 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
47062
47400
|
onLocalEventCreated: onLocalEventCreated,
|
|
47063
47401
|
onLocalEventUpdated: onLocalEventUpdated,
|
|
47064
47402
|
onLocalEventDeleted: onLocalEventDeleted,
|
|
47403
|
+
onRSVPCreated: onRSVPCreated,
|
|
47404
|
+
onRSVPUpdated: onRSVPUpdated,
|
|
47405
|
+
onLocalRSVPCreated: onLocalRSVPCreated,
|
|
47406
|
+
onLocalRSVPUpdated: onLocalRSVPUpdated,
|
|
47065
47407
|
getEvent: getEvent,
|
|
47066
47408
|
getEvents: getEvents,
|
|
47067
|
-
getMyEvents: getMyEvents
|
|
47409
|
+
getMyEvents: getMyEvents,
|
|
47410
|
+
getRSVPs: getRSVPs
|
|
47068
47411
|
});
|
|
47069
47412
|
|
|
47070
47413
|
export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, index$c as CategoryRepository, index$g as ChannelRepository, index$p as Client, index$b as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$d as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$7 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$5 as StoryRepository, index$8 as StreamRepository, index$j as SubChannelRepository, SubscriptionLevels, index$n as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|