@amityco/ts-sdk-react-native 6.26.4-2eb3673.0 → 6.27.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/.env +26 -26
- package/dist/@types/core/model.d.ts +5 -5
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/domains/ad.d.ts +14 -2
- package/dist/@types/domains/ad.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +4 -1
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/adRepository/api/getNetworkAds.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +2 -2
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +11 -5
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
- package/dist/index.cjs.js +284 -265
- package/dist/index.esm.js +284 -265
- package/dist/index.umd.js +2 -2
- package/dist/messageRepository/api/createMessage.d.ts +7 -25
- package/dist/messageRepository/api/createMessage.d.ts.map +1 -1
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts +4 -4
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/postRepository/observers/getPost.d.ts.map +1 -1
- package/dist/utils/linkedObject/adLinkedObject.d.ts +1 -1
- package/dist/utils/linkedObject/adLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/model.ts +5 -5
- package/src/@types/domains/ad.ts +17 -6
- package/src/@types/domains/message.ts +6 -1
- package/src/adRepository/api/getNetworkAds.ts +22 -8
- package/src/analytic/service/analytic/AnalyticsEngine.ts +2 -2
- package/src/analytic/service/analytic/AnalyticsEventCapturer.ts +45 -27
- package/src/core/model/idResolvers.ts +1 -1
- package/src/messageRepository/api/createMessage.ts +83 -98
- package/src/messageRepository/events/onMessageCreated.ts +12 -6
- package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +26 -24
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +3 -2
- package/src/messageRepository/observers/observeMessages.ts +3 -3
- package/src/messageRepository/utils/prepareMessagePayload.ts +1 -1
- package/src/postRepository/observers/getPost.ts +8 -1
- package/src/utils/linkedObject/adLinkedObject.ts +11 -11
package/dist/index.esm.js
CHANGED
|
@@ -84,8 +84,8 @@ const PostContentType = Object.freeze({
|
|
|
84
84
|
|
|
85
85
|
function getVersion() {
|
|
86
86
|
try {
|
|
87
|
-
// the string ''v6.
|
|
88
|
-
return 'v6.
|
|
87
|
+
// the string ''v6.27.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
88
|
+
return 'v6.27.0-esm';
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
91
91
|
return '__dev__';
|
|
@@ -493,7 +493,7 @@ const idResolvers = {
|
|
|
493
493
|
channel: ({ channelInternalId }) => channelInternalId,
|
|
494
494
|
subChannel: ({ subChannelId }) => subChannelId,
|
|
495
495
|
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
496
|
-
message: ({ messageId }) => messageId,
|
|
496
|
+
message: ({ messageId, referenceId }) => referenceId !== null && referenceId !== void 0 ? referenceId : messageId,
|
|
497
497
|
messagePreviewChannel: ({ channelId }) => `${channelId}`,
|
|
498
498
|
messagePreviewSubChannel: ({ subChannelId }) => `${subChannelId}`,
|
|
499
499
|
channelUnreadInfo: ({ channelId }) => channelId,
|
|
@@ -20970,12 +20970,12 @@ class AnalyticsEventCapturer {
|
|
|
20970
20970
|
this._throttleStoryTimer = undefined;
|
|
20971
20971
|
this._bufferNewSeenStoryReferenceIds = [];
|
|
20972
20972
|
}
|
|
20973
|
-
isAbleToEnqueue({
|
|
20973
|
+
isAbleToEnqueue({ uniqueId, expireTime, isHighPriority = false, }) {
|
|
20974
20974
|
const now = new Date();
|
|
20975
20975
|
const getRecentViewedDate = () => {
|
|
20976
20976
|
if (isHighPriority)
|
|
20977
|
-
return this._recentHighPriorityViewed[
|
|
20978
|
-
return this._recentViewed[
|
|
20977
|
+
return this._recentHighPriorityViewed[uniqueId];
|
|
20978
|
+
return this._recentViewed[uniqueId];
|
|
20979
20979
|
};
|
|
20980
20980
|
const recentViewedDate = getRecentViewedDate() || new Date(DAY * -1);
|
|
20981
20981
|
const timeDiff = now.getTime() - recentViewedDate.getTime();
|
|
@@ -20985,8 +20985,8 @@ class AnalyticsEventCapturer {
|
|
|
20985
20985
|
}
|
|
20986
20986
|
return true;
|
|
20987
20987
|
}
|
|
20988
|
-
markAs(
|
|
20989
|
-
if (!this.isAbleToEnqueue({
|
|
20988
|
+
markAs({ uniqueId, contentId, contentType, activityType, metadata, }) {
|
|
20989
|
+
if (!this.isAbleToEnqueue({ uniqueId, expireTime: this._expireTime }))
|
|
20990
20990
|
return;
|
|
20991
20991
|
const now = new Date();
|
|
20992
20992
|
const currentData = { event: [] };
|
|
@@ -21000,7 +21000,7 @@ class AnalyticsEventCapturer {
|
|
|
21000
21000
|
currentData.event.shift();
|
|
21001
21001
|
}
|
|
21002
21002
|
const analyticItem = {
|
|
21003
|
-
contentId
|
|
21003
|
+
contentId,
|
|
21004
21004
|
contentType,
|
|
21005
21005
|
activityType,
|
|
21006
21006
|
timestamp: now.toISOString(),
|
|
@@ -21010,10 +21010,15 @@ class AnalyticsEventCapturer {
|
|
|
21010
21010
|
}
|
|
21011
21011
|
currentData.event.push(analyticItem);
|
|
21012
21012
|
upsertInCache(ANALYTIC_CACHE_KEY, currentData);
|
|
21013
|
-
this._recentViewed[
|
|
21013
|
+
this._recentViewed[uniqueId] = now;
|
|
21014
21014
|
}
|
|
21015
21015
|
markPostAsViewed(postId) {
|
|
21016
|
-
this.markAs(
|
|
21016
|
+
this.markAs({
|
|
21017
|
+
uniqueId: postId,
|
|
21018
|
+
contentId: postId,
|
|
21019
|
+
contentType: "post" /* Amity.AnalyticEventContentType.Post */,
|
|
21020
|
+
activityType: "view" /* Amity.AnalyticEventActivityType.View */,
|
|
21021
|
+
});
|
|
21017
21022
|
}
|
|
21018
21023
|
markStory(story, activityType) {
|
|
21019
21024
|
if (!story.expiresAt)
|
|
@@ -21021,7 +21026,7 @@ class AnalyticsEventCapturer {
|
|
|
21021
21026
|
const now = new Date();
|
|
21022
21027
|
const expireTime = new Date(story.expiresAt);
|
|
21023
21028
|
if (!this.isAbleToEnqueue({
|
|
21024
|
-
|
|
21029
|
+
uniqueId: story.storyId,
|
|
21025
21030
|
expireTime: expireTime.getTime(),
|
|
21026
21031
|
isHighPriority: true,
|
|
21027
21032
|
}))
|
|
@@ -21087,13 +21092,27 @@ class AnalyticsEventCapturer {
|
|
|
21087
21092
|
const metadata = {
|
|
21088
21093
|
placement,
|
|
21089
21094
|
};
|
|
21090
|
-
|
|
21095
|
+
const activityType = "view" /* Amity.AnalyticEventActivityType.View */;
|
|
21096
|
+
this.markAs({
|
|
21097
|
+
uniqueId: `${ad.adId}.${activityType}.${placement}`,
|
|
21098
|
+
contentId: ad.adId,
|
|
21099
|
+
contentType: "ad" /* Amity.AnalyticEventContentType.Ad */,
|
|
21100
|
+
activityType,
|
|
21101
|
+
metadata,
|
|
21102
|
+
});
|
|
21091
21103
|
}
|
|
21092
21104
|
markAdAsClicked(ad, placement) {
|
|
21093
21105
|
const metadata = {
|
|
21094
21106
|
placement,
|
|
21095
21107
|
};
|
|
21096
|
-
|
|
21108
|
+
const activityType = "linkClicked" /* Amity.AnalyticEventActivityType.Click */;
|
|
21109
|
+
this.markAs({
|
|
21110
|
+
uniqueId: `${ad.adId}.${activityType}.${placement}`,
|
|
21111
|
+
contentId: ad.adId,
|
|
21112
|
+
contentType: "ad" /* Amity.AnalyticEventContentType.Ad */,
|
|
21113
|
+
activityType,
|
|
21114
|
+
metadata,
|
|
21115
|
+
});
|
|
21097
21116
|
}
|
|
21098
21117
|
}
|
|
21099
21118
|
|
|
@@ -21860,20 +21879,17 @@ const channelLinkedObject = (channel) => {
|
|
|
21860
21879
|
return Object.assign(Object.assign({}, channel), { markAsRead: () => markAsRead(channel.channelInternalId) });
|
|
21861
21880
|
};
|
|
21862
21881
|
|
|
21863
|
-
// import AnalyticsEngine from '~/analytic/service/analytic/AnalyticsEngine';
|
|
21864
21882
|
const adLinkedObject = (ad) => {
|
|
21865
|
-
|
|
21883
|
+
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
21866
21884
|
const { image9_16: image916, image1_1: image11 } = ad, restAds = __rest(ad, ["image9_16", "image1_1"]);
|
|
21867
|
-
return Object.assign(Object.assign({}, restAds), {
|
|
21868
|
-
|
|
21869
|
-
|
|
21870
|
-
|
|
21871
|
-
|
|
21872
|
-
|
|
21873
|
-
|
|
21874
|
-
|
|
21875
|
-
// },
|
|
21876
|
-
get advertiser() {
|
|
21885
|
+
return Object.assign(Object.assign({}, restAds), { analytics: {
|
|
21886
|
+
markAsSeen: (placement) => {
|
|
21887
|
+
analyticsEngineInstance.markAdAsViewed(ad, placement);
|
|
21888
|
+
},
|
|
21889
|
+
markLinkAsClicked: (placement) => {
|
|
21890
|
+
analyticsEngineInstance.markAdAsClicked(ad, placement);
|
|
21891
|
+
},
|
|
21892
|
+
}, get advertiser() {
|
|
21877
21893
|
var _a, _b;
|
|
21878
21894
|
const advertiserData = (_a = pullFromCache([
|
|
21879
21895
|
'advertiser',
|
|
@@ -22761,7 +22777,7 @@ function convertFromRaw(message, reactors, event) {
|
|
|
22761
22777
|
*
|
|
22762
22778
|
* Check git blame for previous iteration
|
|
22763
22779
|
*/
|
|
22764
|
-
myReactions: myReactions || ((_a = cache === null || cache === void 0 ? void 0 : cache.data.myReactions) !== null && _a !== void 0 ? _a : []), reactionsCount: reactionCount, subChannelId: messageFeedId, uniqueId: cache ? cache.data.uniqueId : messageId, referenceId });
|
|
22780
|
+
myReactions: myReactions || ((_a = cache === null || cache === void 0 ? void 0 : cache.data.myReactions) !== null && _a !== void 0 ? _a : []), reactionsCount: reactionCount, subChannelId: messageFeedId, uniqueId: cache ? cache.data.uniqueId : messageId, referenceId, syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
22765
22781
|
if (mentionedUsers) {
|
|
22766
22782
|
out.mentionees = mentionedUsers.map(mention => {
|
|
22767
22783
|
if (mention.type === 'channel') {
|
|
@@ -24591,9 +24607,12 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
24591
24607
|
const onMessageCreatedLocal = (callback) => {
|
|
24592
24608
|
const client = getActiveClient();
|
|
24593
24609
|
const disposers = [
|
|
24594
|
-
createEventSubscriber(client, 'message/onMessageCreated', 'local.message.created',
|
|
24595
|
-
|
|
24596
|
-
|
|
24610
|
+
createEventSubscriber(client, 'message/onMessageCreated', 'local.message.created', async (payload) => {
|
|
24611
|
+
ingestInCache(payload);
|
|
24612
|
+
return payload.messages.forEach(message => {
|
|
24613
|
+
callback(message);
|
|
24614
|
+
});
|
|
24615
|
+
}),
|
|
24597
24616
|
];
|
|
24598
24617
|
return () => {
|
|
24599
24618
|
disposers.forEach(fn => fn());
|
|
@@ -30676,9 +30695,40 @@ getMessages$1.locally = (messageIds) => {
|
|
|
30676
30695
|
const getLocalId = () => `LOCAL_${uuid()}`;
|
|
30677
30696
|
// FIXME: temp solution
|
|
30678
30697
|
let uniqueId;
|
|
30679
|
-
|
|
30680
|
-
|
|
30681
|
-
|
|
30698
|
+
const createMessageOptimistic = (bundle) => {
|
|
30699
|
+
var _a, _b;
|
|
30700
|
+
const client = getActiveClient();
|
|
30701
|
+
if (!client.cache)
|
|
30702
|
+
return;
|
|
30703
|
+
/*
|
|
30704
|
+
* When creating messages optimistically a messageId needs to be added by the
|
|
30705
|
+
* client, created a new variable to allow backward compatibility of API
|
|
30706
|
+
*
|
|
30707
|
+
* Updated to handle client requirement to add messageId while uploading
|
|
30708
|
+
* a message with image.
|
|
30709
|
+
* Temporary!
|
|
30710
|
+
*/
|
|
30711
|
+
uniqueId = bundle.referenceId || getLocalId();
|
|
30712
|
+
const bundleWithMessageId = Object.assign({ messageId: uniqueId, uniqueId }, bundle);
|
|
30713
|
+
client.log('message/createMessage.optimistically', bundleWithMessageId);
|
|
30714
|
+
const subChannel = pullFromCache(['subChannel', 'get', bundle.subChannelId]);
|
|
30715
|
+
if (subChannel) {
|
|
30716
|
+
upsertInCache(['subChannel', 'get', bundle.subChannelId], Object.assign(Object.assign({}, subChannel.data), { messageCount: subChannel.data.messageCount + 1 }));
|
|
30717
|
+
if (subChannel.data.channelId === subChannel.data.subChannelId) {
|
|
30718
|
+
const channel = pullFromCache(['channel', 'get', subChannel.data.channelId]);
|
|
30719
|
+
if (channel === null || channel === void 0 ? void 0 : channel.data) {
|
|
30720
|
+
upsertInCache(['channel', 'get', subChannel.data.channelId], Object.assign(Object.assign({}, channel.data), { messageCount: ((_a = channel.data.messageCount) !== null && _a !== void 0 ? _a : 0) + 1 }));
|
|
30721
|
+
}
|
|
30722
|
+
}
|
|
30723
|
+
}
|
|
30724
|
+
// as reused to update created and updated time, which should be the same
|
|
30725
|
+
const createdTime = new Date().toISOString();
|
|
30726
|
+
const message = Object.assign({ creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_b = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _b !== void 0 ? _b : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime, syncState: "syncing" /* Amity.SyncState.Syncing */, isDeleted: false }, bundleWithMessageId);
|
|
30727
|
+
const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
|
|
30728
|
+
pushToCache(['message', 'get', message.messageId], message, { cachedAt });
|
|
30729
|
+
fireEvent('local.message.created', { messages: [message] });
|
|
30730
|
+
return message;
|
|
30731
|
+
};
|
|
30682
30732
|
/**
|
|
30683
30733
|
* ```js
|
|
30684
30734
|
* import { createMessage, createQuery, runQuery } from '@amityco/ts-sdk-react-native'
|
|
@@ -30704,75 +30754,31 @@ let uniqueId;
|
|
|
30704
30754
|
const createMessage = async (bundle) => {
|
|
30705
30755
|
const client = getActiveClient();
|
|
30706
30756
|
client.log('message/createMessage', bundle);
|
|
30757
|
+
const optimisticData = createMessageOptimistic(bundle);
|
|
30707
30758
|
const referenceId = bundle.referenceId || uniqueId || getLocalId();
|
|
30708
30759
|
uniqueId = undefined;
|
|
30709
|
-
|
|
30710
|
-
|
|
30711
|
-
|
|
30712
|
-
|
|
30713
|
-
|
|
30714
|
-
|
|
30715
|
-
|
|
30716
|
-
}
|
|
30717
|
-
fireEvent('local.message.created', { messages });
|
|
30718
|
-
return {
|
|
30719
|
-
data: LinkedObject.message(messages[0]),
|
|
30720
|
-
cachedAt,
|
|
30721
|
-
};
|
|
30722
|
-
};
|
|
30723
|
-
/**
|
|
30724
|
-
* ```js
|
|
30725
|
-
* import { createMessage } from '@amityco/ts-sdk-react-native'
|
|
30726
|
-
*
|
|
30727
|
-
* const created = createMessage.optimistically({
|
|
30728
|
-
* channelId: 'foobar',
|
|
30729
|
-
* data: { text: 'hello world' }
|
|
30730
|
-
* })
|
|
30731
|
-
* ```
|
|
30732
|
-
*
|
|
30733
|
-
* Creates an {@link Amity.Message} in cache
|
|
30734
|
-
*
|
|
30735
|
-
* @param bundle The data necessary to create a new {@link Amity.Message}
|
|
30736
|
-
* @returns The newly created {@link Amity.Message}
|
|
30737
|
-
*
|
|
30738
|
-
* @category Message API
|
|
30739
|
-
*/
|
|
30740
|
-
createMessage.optimistically = (_a) => {
|
|
30741
|
-
var _b, _c;
|
|
30742
|
-
var { referenceId } = _a, bundle = __rest(_a, ["referenceId"]);
|
|
30743
|
-
const client = getActiveClient();
|
|
30744
|
-
if (!client.cache)
|
|
30745
|
-
return;
|
|
30746
|
-
/*
|
|
30747
|
-
* when creating messages optimistically a messageId needs to be added by the
|
|
30748
|
-
* client, created a new variable so as to allow backward compatibility of API
|
|
30749
|
-
*
|
|
30750
|
-
* Updated to handle client requirement to add messageId while uploading
|
|
30751
|
-
* message with image. Temporary!
|
|
30752
|
-
*/
|
|
30753
|
-
uniqueId = referenceId || getLocalId();
|
|
30754
|
-
const bundleWithMessageId = Object.assign({ messageId: uniqueId, uniqueId }, bundle);
|
|
30755
|
-
client.log('message/createMessage.optimistically', bundleWithMessageId);
|
|
30756
|
-
const subChannel = pullFromCache(['subChannel', 'get', bundle.subChannelId]);
|
|
30757
|
-
if (subChannel) {
|
|
30758
|
-
upsertInCache(['subChannel', 'get', bundle.subChannelId], Object.assign(Object.assign({}, subChannel.data), { messageCount: subChannel.data.messageCount + 1 }));
|
|
30759
|
-
if (subChannel.data.channelId === subChannel.data.subChannelId) {
|
|
30760
|
-
const channel = pullFromCache(['channel', 'get', subChannel.data.channelId]);
|
|
30761
|
-
if (channel === null || channel === void 0 ? void 0 : channel.data) {
|
|
30762
|
-
upsertInCache(['channel', 'get', subChannel.data.channelId], Object.assign(Object.assign({}, channel.data), { messageCount: ((_b = channel.data.messageCount) !== null && _b !== void 0 ? _b : 0) + 1 }));
|
|
30763
|
-
}
|
|
30760
|
+
try {
|
|
30761
|
+
const { data: payload } = await client.http.post('/api/v5/messages', Object.assign(Object.assign({}, convertParams(bundle)), { referenceId }));
|
|
30762
|
+
const data = await prepareMessagePayload(payload);
|
|
30763
|
+
const { messages } = data;
|
|
30764
|
+
const cachedAt = client.cache && Date.now();
|
|
30765
|
+
if (client.cache) {
|
|
30766
|
+
ingestInCache(data, { cachedAt });
|
|
30764
30767
|
}
|
|
30768
|
+
fireEvent('local.message.created', {
|
|
30769
|
+
messages: [Object.assign(Object.assign({}, messages[0]), { syncState: "synced" /* Amity.SyncState.Synced */ })],
|
|
30770
|
+
});
|
|
30771
|
+
return {
|
|
30772
|
+
data: LinkedObject.message(messages[0]),
|
|
30773
|
+
cachedAt,
|
|
30774
|
+
};
|
|
30775
|
+
}
|
|
30776
|
+
catch (e) {
|
|
30777
|
+
fireEvent('local.message.created', {
|
|
30778
|
+
messages: [Object.assign(Object.assign({}, optimisticData), { syncState: "error" /* Amity.SyncState.Error */ })],
|
|
30779
|
+
});
|
|
30780
|
+
throw e;
|
|
30765
30781
|
}
|
|
30766
|
-
// as reused to update created and updated time, which should be the same
|
|
30767
|
-
const createdTime = new Date().toISOString();
|
|
30768
|
-
const message = Object.assign({ creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_c = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _c !== void 0 ? _c : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime }, bundleWithMessageId);
|
|
30769
|
-
const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
|
|
30770
|
-
pushToCache(['message', 'get', message.messageId], message, { cachedAt });
|
|
30771
|
-
fireEvent('local.message.created', { messages: [message] });
|
|
30772
|
-
return {
|
|
30773
|
-
cachedAt,
|
|
30774
|
-
data: LinkedObject.message(message),
|
|
30775
|
-
};
|
|
30776
30782
|
};
|
|
30777
30783
|
/* end_public_function */
|
|
30778
30784
|
|
|
@@ -31485,67 +31491,106 @@ const getMessage$1 = (messageId, callback) => {
|
|
|
31485
31491
|
};
|
|
31486
31492
|
/* end_public_function */
|
|
31487
31493
|
|
|
31488
|
-
class
|
|
31494
|
+
class PaginationNoPageController {
|
|
31489
31495
|
constructor(queryParams) {
|
|
31490
31496
|
const { http } = getActiveClient();
|
|
31491
31497
|
this.queryParams = queryParams;
|
|
31492
31498
|
this.http = http;
|
|
31493
31499
|
}
|
|
31494
|
-
|
|
31495
|
-
|
|
31500
|
+
async onFetch() {
|
|
31501
|
+
const queryResponse = await this.getRequest(this.queryParams);
|
|
31502
|
+
return queryResponse;
|
|
31496
31503
|
}
|
|
31497
|
-
|
|
31498
|
-
|
|
31504
|
+
}
|
|
31505
|
+
|
|
31506
|
+
class LiveCollectionController {
|
|
31507
|
+
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
31508
|
+
this.paginationController = paginationController;
|
|
31509
|
+
this.queryStreamId = queryStreamId;
|
|
31510
|
+
this.cacheKey = cacheKey;
|
|
31511
|
+
this.callback = callback;
|
|
31499
31512
|
}
|
|
31500
|
-
|
|
31501
|
-
|
|
31513
|
+
async refresh() {
|
|
31514
|
+
try {
|
|
31515
|
+
let result;
|
|
31516
|
+
if (this.paginationController instanceof PaginationNoPageController) {
|
|
31517
|
+
result = await this.paginationController.onFetch();
|
|
31518
|
+
}
|
|
31519
|
+
else {
|
|
31520
|
+
result = await this.paginationController.loadFirstPage();
|
|
31521
|
+
}
|
|
31522
|
+
if (!result)
|
|
31523
|
+
return;
|
|
31524
|
+
await this.persistModel(result);
|
|
31525
|
+
this.persistQueryStream({
|
|
31526
|
+
response: result,
|
|
31527
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
31528
|
+
refresh: true,
|
|
31529
|
+
});
|
|
31530
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
31531
|
+
}
|
|
31532
|
+
catch (e) {
|
|
31533
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
31534
|
+
}
|
|
31502
31535
|
}
|
|
31503
|
-
|
|
31504
|
-
|
|
31505
|
-
|
|
31506
|
-
|
|
31507
|
-
|
|
31508
|
-
|
|
31509
|
-
|
|
31510
|
-
|
|
31511
|
-
|
|
31512
|
-
if (direction ===
|
|
31513
|
-
|
|
31514
|
-
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
31515
|
-
if (direction === 'first') {
|
|
31516
|
-
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
31517
|
-
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
31536
|
+
loadPage({ initial = false, direction = "next" /* Amity.LiveCollectionPageDirection.NEXT */, }) {
|
|
31537
|
+
this.setup();
|
|
31538
|
+
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
31539
|
+
if (initial) {
|
|
31540
|
+
this.refresh();
|
|
31541
|
+
}
|
|
31542
|
+
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
31543
|
+
this.loadPrevPage();
|
|
31544
|
+
}
|
|
31545
|
+
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
31546
|
+
this.loadNextPage();
|
|
31518
31547
|
}
|
|
31519
|
-
if (direction === 'prev')
|
|
31520
|
-
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
31521
|
-
if (direction === 'next')
|
|
31522
|
-
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
31523
|
-
return queryResponse;
|
|
31524
31548
|
}
|
|
31525
|
-
|
|
31526
|
-
|
|
31549
|
+
async loadNextPage() {
|
|
31550
|
+
try {
|
|
31551
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
31552
|
+
return;
|
|
31553
|
+
const result = await this.paginationController.loadNextPage();
|
|
31554
|
+
if (!result)
|
|
31555
|
+
return;
|
|
31556
|
+
await this.persistModel(result);
|
|
31557
|
+
this.persistQueryStream({
|
|
31558
|
+
response: result,
|
|
31559
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
31560
|
+
});
|
|
31561
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
31562
|
+
}
|
|
31563
|
+
catch (e) {
|
|
31564
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
31565
|
+
}
|
|
31527
31566
|
}
|
|
31528
|
-
|
|
31529
|
-
|
|
31567
|
+
async loadPrevPage() {
|
|
31568
|
+
try {
|
|
31569
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
31570
|
+
return;
|
|
31571
|
+
const result = await this.paginationController.loadPreviousPage();
|
|
31572
|
+
if (!result)
|
|
31573
|
+
return;
|
|
31574
|
+
await this.persistModel(result);
|
|
31575
|
+
this.persistQueryStream({
|
|
31576
|
+
response: result,
|
|
31577
|
+
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
31578
|
+
});
|
|
31579
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
31580
|
+
}
|
|
31581
|
+
catch (e) {
|
|
31582
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
31583
|
+
}
|
|
31530
31584
|
}
|
|
31531
|
-
|
|
31532
|
-
|
|
31533
|
-
|
|
31534
|
-
|
|
31535
|
-
|
|
31536
|
-
|
|
31537
|
-
|
|
31538
|
-
|
|
31539
|
-
|
|
31540
|
-
const processedQueryParams = convertQueryParams$1(queryParams);
|
|
31541
|
-
const { data: queryResponse } = await this.http.get(`/api/v5/messages`, {
|
|
31542
|
-
params: Object.assign(Object.assign({}, processedQueryParams), { options: token
|
|
31543
|
-
? {
|
|
31544
|
-
token,
|
|
31545
|
-
}
|
|
31546
|
-
: Object.assign({}, processedQueryParams.options) }),
|
|
31547
|
-
});
|
|
31548
|
-
return queryResponse;
|
|
31585
|
+
shouldNotify(data) {
|
|
31586
|
+
const newData = data.map(convertGetterPropsToStatic).map(removeFunctionProperties);
|
|
31587
|
+
if (isEqual(this.snapshot, newData))
|
|
31588
|
+
return false;
|
|
31589
|
+
this.snapshot = newData;
|
|
31590
|
+
return true;
|
|
31591
|
+
}
|
|
31592
|
+
getCacheKey() {
|
|
31593
|
+
return this.cacheKey;
|
|
31549
31594
|
}
|
|
31550
31595
|
}
|
|
31551
31596
|
|
|
@@ -31593,6 +31638,7 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
31593
31638
|
var _a, _b, _c, _d, _e;
|
|
31594
31639
|
if (action === 'onCreate') {
|
|
31595
31640
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31641
|
+
const { referenceId } = payload;
|
|
31596
31642
|
if (!collection)
|
|
31597
31643
|
return;
|
|
31598
31644
|
if (this.query.subChannelId !== (payload === null || payload === void 0 ? void 0 : payload.subChannelId) || !collection)
|
|
@@ -31622,10 +31668,10 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
31622
31668
|
return;
|
|
31623
31669
|
if ((!this.query.sortBy || this.query.sortBy === 'segmentDesc') &&
|
|
31624
31670
|
!this.paginationController.getPrevToken()) {
|
|
31625
|
-
collection.data = [...new Set([payload.messageId, ...collection.data])];
|
|
31671
|
+
collection.data = [...new Set([referenceId !== null && referenceId !== void 0 ? referenceId : payload.messageId, ...collection.data])];
|
|
31626
31672
|
}
|
|
31627
31673
|
if (this.query.sortBy === 'segmentAsc' && !this.paginationController.getNextToken()) {
|
|
31628
|
-
collection.data = [...new Set([...collection.data, payload.messageId])];
|
|
31674
|
+
collection.data = [...new Set([...collection.data, referenceId !== null && referenceId !== void 0 ? referenceId : payload.messageId])];
|
|
31629
31675
|
}
|
|
31630
31676
|
pushToCache(this.cacheKey, collection);
|
|
31631
31677
|
}
|
|
@@ -31637,106 +31683,67 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
31637
31683
|
}
|
|
31638
31684
|
}
|
|
31639
31685
|
|
|
31640
|
-
class
|
|
31686
|
+
class PaginationController {
|
|
31641
31687
|
constructor(queryParams) {
|
|
31642
31688
|
const { http } = getActiveClient();
|
|
31643
31689
|
this.queryParams = queryParams;
|
|
31644
31690
|
this.http = http;
|
|
31645
31691
|
}
|
|
31646
|
-
|
|
31647
|
-
|
|
31648
|
-
return queryResponse;
|
|
31649
|
-
}
|
|
31650
|
-
}
|
|
31651
|
-
|
|
31652
|
-
class LiveCollectionController {
|
|
31653
|
-
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
31654
|
-
this.paginationController = paginationController;
|
|
31655
|
-
this.queryStreamId = queryStreamId;
|
|
31656
|
-
this.cacheKey = cacheKey;
|
|
31657
|
-
this.callback = callback;
|
|
31692
|
+
loadFirstPage() {
|
|
31693
|
+
return this.onFetch("first" /* Amity.LiveCollectionPageDirection.FIRST */);
|
|
31658
31694
|
}
|
|
31659
|
-
|
|
31660
|
-
|
|
31661
|
-
let result;
|
|
31662
|
-
if (this.paginationController instanceof PaginationNoPageController) {
|
|
31663
|
-
result = await this.paginationController.onFetch();
|
|
31664
|
-
}
|
|
31665
|
-
else {
|
|
31666
|
-
result = await this.paginationController.loadFirstPage();
|
|
31667
|
-
}
|
|
31668
|
-
if (!result)
|
|
31669
|
-
return;
|
|
31670
|
-
await this.persistModel(result);
|
|
31671
|
-
this.persistQueryStream({
|
|
31672
|
-
response: result,
|
|
31673
|
-
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
31674
|
-
refresh: true,
|
|
31675
|
-
});
|
|
31676
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
31677
|
-
}
|
|
31678
|
-
catch (e) {
|
|
31679
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
31680
|
-
}
|
|
31695
|
+
loadNextPage() {
|
|
31696
|
+
return this.onFetch("next" /* Amity.LiveCollectionPageDirection.NEXT */);
|
|
31681
31697
|
}
|
|
31682
|
-
|
|
31683
|
-
this.
|
|
31684
|
-
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
31685
|
-
if (initial) {
|
|
31686
|
-
this.refresh();
|
|
31687
|
-
}
|
|
31688
|
-
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
31689
|
-
this.loadPrevPage();
|
|
31690
|
-
}
|
|
31691
|
-
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
31692
|
-
this.loadNextPage();
|
|
31693
|
-
}
|
|
31698
|
+
loadPreviousPage() {
|
|
31699
|
+
return this.onFetch("prev" /* Amity.LiveCollectionPageDirection.PREV */);
|
|
31694
31700
|
}
|
|
31695
|
-
async
|
|
31696
|
-
|
|
31697
|
-
|
|
31698
|
-
|
|
31699
|
-
|
|
31700
|
-
|
|
31701
|
-
|
|
31702
|
-
|
|
31703
|
-
this.
|
|
31704
|
-
|
|
31705
|
-
|
|
31706
|
-
|
|
31707
|
-
|
|
31708
|
-
|
|
31709
|
-
|
|
31710
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
31701
|
+
async onFetch(direction = "first" /* Amity.LiveCollectionPageDirection.FIRST */) {
|
|
31702
|
+
var _a, _b, _c, _d;
|
|
31703
|
+
if (direction === 'prev' && !this.previousToken)
|
|
31704
|
+
return;
|
|
31705
|
+
if (direction === 'next' && !this.nextToken)
|
|
31706
|
+
return;
|
|
31707
|
+
let token;
|
|
31708
|
+
if (direction === 'prev')
|
|
31709
|
+
token = this.previousToken;
|
|
31710
|
+
if (direction === 'next')
|
|
31711
|
+
token = this.nextToken;
|
|
31712
|
+
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
31713
|
+
if (direction === 'first') {
|
|
31714
|
+
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
31715
|
+
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
31711
31716
|
}
|
|
31717
|
+
if (direction === 'prev')
|
|
31718
|
+
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
31719
|
+
if (direction === 'next')
|
|
31720
|
+
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
31721
|
+
return queryResponse;
|
|
31712
31722
|
}
|
|
31713
|
-
|
|
31714
|
-
|
|
31715
|
-
if (this.paginationController instanceof PaginationNoPageController)
|
|
31716
|
-
return;
|
|
31717
|
-
const result = await this.paginationController.loadPreviousPage();
|
|
31718
|
-
if (!result)
|
|
31719
|
-
return;
|
|
31720
|
-
await this.persistModel(result);
|
|
31721
|
-
this.persistQueryStream({
|
|
31722
|
-
response: result,
|
|
31723
|
-
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
31724
|
-
});
|
|
31725
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
31726
|
-
}
|
|
31727
|
-
catch (e) {
|
|
31728
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
31729
|
-
}
|
|
31723
|
+
getNextToken() {
|
|
31724
|
+
return this.nextToken;
|
|
31730
31725
|
}
|
|
31731
|
-
|
|
31732
|
-
|
|
31733
|
-
if (isEqual(this.snapshot, newData))
|
|
31734
|
-
return false;
|
|
31735
|
-
this.snapshot = newData;
|
|
31736
|
-
return true;
|
|
31726
|
+
getPrevToken() {
|
|
31727
|
+
return this.previousToken;
|
|
31737
31728
|
}
|
|
31738
|
-
|
|
31739
|
-
|
|
31729
|
+
}
|
|
31730
|
+
|
|
31731
|
+
/* eslint-disable no-use-before-define */
|
|
31732
|
+
/**
|
|
31733
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
31734
|
+
* TODO: check if querybyIds is supported
|
|
31735
|
+
*/
|
|
31736
|
+
class MessagePaginationController extends PaginationController {
|
|
31737
|
+
async getRequest(queryParams, token) {
|
|
31738
|
+
const processedQueryParams = convertQueryParams$1(queryParams);
|
|
31739
|
+
const { data: queryResponse } = await this.http.get(`/api/v5/messages`, {
|
|
31740
|
+
params: Object.assign(Object.assign({}, processedQueryParams), { options: token
|
|
31741
|
+
? {
|
|
31742
|
+
token,
|
|
31743
|
+
}
|
|
31744
|
+
: Object.assign({}, processedQueryParams.options) }),
|
|
31745
|
+
});
|
|
31746
|
+
return queryResponse;
|
|
31740
31747
|
}
|
|
31741
31748
|
}
|
|
31742
31749
|
|
|
@@ -31751,25 +31758,10 @@ class MessageLiveCollectionController extends LiveCollectionController {
|
|
|
31751
31758
|
this.callback = callback.bind(this);
|
|
31752
31759
|
this.loadPage({ initial: true });
|
|
31753
31760
|
}
|
|
31754
|
-
setup() {
|
|
31755
|
-
var _a;
|
|
31756
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31757
|
-
if (!collection) {
|
|
31758
|
-
pushToCache(this.cacheKey, {
|
|
31759
|
-
data: [],
|
|
31760
|
-
query: this.query,
|
|
31761
|
-
});
|
|
31762
|
-
}
|
|
31763
|
-
}
|
|
31764
|
-
async persistModel(response) {
|
|
31765
|
-
await this.queryStreamController.saveToMainDB(response);
|
|
31766
|
-
}
|
|
31767
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
31768
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
31769
|
-
}
|
|
31770
31761
|
startSubscription() {
|
|
31771
31762
|
return this.queryStreamController.subscribeRTE([
|
|
31772
31763
|
{ fn: onMessageCreatedMqtt, action: 'onCreate' },
|
|
31764
|
+
{ fn: onMessageCreatedLocal, action: 'onCreate' },
|
|
31773
31765
|
{ fn: onMessageDeleted, action: 'onDelete' },
|
|
31774
31766
|
{ fn: onMessageUpdated, action: 'onUpdate' },
|
|
31775
31767
|
{ fn: onMessageFlagged, action: 'onFlagged' },
|
|
@@ -31846,6 +31838,22 @@ class MessageLiveCollectionController extends LiveCollectionController {
|
|
|
31846
31838
|
});
|
|
31847
31839
|
return messages;
|
|
31848
31840
|
}
|
|
31841
|
+
setup() {
|
|
31842
|
+
var _a;
|
|
31843
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31844
|
+
if (!collection) {
|
|
31845
|
+
pushToCache(this.cacheKey, {
|
|
31846
|
+
data: [],
|
|
31847
|
+
query: this.query,
|
|
31848
|
+
});
|
|
31849
|
+
}
|
|
31850
|
+
}
|
|
31851
|
+
async persistModel(response) {
|
|
31852
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
31853
|
+
}
|
|
31854
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
31855
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
31856
|
+
}
|
|
31849
31857
|
}
|
|
31850
31858
|
|
|
31851
31859
|
/* eslint-disable no-use-before-define */
|
|
@@ -38055,7 +38063,11 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
38055
38063
|
* @category Post Live Object
|
|
38056
38064
|
*/
|
|
38057
38065
|
const getPost = (postId, callback) => {
|
|
38058
|
-
|
|
38066
|
+
const responder = (snapshot) => {
|
|
38067
|
+
const { data } = snapshot;
|
|
38068
|
+
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
38069
|
+
};
|
|
38070
|
+
return liveObject(postId, responder, 'postId', getPost$1, [
|
|
38059
38071
|
onPostApproved,
|
|
38060
38072
|
onPostDeclined,
|
|
38061
38073
|
(callback) => {
|
|
@@ -39236,7 +39248,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
39236
39248
|
getPoll: getPoll
|
|
39237
39249
|
});
|
|
39238
39250
|
|
|
39239
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
39251
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
|
|
39240
39252
|
/*
|
|
39241
39253
|
* The crypto algorithm used for importing key and signing string
|
|
39242
39254
|
*/
|
|
@@ -40683,20 +40695,27 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
40683
40695
|
getGlobalStoryTargets: getGlobalStoryTargets
|
|
40684
40696
|
});
|
|
40685
40697
|
|
|
40686
|
-
const
|
|
40687
|
-
|
|
40688
|
-
|
|
40689
|
-
|
|
40690
|
-
|
|
40691
|
-
};
|
|
40698
|
+
const convertToInternalAd = (ad) => {
|
|
40699
|
+
return Object.assign(Object.assign({}, ad), { endAt: ad.endAt ? ad.endAt : null });
|
|
40700
|
+
};
|
|
40701
|
+
const convertToInternalAdvertiser = (advertiser) => {
|
|
40702
|
+
return Object.assign({}, advertiser);
|
|
40692
40703
|
};
|
|
40693
40704
|
const getNetworkAds = async () => {
|
|
40694
40705
|
const client = getActiveClient();
|
|
40695
40706
|
const { data } = await client.http.get('/api/v1/ads/me');
|
|
40696
|
-
const
|
|
40697
|
-
|
|
40698
|
-
|
|
40699
|
-
|
|
40707
|
+
const internalAds = data.ads.map(convertToInternalAd);
|
|
40708
|
+
const internalAdvertisers = data.advertisers.map(convertToInternalAdvertiser);
|
|
40709
|
+
ingestInCache({
|
|
40710
|
+
ads: internalAds,
|
|
40711
|
+
advertisers: internalAdvertisers,
|
|
40712
|
+
files: data.files,
|
|
40713
|
+
});
|
|
40714
|
+
pushToCache(['ad', 'setting'], data.settings);
|
|
40715
|
+
return {
|
|
40716
|
+
ads: internalAds.map(LinkedObject.ad),
|
|
40717
|
+
settings: data.settings,
|
|
40718
|
+
};
|
|
40700
40719
|
};
|
|
40701
40720
|
|
|
40702
40721
|
var index = /*#__PURE__*/Object.freeze({
|