@amityco/ts-sdk 7.11.1-9f733521.0 → 7.11.1-b8fc6951.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/domains/event.d.ts +0 -11
- package/dist/@types/domains/event.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 +2 -143
- package/dist/index.esm.js +3 -144
- package/dist/index.umd.js +3 -3
- package/package.json +1 -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
|
@@ -13,17 +13,11 @@ export declare enum AmityEventStatus {
|
|
|
13
13
|
Ended = "ended",
|
|
14
14
|
Cancelled = "cancelled"
|
|
15
15
|
}
|
|
16
|
-
export declare enum AmityEventResponseStatus {
|
|
17
|
-
Going = "going",
|
|
18
|
-
Interested = "interested",
|
|
19
|
-
NotGoing = "not_going"
|
|
20
|
-
}
|
|
21
16
|
declare global {
|
|
22
17
|
namespace Amity {
|
|
23
18
|
type EventType = AmityEventType;
|
|
24
19
|
type EventOriginType = AmityEventOriginType;
|
|
25
20
|
type EventStatus = AmityEventStatus;
|
|
26
|
-
type EventResponseStatus = AmityEventResponseStatus;
|
|
27
21
|
type RawEvent = {
|
|
28
22
|
eventId: string;
|
|
29
23
|
userId: string;
|
|
@@ -65,11 +59,6 @@ declare global {
|
|
|
65
59
|
};
|
|
66
60
|
type EventLiveCollection = Amity.LiveCollectionParams<Amity.QueryEvents>;
|
|
67
61
|
type EventLiveCollectionCache = Amity.LiveCollectionCache<Amity.InternalEvent['eventId'], Amity.QueryEvents>;
|
|
68
|
-
type QueryMyEvents = {
|
|
69
|
-
status: Amity.EventResponseStatus;
|
|
70
|
-
};
|
|
71
|
-
type MyEventLiveCollection = Amity.LiveCollectionParams<Amity.QueryMyEvents>;
|
|
72
|
-
type MyEventLiveCollectionCache = Amity.LiveCollectionCache<Amity.InternalEvent['eventId'], Amity.QueryMyEvents>;
|
|
73
62
|
type EventCreateOptions = Pick<Amity.Event, 'coverImageFileId' | 'title' | 'description' | 'type' | 'startTime' | 'endTime' | 'originType' | 'originId' | 'location' | 'externalUrl' | 'tags' | 'metadata'>;
|
|
74
63
|
type EventUpdateOptions = Pick<Amity.Event, 'coverImageFileId' | 'title' | 'description' | 'type' | 'startTime' | 'endTime' | 'location' | 'externalUrl' | 'tags' | 'metadata'>;
|
|
75
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,QAAQ,cAAc;CACvB;AAED,oBAAY,oBAAoB;IAC9B,SAAS,cAAc;IACvB,IAAI,SAAS;CACd;AAED,oBAAY,gBAAgB;IAC1B,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,SAAS,cAAc;CACxB;AAED,
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/event.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eventRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eventRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -209,12 +209,6 @@ exports.AmityEventStatus = void 0;
|
|
|
209
209
|
AmityEventStatus["Ended"] = "ended";
|
|
210
210
|
AmityEventStatus["Cancelled"] = "cancelled";
|
|
211
211
|
})(exports.AmityEventStatus || (exports.AmityEventStatus = {}));
|
|
212
|
-
exports.AmityEventResponseStatus = void 0;
|
|
213
|
-
(function (AmityEventResponseStatus) {
|
|
214
|
-
AmityEventResponseStatus["Going"] = "going";
|
|
215
|
-
AmityEventResponseStatus["Interested"] = "interested";
|
|
216
|
-
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
217
|
-
})(exports.AmityEventResponseStatus || (exports.AmityEventResponseStatus = {}));
|
|
218
212
|
|
|
219
213
|
function getVersion() {
|
|
220
214
|
try {
|
|
@@ -30713,7 +30707,7 @@ class EventLiveCollectionController extends LiveCollectionController {
|
|
|
30713
30707
|
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
30714
30708
|
.filter(isNonNullable)
|
|
30715
30709
|
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
30716
|
-
if (!this.shouldNotify(data) && origin ===
|
|
30710
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
30717
30711
|
return;
|
|
30718
30712
|
this.callback({
|
|
30719
30713
|
data,
|
|
@@ -30751,140 +30745,6 @@ const getEvents = (params, callback, config) => {
|
|
|
30751
30745
|
};
|
|
30752
30746
|
};
|
|
30753
30747
|
|
|
30754
|
-
class MyEventPaginationController extends PaginationController {
|
|
30755
|
-
async getRequest(queryParams, token) {
|
|
30756
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
30757
|
-
const options = token ? { token } : { limit };
|
|
30758
|
-
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
30759
|
-
return response;
|
|
30760
|
-
}
|
|
30761
|
-
}
|
|
30762
|
-
|
|
30763
|
-
class MyEventQueryStreamController extends QueryStreamController {
|
|
30764
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
30765
|
-
super(query, cacheKey);
|
|
30766
|
-
this.notifyChange = notifyChange;
|
|
30767
|
-
this.preparePayload = preparePayload;
|
|
30768
|
-
}
|
|
30769
|
-
async saveToMainDB(response) {
|
|
30770
|
-
const processedPayload = this.preparePayload(response);
|
|
30771
|
-
const client = getActiveClient();
|
|
30772
|
-
const cachedAt = client.cache && Date.now();
|
|
30773
|
-
if (client.cache)
|
|
30774
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
30775
|
-
}
|
|
30776
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
30777
|
-
var _a, _b;
|
|
30778
|
-
if (refresh) {
|
|
30779
|
-
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
30780
|
-
}
|
|
30781
|
-
else {
|
|
30782
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30783
|
-
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30784
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
30785
|
-
}
|
|
30786
|
-
}
|
|
30787
|
-
reactor(action) {
|
|
30788
|
-
return (event) => {
|
|
30789
|
-
var _a;
|
|
30790
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30791
|
-
if (!collection)
|
|
30792
|
-
return;
|
|
30793
|
-
if (action === EventActionsEnum.OnEventCreated) {
|
|
30794
|
-
const client = getActiveClient();
|
|
30795
|
-
if (client.userId !== event.userId)
|
|
30796
|
-
return;
|
|
30797
|
-
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
30798
|
-
}
|
|
30799
|
-
if (action === EventActionsEnum.OnEventDeleted) {
|
|
30800
|
-
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
30801
|
-
}
|
|
30802
|
-
pushToCache(this.cacheKey, collection);
|
|
30803
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
30804
|
-
};
|
|
30805
|
-
}
|
|
30806
|
-
subscribeRTE(createSubscriber) {
|
|
30807
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
30808
|
-
}
|
|
30809
|
-
}
|
|
30810
|
-
|
|
30811
|
-
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
30812
|
-
constructor(query, callback) {
|
|
30813
|
-
const queryStreamId = hash__default["default"](query);
|
|
30814
|
-
const cacheKey = ['event', 'collection', queryStreamId];
|
|
30815
|
-
const paginationController = new MyEventPaginationController(query);
|
|
30816
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
30817
|
-
this.query = query;
|
|
30818
|
-
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
30819
|
-
this.callback = callback.bind(this);
|
|
30820
|
-
this.loadPage({ initial: true });
|
|
30821
|
-
}
|
|
30822
|
-
setup() {
|
|
30823
|
-
var _a;
|
|
30824
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30825
|
-
if (!collection)
|
|
30826
|
-
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
30827
|
-
}
|
|
30828
|
-
async persistModel(queryPayload) {
|
|
30829
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
30830
|
-
}
|
|
30831
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
30832
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
30833
|
-
}
|
|
30834
|
-
startSubscription() {
|
|
30835
|
-
return this.queryStreamController.subscribeRTE([
|
|
30836
|
-
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
30837
|
-
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
30838
|
-
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
30839
|
-
]);
|
|
30840
|
-
}
|
|
30841
|
-
notifyChange({ origin, loading, error }) {
|
|
30842
|
-
var _a, _b;
|
|
30843
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30844
|
-
if (!collection)
|
|
30845
|
-
return;
|
|
30846
|
-
const data = ((_b = collection.data
|
|
30847
|
-
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
30848
|
-
.filter(isNonNullable)
|
|
30849
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
30850
|
-
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
30851
|
-
return;
|
|
30852
|
-
this.callback({
|
|
30853
|
-
data,
|
|
30854
|
-
error,
|
|
30855
|
-
loading,
|
|
30856
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
30857
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
30858
|
-
});
|
|
30859
|
-
}
|
|
30860
|
-
}
|
|
30861
|
-
|
|
30862
|
-
/**
|
|
30863
|
-
* Get my events
|
|
30864
|
-
*
|
|
30865
|
-
* @param params the query parameters
|
|
30866
|
-
* @param callback the callback to be called when the events are updated
|
|
30867
|
-
* @returns events
|
|
30868
|
-
*
|
|
30869
|
-
* @category Event Live Collection
|
|
30870
|
-
*
|
|
30871
|
-
*/
|
|
30872
|
-
const getMyEvents = (params, callback, config) => {
|
|
30873
|
-
const { log, cache } = getActiveClient();
|
|
30874
|
-
if (!cache)
|
|
30875
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
30876
|
-
const timestamp = Date.now();
|
|
30877
|
-
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
30878
|
-
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
30879
|
-
const disposers = myEventLiveCollection.startSubscription();
|
|
30880
|
-
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
30881
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
30882
|
-
return () => {
|
|
30883
|
-
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
30884
|
-
disposers.forEach(fn => fn());
|
|
30885
|
-
};
|
|
30886
|
-
};
|
|
30887
|
-
|
|
30888
30748
|
var index = /*#__PURE__*/Object.freeze({
|
|
30889
30749
|
__proto__: null,
|
|
30890
30750
|
createEvent: createEvent,
|
|
@@ -30894,8 +30754,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
30894
30754
|
onEventUpdated: onEventUpdated,
|
|
30895
30755
|
onEventDeleted: onEventDeleted,
|
|
30896
30756
|
getEvent: getEvent,
|
|
30897
|
-
getEvents: getEvents
|
|
30898
|
-
getMyEvents: getMyEvents
|
|
30757
|
+
getEvents: getEvents
|
|
30899
30758
|
});
|
|
30900
30759
|
|
|
30901
30760
|
exports.API_REGIONS = API_REGIONS;
|
package/dist/index.esm.js
CHANGED
|
@@ -194,12 +194,6 @@ var AmityEventStatus;
|
|
|
194
194
|
AmityEventStatus["Ended"] = "ended";
|
|
195
195
|
AmityEventStatus["Cancelled"] = "cancelled";
|
|
196
196
|
})(AmityEventStatus || (AmityEventStatus = {}));
|
|
197
|
-
var AmityEventResponseStatus;
|
|
198
|
-
(function (AmityEventResponseStatus) {
|
|
199
|
-
AmityEventResponseStatus["Going"] = "going";
|
|
200
|
-
AmityEventResponseStatus["Interested"] = "interested";
|
|
201
|
-
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
202
|
-
})(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
|
|
203
197
|
|
|
204
198
|
function getVersion() {
|
|
205
199
|
try {
|
|
@@ -46805,7 +46799,7 @@ class EventLiveCollectionController extends LiveCollectionController {
|
|
|
46805
46799
|
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
46806
46800
|
.filter(isNonNullable)
|
|
46807
46801
|
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
46808
|
-
if (!this.shouldNotify(data) && origin ===
|
|
46802
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
46809
46803
|
return;
|
|
46810
46804
|
this.callback({
|
|
46811
46805
|
data,
|
|
@@ -46843,140 +46837,6 @@ const getEvents = (params, callback, config) => {
|
|
|
46843
46837
|
};
|
|
46844
46838
|
};
|
|
46845
46839
|
|
|
46846
|
-
class MyEventPaginationController extends PaginationController {
|
|
46847
|
-
async getRequest(queryParams, token) {
|
|
46848
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
46849
|
-
const options = token ? { token } : { limit };
|
|
46850
|
-
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
46851
|
-
return response;
|
|
46852
|
-
}
|
|
46853
|
-
}
|
|
46854
|
-
|
|
46855
|
-
class MyEventQueryStreamController extends QueryStreamController {
|
|
46856
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
46857
|
-
super(query, cacheKey);
|
|
46858
|
-
this.notifyChange = notifyChange;
|
|
46859
|
-
this.preparePayload = preparePayload;
|
|
46860
|
-
}
|
|
46861
|
-
async saveToMainDB(response) {
|
|
46862
|
-
const processedPayload = this.preparePayload(response);
|
|
46863
|
-
const client = getActiveClient();
|
|
46864
|
-
const cachedAt = client.cache && Date.now();
|
|
46865
|
-
if (client.cache)
|
|
46866
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
46867
|
-
}
|
|
46868
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
46869
|
-
var _a, _b;
|
|
46870
|
-
if (refresh) {
|
|
46871
|
-
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
46872
|
-
}
|
|
46873
|
-
else {
|
|
46874
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46875
|
-
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
46876
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
46877
|
-
}
|
|
46878
|
-
}
|
|
46879
|
-
reactor(action) {
|
|
46880
|
-
return (event) => {
|
|
46881
|
-
var _a;
|
|
46882
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46883
|
-
if (!collection)
|
|
46884
|
-
return;
|
|
46885
|
-
if (action === EventActionsEnum.OnEventCreated) {
|
|
46886
|
-
const client = getActiveClient();
|
|
46887
|
-
if (client.userId !== event.userId)
|
|
46888
|
-
return;
|
|
46889
|
-
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
46890
|
-
}
|
|
46891
|
-
if (action === EventActionsEnum.OnEventDeleted) {
|
|
46892
|
-
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
46893
|
-
}
|
|
46894
|
-
pushToCache(this.cacheKey, collection);
|
|
46895
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
46896
|
-
};
|
|
46897
|
-
}
|
|
46898
|
-
subscribeRTE(createSubscriber) {
|
|
46899
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
46900
|
-
}
|
|
46901
|
-
}
|
|
46902
|
-
|
|
46903
|
-
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
46904
|
-
constructor(query, callback) {
|
|
46905
|
-
const queryStreamId = hash(query);
|
|
46906
|
-
const cacheKey = ['event', 'collection', queryStreamId];
|
|
46907
|
-
const paginationController = new MyEventPaginationController(query);
|
|
46908
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
46909
|
-
this.query = query;
|
|
46910
|
-
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
46911
|
-
this.callback = callback.bind(this);
|
|
46912
|
-
this.loadPage({ initial: true });
|
|
46913
|
-
}
|
|
46914
|
-
setup() {
|
|
46915
|
-
var _a;
|
|
46916
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46917
|
-
if (!collection)
|
|
46918
|
-
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
46919
|
-
}
|
|
46920
|
-
async persistModel(queryPayload) {
|
|
46921
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
46922
|
-
}
|
|
46923
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
46924
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
46925
|
-
}
|
|
46926
|
-
startSubscription() {
|
|
46927
|
-
return this.queryStreamController.subscribeRTE([
|
|
46928
|
-
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
46929
|
-
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
46930
|
-
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
46931
|
-
]);
|
|
46932
|
-
}
|
|
46933
|
-
notifyChange({ origin, loading, error }) {
|
|
46934
|
-
var _a, _b;
|
|
46935
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46936
|
-
if (!collection)
|
|
46937
|
-
return;
|
|
46938
|
-
const data = ((_b = collection.data
|
|
46939
|
-
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
46940
|
-
.filter(isNonNullable)
|
|
46941
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
46942
|
-
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
46943
|
-
return;
|
|
46944
|
-
this.callback({
|
|
46945
|
-
data,
|
|
46946
|
-
error,
|
|
46947
|
-
loading,
|
|
46948
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
46949
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
46950
|
-
});
|
|
46951
|
-
}
|
|
46952
|
-
}
|
|
46953
|
-
|
|
46954
|
-
/**
|
|
46955
|
-
* Get my events
|
|
46956
|
-
*
|
|
46957
|
-
* @param params the query parameters
|
|
46958
|
-
* @param callback the callback to be called when the events are updated
|
|
46959
|
-
* @returns events
|
|
46960
|
-
*
|
|
46961
|
-
* @category Event Live Collection
|
|
46962
|
-
*
|
|
46963
|
-
*/
|
|
46964
|
-
const getMyEvents = (params, callback, config) => {
|
|
46965
|
-
const { log, cache } = getActiveClient();
|
|
46966
|
-
if (!cache)
|
|
46967
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
46968
|
-
const timestamp = Date.now();
|
|
46969
|
-
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
46970
|
-
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
46971
|
-
const disposers = myEventLiveCollection.startSubscription();
|
|
46972
|
-
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
46973
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
46974
|
-
return () => {
|
|
46975
|
-
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
46976
|
-
disposers.forEach(fn => fn());
|
|
46977
|
-
};
|
|
46978
|
-
};
|
|
46979
|
-
|
|
46980
46840
|
var index = /*#__PURE__*/Object.freeze({
|
|
46981
46841
|
__proto__: null,
|
|
46982
46842
|
createEvent: createEvent,
|
|
@@ -46986,8 +46846,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
46986
46846
|
onEventUpdated: onEventUpdated,
|
|
46987
46847
|
onEventDeleted: onEventDeleted,
|
|
46988
46848
|
getEvent: getEvent,
|
|
46989
|
-
getEvents: getEvents
|
|
46990
|
-
getMyEvents: getMyEvents
|
|
46849
|
+
getEvents: getEvents
|
|
46991
46850
|
});
|
|
46992
46851
|
|
|
46993
|
-
export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType,
|
|
46852
|
+
export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, 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 };
|