@amityco/ts-sdk 6.18.1-c018952.0 → 6.19.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/events.d.ts +4 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/objectResolver.d.ts +13 -0
- package/dist/@types/core/objectResolver.d.ts.map +1 -0
- package/dist/@types/domains/channel.d.ts +12 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/analytic/api/syncEvent.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +1 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +1 -0
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannelByIds.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelFetched.d.ts +17 -0
- package/dist/channelRepository/events/onChannelFetched.d.ts.map +1 -0
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts +3 -3
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/observers/observeChannel.d.ts +1 -1
- package/dist/channelRepository/observers/observeChannel.d.ts.map +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/channelRepository/utils/prepateUnreadCountInfo.d.ts +2 -0
- package/dist/channelRepository/utils/prepateUnreadCountInfo.d.ts.map +1 -0
- package/dist/channelRepository/utils/resolveUnreadInfoOnChannelEvent.d.ts +2 -0
- package/dist/channelRepository/utils/resolveUnreadInfoOnChannelEvent.d.ts.map +1 -0
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts +26 -0
- package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +1 -0
- package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts +3 -0
- package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/client/utils/onOffline.d.ts +2 -0
- package/dist/client/utils/onOffline.d.ts.map +1 -0
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/index.cjs.js +446 -158
- package/dist/index.esm.js +446 -158
- package/dist/index.umd.js +4 -4
- package/dist/marker/api/getUserMessageFeedMarkers.d.ts.map +1 -1
- package/dist/marker/events/onUserFeedMarkerFetched.d.ts +17 -0
- package/dist/marker/events/onUserFeedMarkerFetched.d.ts.map +1 -0
- package/dist/marker/utils/addFlagSubChannelUnreadByChannelId.d.ts +2 -0
- package/dist/marker/utils/addFlagSubChannelUnreadByChannelId.d.ts.map +1 -0
- package/dist/marker/utils/addFlagSubChannelUnreadBySubChannelId.d.ts +2 -0
- package/dist/marker/utils/addFlagSubChannelUnreadBySubChannelId.d.ts.map +1 -0
- package/dist/messageRepository/observers/tests/markReadMessage.test.d.ts +2 -0
- package/dist/messageRepository/observers/tests/markReadMessage.test.d.ts.map +1 -0
- package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
- package/dist/subChannelRepository/events/onSubChannelCreated.d.ts.map +1 -1
- package/dist/subChannelRepository/utils/persistOptimisticUnreadInfo.d.ts +1 -1
- package/dist/subChannelRepository/utils/persistOptimisticUnreadInfo.d.ts.map +1 -1
- package/dist/utils/liveObject.d.ts.map +1 -1
- package/dist/utils/tests/dummy/message.d.ts +5 -4
- package/dist/utils/tests/dummy/message.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +5 -0
- package/src/@types/core/objectResolver.ts +14 -0
- package/src/@types/domains/channel.ts +12 -10
- package/src/analytic/api/syncEvent.ts +1 -3
- package/src/analytic/service/analytic/AnalyticsEngine.ts +6 -6
- package/src/analytic/service/analytic/AnalyticsEventCapturer.ts +9 -1
- package/src/analytic/service/analytic/AnalyticsEventSyncer.ts +9 -3
- package/src/channelRepository/api/getChannel.ts +5 -0
- package/src/channelRepository/api/getChannelByIds.ts +3 -0
- package/src/channelRepository/events/onChannelFetched.ts +28 -0
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +86 -26
- package/src/channelRepository/observers/getChannels/ChannelQueryStreamController.ts +21 -8
- package/src/channelRepository/observers/observeChannel.ts +22 -9
- package/src/channelRepository/observers/observeChannels.ts +9 -9
- package/src/channelRepository/utils/prepareChannelPayload.ts +0 -13
- package/src/channelRepository/utils/prepateUnreadCountInfo.ts +20 -0
- package/src/channelRepository/utils/resolveUnreadInfoOnChannelEvent.ts +15 -0
- package/src/channelRepository/utils/tests/prepareChannelPayload.test.ts +2 -2
- package/src/client/api/login.ts +3 -1
- package/src/client/utils/ObjectResolver/objectResolverEngine.ts +143 -0
- package/src/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.ts +21 -0
- package/src/client/utils/onOffline.ts +15 -0
- package/src/marker/api/getUserMessageFeedMarkers.ts +3 -0
- package/src/marker/events/onUserFeedMarkerFetched.ts +37 -0
- package/src/marker/utils/addFlagSubChannelUnreadByChannelId.ts +19 -0
- package/src/marker/utils/addFlagSubChannelUnreadBySubChannelId.ts +13 -0
- package/src/messageRepository/observers/tests/markReadMessage.test.ts +225 -0
- package/src/reactionRepository/events/onReactionAdded.ts +1 -0
- package/src/subChannelRepository/events/onSubChannelCreated.ts +8 -1
- package/src/subChannelRepository/utils/persistOptimisticUnreadInfo.ts +24 -19
- package/src/utils/liveObject.ts +1 -0
- package/src/utils/tests/client.ts +1 -1
- package/src/utils/tests/dummy/channel.ts +4 -4
- package/src/utils/tests/dummy/message.ts +11 -2
package/dist/index.cjs.js
CHANGED
|
@@ -98,8 +98,8 @@ const PostContentType = Object.freeze({
|
|
|
98
98
|
|
|
99
99
|
function getVersion() {
|
|
100
100
|
try {
|
|
101
|
-
// the string ''v6.
|
|
102
|
-
return 'v6.
|
|
101
|
+
// the string ''v6.19.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
102
|
+
return 'v6.19.0-cjs';
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
105
|
return '__dev__';
|
|
@@ -4766,9 +4766,10 @@ const HIGH_PRIORITY_ANALYTIC_CACHE_KEY = ['analytic', 'high-priority'];
|
|
|
4766
4766
|
|
|
4767
4767
|
const syncEvent = async (events) => {
|
|
4768
4768
|
const client = getActiveClient();
|
|
4769
|
-
|
|
4769
|
+
const params = {
|
|
4770
4770
|
activities: events,
|
|
4771
|
-
}
|
|
4771
|
+
};
|
|
4772
|
+
await client.http.post('/api/v1/analytics/activities', params);
|
|
4772
4773
|
};
|
|
4773
4774
|
|
|
4774
4775
|
class AnalyticsEventSyncer {
|
|
@@ -4786,10 +4787,14 @@ class AnalyticsEventSyncer {
|
|
|
4786
4787
|
}, 10 * SECOND$1);
|
|
4787
4788
|
}
|
|
4788
4789
|
stop() {
|
|
4789
|
-
if (
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4790
|
+
if (this._timer) {
|
|
4791
|
+
clearInterval(this._timer);
|
|
4792
|
+
this._timer = undefined;
|
|
4793
|
+
}
|
|
4794
|
+
if (this._high_priority_timer) {
|
|
4795
|
+
clearInterval(this._high_priority_timer);
|
|
4796
|
+
this._high_priority_timer = undefined;
|
|
4797
|
+
}
|
|
4793
4798
|
}
|
|
4794
4799
|
async syncCapturedEvent() {
|
|
4795
4800
|
try {
|
|
@@ -4939,6 +4944,12 @@ class AnalyticsEventCapturer {
|
|
|
4939
4944
|
this._bufferNewSeenStoryReferenceIds = [];
|
|
4940
4945
|
}, 300);
|
|
4941
4946
|
}
|
|
4947
|
+
resetAllBuckets() {
|
|
4948
|
+
this._recentViewed = {};
|
|
4949
|
+
this._recentHighPriorityViewed = {};
|
|
4950
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
4951
|
+
dropFromCache(HIGH_PRIORITY_ANALYTIC_CACHE_KEY);
|
|
4952
|
+
}
|
|
4942
4953
|
markStoryAsViewed(story) {
|
|
4943
4954
|
this.markStory(story, "view" /* Amity.AnalyticEventActivityType.View */);
|
|
4944
4955
|
}
|
|
@@ -4977,21 +4988,23 @@ class AnalyticsEngine {
|
|
|
4977
4988
|
this._eventSyncer.start();
|
|
4978
4989
|
}
|
|
4979
4990
|
handleTokenExpired() {
|
|
4980
|
-
this.
|
|
4991
|
+
this._stopAndDestroy();
|
|
4981
4992
|
}
|
|
4982
4993
|
destroy() {
|
|
4994
|
+
this._stopAndDestroy();
|
|
4995
|
+
}
|
|
4996
|
+
_stopAndDestroy() {
|
|
4983
4997
|
this._eventSyncer.stop();
|
|
4984
|
-
|
|
4985
|
-
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
4998
|
+
this._eventCapturer.resetAllBuckets();
|
|
4986
4999
|
}
|
|
4987
5000
|
}
|
|
4988
|
-
let instance$
|
|
5001
|
+
let instance$3;
|
|
4989
5002
|
var AnalyticsEngine$1 = {
|
|
4990
5003
|
getInstance: () => {
|
|
4991
|
-
if (!instance$
|
|
4992
|
-
instance$
|
|
5004
|
+
if (!instance$3) {
|
|
5005
|
+
instance$3 = new AnalyticsEngine();
|
|
4993
5006
|
}
|
|
4994
|
-
return instance$
|
|
5007
|
+
return instance$3;
|
|
4995
5008
|
},
|
|
4996
5009
|
};
|
|
4997
5010
|
|
|
@@ -5590,12 +5603,12 @@ class MessageReadReceiptSyncEngine {
|
|
|
5590
5603
|
}
|
|
5591
5604
|
}
|
|
5592
5605
|
}
|
|
5593
|
-
let instance$
|
|
5606
|
+
let instance$2 = null;
|
|
5594
5607
|
var ReadReceiptSyncEngine = {
|
|
5595
5608
|
getInstance: () => {
|
|
5596
|
-
if (!instance$
|
|
5597
|
-
instance$
|
|
5598
|
-
return instance$
|
|
5609
|
+
if (!instance$2)
|
|
5610
|
+
instance$2 = new MessageReadReceiptSyncEngine();
|
|
5611
|
+
return instance$2;
|
|
5599
5612
|
},
|
|
5600
5613
|
};
|
|
5601
5614
|
|
|
@@ -6009,71 +6022,6 @@ const getChannelIsMentioned = (channel, marker) => {
|
|
|
6009
6022
|
: (_d = (_c = getCachedMarker(channel.channelId)) === null || _c === void 0 ? void 0 : _c.hasMentioned) !== null && _d !== void 0 ? _d : false;
|
|
6010
6023
|
};
|
|
6011
6024
|
|
|
6012
|
-
/**
|
|
6013
|
-
* ```js
|
|
6014
|
-
* import { getSubChannelMarkers } from '@amityco/ts-sdk'
|
|
6015
|
-
* const subChannelMarkers = await getSubChannelMarkers(['sch1', 'sch2'])
|
|
6016
|
-
* ```
|
|
6017
|
-
*
|
|
6018
|
-
* Fetches a paginable list of {@link Amity.SubChannelMarker} objects
|
|
6019
|
-
*
|
|
6020
|
-
* @param messageFeedIds the feed IDs of the {@link Amity.RawSubChannel} marker to fetch
|
|
6021
|
-
* @param page
|
|
6022
|
-
* @returns A page of {@link Amity.SubChannelMarker} objects
|
|
6023
|
-
*
|
|
6024
|
-
* @category Channel API
|
|
6025
|
-
* @async
|
|
6026
|
-
* @private
|
|
6027
|
-
*/
|
|
6028
|
-
const getUserMessageFeedMakers = async (channelIds) => {
|
|
6029
|
-
const client = getActiveClient();
|
|
6030
|
-
client.log('channel/getUserMessageFeedMakers', channelIds);
|
|
6031
|
-
const { data } = await client.http.get(`/api/v1/markers/user-message-feed`, {
|
|
6032
|
-
params: {
|
|
6033
|
-
channelIds,
|
|
6034
|
-
},
|
|
6035
|
-
});
|
|
6036
|
-
return data;
|
|
6037
|
-
};
|
|
6038
|
-
|
|
6039
|
-
const persistUnreadCountInfo = (payload) => {
|
|
6040
|
-
const { feedMarkers, userFeedMarkers } = payload;
|
|
6041
|
-
// calculate sub channel unread info and channel unread info
|
|
6042
|
-
if (feedMarkers.length > 0 && userFeedMarkers.length > 0) {
|
|
6043
|
-
const channelIds = [];
|
|
6044
|
-
const feedMarkerMap = new Map(feedMarkers.map(fm => [fm.feedId, fm]));
|
|
6045
|
-
userFeedMarkers.forEach(userFeedMarker => {
|
|
6046
|
-
const feedMarker = feedMarkerMap.get(userFeedMarker.feedId);
|
|
6047
|
-
if (!feedMarker)
|
|
6048
|
-
return;
|
|
6049
|
-
if (feedMarker.feedId === userFeedMarker.feedId) {
|
|
6050
|
-
const unreadCount = feedMarker.lastSegment - userFeedMarker.readToSegment;
|
|
6051
|
-
const subChannelUnreadInfo = {
|
|
6052
|
-
subChannelId: feedMarker.feedId,
|
|
6053
|
-
channelId: feedMarker.entityId,
|
|
6054
|
-
readToSegment: userFeedMarker.readToSegment,
|
|
6055
|
-
lastSegment: feedMarker.lastSegment,
|
|
6056
|
-
lastMentionSegment: userFeedMarker.lastMentionSegment,
|
|
6057
|
-
unreadCount: Math.max(0, unreadCount),
|
|
6058
|
-
isMentioned: userFeedMarker.isMentioned,
|
|
6059
|
-
isDeleted: feedMarker.isDeleted,
|
|
6060
|
-
createdAt: userFeedMarker.createdAt,
|
|
6061
|
-
updatedAt: userFeedMarker.updatedAt,
|
|
6062
|
-
};
|
|
6063
|
-
// update sub channel unread info in cache
|
|
6064
|
-
ingestInCache({ subChannelUnreadInfo: [subChannelUnreadInfo] });
|
|
6065
|
-
if (!channelIds.includes(feedMarker.entityId)) {
|
|
6066
|
-
channelIds.push(feedMarker.entityId);
|
|
6067
|
-
}
|
|
6068
|
-
}
|
|
6069
|
-
});
|
|
6070
|
-
// re-calculate channel unread info in cache
|
|
6071
|
-
channelIds.forEach(channelId => {
|
|
6072
|
-
reCalculateChannelUnreadInfo(channelId);
|
|
6073
|
-
});
|
|
6074
|
-
}
|
|
6075
|
-
};
|
|
6076
|
-
|
|
6077
6025
|
const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
6078
6026
|
const isUnreadCountSupport$2 = ({ type }) => MARKER_INCLUDED_CHANNEL_TYPE.includes(type);
|
|
6079
6027
|
function convertFromRaw$2(channel, options = { isMessagePreviewUpdated: true }) {
|
|
@@ -6108,15 +6056,6 @@ const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated:
|
|
|
6108
6056
|
const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpdated: true }) => {
|
|
6109
6057
|
const client = getActiveClient();
|
|
6110
6058
|
const networkPreviewSetting = await client.getMessagePreviewSetting(false);
|
|
6111
|
-
// if consistent mode is enabled, persist the unread count info to the cache
|
|
6112
|
-
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
6113
|
-
const queryPayload = await getUserMessageFeedMakers(rawPayload.channels.map(({ channelId }) => channelId));
|
|
6114
|
-
const { feedMarkers, userFeedMarkers } = queryPayload;
|
|
6115
|
-
persistUnreadCountInfo({
|
|
6116
|
-
feedMarkers,
|
|
6117
|
-
userFeedMarkers,
|
|
6118
|
-
});
|
|
6119
|
-
}
|
|
6120
6059
|
if (options.isMessagePreviewUpdated &&
|
|
6121
6060
|
networkPreviewSetting !== "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */ &&
|
|
6122
6061
|
rawPayload.messagePreviews &&
|
|
@@ -6184,6 +6123,7 @@ const getChannelByIds = async (channelIds) => {
|
|
|
6184
6123
|
const cachedAt = client.cache && Date.now();
|
|
6185
6124
|
if (client.cache)
|
|
6186
6125
|
ingestInCache(data, { cachedAt });
|
|
6126
|
+
fireEvent('local.channel.fetched', data.channels);
|
|
6187
6127
|
return {
|
|
6188
6128
|
data: data.channels,
|
|
6189
6129
|
cachedAt,
|
|
@@ -6254,6 +6194,44 @@ const getMessageMarkers = async (messageIds) => {
|
|
|
6254
6194
|
return { data: contentMarkers, cachedAt };
|
|
6255
6195
|
};
|
|
6256
6196
|
|
|
6197
|
+
const persistUnreadCountInfo = (payload) => {
|
|
6198
|
+
const { feedMarkers, userFeedMarkers } = payload;
|
|
6199
|
+
// calculate sub channel unread info and channel unread info
|
|
6200
|
+
if (feedMarkers.length > 0 && userFeedMarkers.length > 0) {
|
|
6201
|
+
const channelIds = [];
|
|
6202
|
+
const feedMarkerMap = new Map(feedMarkers.map(fm => [fm.feedId, fm]));
|
|
6203
|
+
userFeedMarkers.forEach(userFeedMarker => {
|
|
6204
|
+
const feedMarker = feedMarkerMap.get(userFeedMarker.feedId);
|
|
6205
|
+
if (!feedMarker)
|
|
6206
|
+
return;
|
|
6207
|
+
if (feedMarker.feedId === userFeedMarker.feedId) {
|
|
6208
|
+
const unreadCount = feedMarker.lastSegment - userFeedMarker.readToSegment;
|
|
6209
|
+
const subChannelUnreadInfo = {
|
|
6210
|
+
subChannelId: feedMarker.feedId,
|
|
6211
|
+
channelId: feedMarker.entityId,
|
|
6212
|
+
readToSegment: userFeedMarker.readToSegment,
|
|
6213
|
+
lastSegment: feedMarker.lastSegment,
|
|
6214
|
+
lastMentionSegment: userFeedMarker.lastMentionSegment,
|
|
6215
|
+
unreadCount: Math.max(0, unreadCount),
|
|
6216
|
+
isMentioned: userFeedMarker.isMentioned,
|
|
6217
|
+
isDeleted: feedMarker.isDeleted,
|
|
6218
|
+
createdAt: userFeedMarker.createdAt,
|
|
6219
|
+
updatedAt: userFeedMarker.updatedAt,
|
|
6220
|
+
};
|
|
6221
|
+
// update sub channel unread info in cache
|
|
6222
|
+
ingestInCache({ subChannelUnreadInfo: [subChannelUnreadInfo] });
|
|
6223
|
+
if (!channelIds.includes(feedMarker.entityId)) {
|
|
6224
|
+
channelIds.push(feedMarker.entityId);
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
});
|
|
6228
|
+
// re-calculate channel unread info in cache
|
|
6229
|
+
channelIds.forEach(channelId => {
|
|
6230
|
+
reCalculateChannelUnreadInfo(channelId);
|
|
6231
|
+
});
|
|
6232
|
+
}
|
|
6233
|
+
};
|
|
6234
|
+
|
|
6257
6235
|
/**
|
|
6258
6236
|
* ```js
|
|
6259
6237
|
* import { getSubChannelMarkers } from '@amityco/ts-sdk'
|
|
@@ -6620,13 +6598,13 @@ class SessionWatcher {
|
|
|
6620
6598
|
this._listener.clear();
|
|
6621
6599
|
}
|
|
6622
6600
|
}
|
|
6623
|
-
let instance;
|
|
6601
|
+
let instance$1;
|
|
6624
6602
|
var SessionWatcher$1 = {
|
|
6625
6603
|
getInstance: () => {
|
|
6626
|
-
if (!instance) {
|
|
6627
|
-
instance = new SessionWatcher();
|
|
6604
|
+
if (!instance$1) {
|
|
6605
|
+
instance$1 = new SessionWatcher();
|
|
6628
6606
|
}
|
|
6629
|
-
return instance;
|
|
6607
|
+
return instance$1;
|
|
6630
6608
|
},
|
|
6631
6609
|
};
|
|
6632
6610
|
|
|
@@ -7529,6 +7507,174 @@ var readReceiptSyncEngineOnLoginHandler = () => {
|
|
|
7529
7507
|
};
|
|
7530
7508
|
};
|
|
7531
7509
|
|
|
7510
|
+
const onOffline = (callback) => {
|
|
7511
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
7512
|
+
window.addEventListener('offline', callback);
|
|
7513
|
+
return () => window.removeEventListener('offline', callback);
|
|
7514
|
+
}
|
|
7515
|
+
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
7516
|
+
document.addEventListener('offline', callback);
|
|
7517
|
+
return () => document.removeEventListener('offline', callback);
|
|
7518
|
+
}
|
|
7519
|
+
// Handle unsupported environment
|
|
7520
|
+
console.error('Unsupported environment');
|
|
7521
|
+
return () => console.error('Unsupported environment');
|
|
7522
|
+
};
|
|
7523
|
+
|
|
7524
|
+
/**
|
|
7525
|
+
* ```js
|
|
7526
|
+
* import { getSubChannelMarkers } from '@amityco/ts-sdk'
|
|
7527
|
+
* const subChannelMarkers = await getSubChannelMarkers(['sch1', 'sch2'])
|
|
7528
|
+
* ```
|
|
7529
|
+
*
|
|
7530
|
+
* Fetches a paginable list of {@link Amity.SubChannelMarker} objects
|
|
7531
|
+
*
|
|
7532
|
+
* @param messageFeedIds the feed IDs of the {@link Amity.RawSubChannel} marker to fetch
|
|
7533
|
+
* @param page
|
|
7534
|
+
* @returns A page of {@link Amity.SubChannelMarker} objects
|
|
7535
|
+
*
|
|
7536
|
+
* @category Channel API
|
|
7537
|
+
* @async
|
|
7538
|
+
* @private
|
|
7539
|
+
*/
|
|
7540
|
+
const getUserMessageFeedMakers = async (channelIds) => {
|
|
7541
|
+
const client = getActiveClient();
|
|
7542
|
+
client.log('channel/getUserMessageFeedMakers', channelIds);
|
|
7543
|
+
const { data } = await client.http.get(`/api/v1/markers/user-message-feed`, {
|
|
7544
|
+
params: {
|
|
7545
|
+
channelIds,
|
|
7546
|
+
},
|
|
7547
|
+
});
|
|
7548
|
+
fireEvent('local.userMessageFeedMarker.fetched', { userMessageFeedMarker: data });
|
|
7549
|
+
return data;
|
|
7550
|
+
};
|
|
7551
|
+
|
|
7552
|
+
class ObjectResolverEngine {
|
|
7553
|
+
constructor() {
|
|
7554
|
+
this.TIMER_INTERVAL_MS = SECOND$1;
|
|
7555
|
+
this.BUFFER_ID_LIMIT = 100;
|
|
7556
|
+
this.buffer = {
|
|
7557
|
+
["channel" /* Amity.ReferenceType.CHANNEL */]: [],
|
|
7558
|
+
["userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */]: [],
|
|
7559
|
+
};
|
|
7560
|
+
this.isResolvingTask = false;
|
|
7561
|
+
this.connectionListener = [];
|
|
7562
|
+
this.isConnected = true;
|
|
7563
|
+
this.addConnectionListener();
|
|
7564
|
+
}
|
|
7565
|
+
startResolver() {
|
|
7566
|
+
if (!this.timer) {
|
|
7567
|
+
this.timer = setInterval(() => {
|
|
7568
|
+
if (this.isConnected)
|
|
7569
|
+
this.resolveObjects();
|
|
7570
|
+
}, this.TIMER_INTERVAL_MS);
|
|
7571
|
+
}
|
|
7572
|
+
}
|
|
7573
|
+
stopResolver() {
|
|
7574
|
+
if (this.timer) {
|
|
7575
|
+
clearInterval(this.timer);
|
|
7576
|
+
this.timer = undefined;
|
|
7577
|
+
}
|
|
7578
|
+
}
|
|
7579
|
+
resolve(id, referenceType) {
|
|
7580
|
+
const objectIdList = this.getBuffer(referenceType);
|
|
7581
|
+
if (objectIdList.includes(id))
|
|
7582
|
+
return;
|
|
7583
|
+
if (objectIdList.length >= this.BUFFER_ID_LIMIT) {
|
|
7584
|
+
objectIdList.shift(); // Remove first element of the array
|
|
7585
|
+
}
|
|
7586
|
+
objectIdList.push(id);
|
|
7587
|
+
}
|
|
7588
|
+
addConnectionListener() {
|
|
7589
|
+
if (this.connectionListener.length > 0)
|
|
7590
|
+
return;
|
|
7591
|
+
this.connectionListener.push(onOnline(() => {
|
|
7592
|
+
this.isConnected = true;
|
|
7593
|
+
}));
|
|
7594
|
+
this.connectionListener.push(onOffline(() => {
|
|
7595
|
+
this.isConnected = false;
|
|
7596
|
+
}));
|
|
7597
|
+
}
|
|
7598
|
+
removeConnectionListener() {
|
|
7599
|
+
if (this.connectionListener.length > 0)
|
|
7600
|
+
this.connectionListener.forEach(listener => listener());
|
|
7601
|
+
}
|
|
7602
|
+
resolveObjects() {
|
|
7603
|
+
if (this.isResolvingTask) {
|
|
7604
|
+
return;
|
|
7605
|
+
}
|
|
7606
|
+
this.isResolvingTask = true;
|
|
7607
|
+
// Get first 100 ids for all reference type supported.
|
|
7608
|
+
const channelIds = this.getBuffer("channel" /* Amity.ReferenceType.CHANNEL */);
|
|
7609
|
+
const userMessageFeedMarkerIds = this.getBuffer("userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */);
|
|
7610
|
+
// Clear buffer
|
|
7611
|
+
this.clearBuffer();
|
|
7612
|
+
// Send Requests.
|
|
7613
|
+
// Incase of failure: Ignore
|
|
7614
|
+
// Incase of success: Persist in Domain DB & Notify Live collection
|
|
7615
|
+
if (channelIds.length > 0)
|
|
7616
|
+
getChannelByIds(channelIds);
|
|
7617
|
+
if (userMessageFeedMarkerIds.length > 0)
|
|
7618
|
+
getUserMessageFeedMakers(userMessageFeedMarkerIds);
|
|
7619
|
+
// After sending request
|
|
7620
|
+
this.isResolvingTask = false;
|
|
7621
|
+
}
|
|
7622
|
+
clearBuffer() {
|
|
7623
|
+
this.buffer = {
|
|
7624
|
+
["channel" /* Amity.ReferenceType.CHANNEL */]: [],
|
|
7625
|
+
["userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */]: [],
|
|
7626
|
+
};
|
|
7627
|
+
}
|
|
7628
|
+
getBuffer(referenceType) {
|
|
7629
|
+
return this.buffer[referenceType];
|
|
7630
|
+
}
|
|
7631
|
+
// Session Management : SessionComponent
|
|
7632
|
+
onSessionEstablished() {
|
|
7633
|
+
this.startResolver();
|
|
7634
|
+
this.addConnectionListener();
|
|
7635
|
+
}
|
|
7636
|
+
onSessionDestroyed() {
|
|
7637
|
+
// Stop timer
|
|
7638
|
+
this.stopResolver();
|
|
7639
|
+
// Clear buffer
|
|
7640
|
+
this.clearBuffer();
|
|
7641
|
+
// Reset state
|
|
7642
|
+
this.isResolvingTask = false;
|
|
7643
|
+
// remove connection listener
|
|
7644
|
+
this.removeConnectionListener();
|
|
7645
|
+
}
|
|
7646
|
+
onTokenExpired() {
|
|
7647
|
+
this.stopResolver();
|
|
7648
|
+
}
|
|
7649
|
+
}
|
|
7650
|
+
let instance = null;
|
|
7651
|
+
var ObjectResolverEngine$1 = {
|
|
7652
|
+
getInstance: () => {
|
|
7653
|
+
if (!instance)
|
|
7654
|
+
instance = new ObjectResolverEngine();
|
|
7655
|
+
return instance;
|
|
7656
|
+
},
|
|
7657
|
+
};
|
|
7658
|
+
|
|
7659
|
+
var objectResolverEngineOnLoginHandler = () => {
|
|
7660
|
+
const objectResolverEngine = ObjectResolverEngine$1.getInstance();
|
|
7661
|
+
objectResolverEngine.startResolver();
|
|
7662
|
+
onSessionStateChange(state => {
|
|
7663
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
7664
|
+
objectResolverEngine.onSessionEstablished();
|
|
7665
|
+
}
|
|
7666
|
+
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
7667
|
+
objectResolverEngine.onTokenExpired();
|
|
7668
|
+
}
|
|
7669
|
+
else {
|
|
7670
|
+
objectResolverEngine.onSessionDestroyed();
|
|
7671
|
+
}
|
|
7672
|
+
});
|
|
7673
|
+
return () => {
|
|
7674
|
+
objectResolverEngine.onSessionDestroyed();
|
|
7675
|
+
};
|
|
7676
|
+
};
|
|
7677
|
+
|
|
7532
7678
|
/* begin_public_function
|
|
7533
7679
|
id: client.logout
|
|
7534
7680
|
*/
|
|
@@ -8128,22 +8274,21 @@ const onMessageCreatedLocal = (callback) => {
|
|
|
8128
8274
|
};
|
|
8129
8275
|
};
|
|
8130
8276
|
|
|
8131
|
-
const persistOptimisticUnreadInfo = (
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
});
|
|
8277
|
+
const persistOptimisticUnreadInfo = (subChannelOptimisticInfo) => {
|
|
8278
|
+
const { channelId, subChannelId, createdAt, updatedAt } = subChannelOptimisticInfo;
|
|
8279
|
+
const subChannelUnreadInfo = {
|
|
8280
|
+
channelId,
|
|
8281
|
+
subChannelId,
|
|
8282
|
+
unreadCount: 0,
|
|
8283
|
+
readToSegment: 0,
|
|
8284
|
+
lastMentionSegment: 0,
|
|
8285
|
+
lastSegment: 0,
|
|
8286
|
+
isMentioned: false,
|
|
8287
|
+
isDeleted: false,
|
|
8288
|
+
createdAt,
|
|
8289
|
+
updatedAt,
|
|
8290
|
+
};
|
|
8291
|
+
pushToCache(['subChannelUnreadInfo', 'get', subChannelUnreadInfo.subChannelId], subChannelUnreadInfo);
|
|
8147
8292
|
};
|
|
8148
8293
|
|
|
8149
8294
|
/**
|
|
@@ -8167,7 +8312,14 @@ const onSubChannelCreated = (callback) => {
|
|
|
8167
8312
|
const payload = await prepareSubChannelPayload(rawPayload);
|
|
8168
8313
|
// optimistically create subChannelUnreadInfo
|
|
8169
8314
|
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
8170
|
-
|
|
8315
|
+
rawPayload.messageFeeds.forEach(subChannel => {
|
|
8316
|
+
persistOptimisticUnreadInfo({
|
|
8317
|
+
channelId: subChannel.channelId,
|
|
8318
|
+
subChannelId: subChannel.messageFeedId,
|
|
8319
|
+
createdAt: subChannel.createdAt,
|
|
8320
|
+
updatedAt: subChannel.updatedAt,
|
|
8321
|
+
});
|
|
8322
|
+
});
|
|
8171
8323
|
}
|
|
8172
8324
|
ingestInCache(payload);
|
|
8173
8325
|
callback(payload.messageFeeds[0]);
|
|
@@ -8583,7 +8735,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
8583
8735
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
8584
8736
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
8585
8737
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
8586
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), readReceiptSyncEngineOnLoginHandler());
|
|
8738
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), readReceiptSyncEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
|
|
8587
8739
|
const markerSyncUnsubscriber = await startMarkerSync();
|
|
8588
8740
|
subscriptions.push(markerSyncUnsubscriber);
|
|
8589
8741
|
}
|
|
@@ -9149,6 +9301,7 @@ const liveObject = (id, callback, key, fetcher, eventHandlers, options) => {
|
|
|
9149
9301
|
dispatcher({ loading: false, data: eventModel, origin: 'event' });
|
|
9150
9302
|
};
|
|
9151
9303
|
const onFetch = () => {
|
|
9304
|
+
// TODO: Ihis `@ts-ignore` is bring back to fix the build and it needs to be removed later
|
|
9152
9305
|
// @ts-ignore
|
|
9153
9306
|
const query = createQuery(fetcher, id, true);
|
|
9154
9307
|
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
@@ -13417,6 +13570,18 @@ const updateChannel = async (channelId, patch) => {
|
|
|
13417
13570
|
};
|
|
13418
13571
|
/* end_public_function */
|
|
13419
13572
|
|
|
13573
|
+
const prepareUnreadCountInfo = async (rawPayload) => {
|
|
13574
|
+
const client = getActiveClient();
|
|
13575
|
+
// if consistent mode is enabled, persist the unread count info to the cache
|
|
13576
|
+
const queryPayload = await getUserMessageFeedMakers(rawPayload.channels.map(({ channelId }) => channelId));
|
|
13577
|
+
const { feedMarkers, userFeedMarkers } = queryPayload;
|
|
13578
|
+
persistUnreadCountInfo({
|
|
13579
|
+
feedMarkers,
|
|
13580
|
+
userFeedMarkers,
|
|
13581
|
+
});
|
|
13582
|
+
client.log('channel/prepareUnreadCountInfo', rawPayload.channels);
|
|
13583
|
+
};
|
|
13584
|
+
|
|
13420
13585
|
/**
|
|
13421
13586
|
* ```js
|
|
13422
13587
|
* import { getChannel } from '@amityco/ts-sdk'
|
|
@@ -13439,6 +13604,9 @@ const getChannel$1 = async (channelId) => {
|
|
|
13439
13604
|
try {
|
|
13440
13605
|
const { data: payload } = await client.http.get(`/api/v3/channels/${encodeURIComponent(channelId)}`);
|
|
13441
13606
|
data = await prepareChannelPayload(payload);
|
|
13607
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
13608
|
+
prepareUnreadCountInfo(payload);
|
|
13609
|
+
}
|
|
13442
13610
|
}
|
|
13443
13611
|
catch (error) {
|
|
13444
13612
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
@@ -13702,8 +13870,8 @@ const observeChannel = (channelId, callback) => {
|
|
|
13702
13870
|
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, result);
|
|
13703
13871
|
};
|
|
13704
13872
|
const disposers = [];
|
|
13705
|
-
disposers.push(onChannelUpdated(data => router({ data, loading: false, origin: 'event' },
|
|
13706
|
-
runQuery(createQuery(getChannel$1, channelId), result => result.data && router(result,
|
|
13873
|
+
disposers.push(onChannelUpdated(data => router({ data, loading: false, origin: 'event' }, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)), onChannelDeleted(data => router({ data, loading: false, origin: 'event' }, "onDelete" /* Amity.ChannelActionType.OnDelete */)), onChannelJoined(data => router({ data, loading: false, origin: 'event' }, "onJoin" /* Amity.ChannelActionType.OnJoin */)), onChannelLeft(data => router({ data, loading: false, origin: 'event' }, "onLeft" /* Amity.ChannelActionType.OnLeft */)), onChannelMuted(data => router({ data, loading: false, origin: 'event' }, "onMute" /* Amity.ChannelActionType.OnMute */)), onChannelMemberAdded(data => router({ data, loading: false, origin: 'event' }, "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */)), onChannelMemberRemoved(data => router({ data, loading: false, origin: 'event' }, "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */)), convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(data => router({ data, loading: false, origin: 'event' }, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)));
|
|
13874
|
+
runQuery(createQuery(getChannel$1, channelId), result => result.data && router(result, "onFetch" /* Amity.ChannelActionType.OnFetch */));
|
|
13707
13875
|
return () => {
|
|
13708
13876
|
log(`observeChannel(tmpid: ${timestamp}) > dispose`);
|
|
13709
13877
|
disposers.forEach(fn => fn());
|
|
@@ -13737,7 +13905,7 @@ const observeChannels = (callback) => {
|
|
|
13737
13905
|
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, channel);
|
|
13738
13906
|
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, channel);
|
|
13739
13907
|
};
|
|
13740
|
-
disposers.push(onChannelCreated(data => router(data,
|
|
13908
|
+
disposers.push(onChannelCreated(data => router(data, "onCreate" /* Amity.ChannelActionType.OnCreate */)), onChannelUpdated(data => router(data, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)), onChannelDeleted(data => router(data, "onDelete" /* Amity.ChannelActionType.OnDelete */)), onChannelJoined(data => router(data, "onJoin" /* Amity.ChannelActionType.OnJoin */)), onChannelLeft(data => router(data, "onLeft" /* Amity.ChannelActionType.OnLeft */)), onChannelMuted(data => router(data, "onMute" /* Amity.ChannelActionType.OnMute */)), onChannelMemberAdded(data => router(data, "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */)), onChannelMemberRemoved(data => router(data, "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */)), convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(data => router(data, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)));
|
|
13741
13909
|
return () => {
|
|
13742
13910
|
log(`observeChannels(tmpid: ${timestamp}) > dispose`);
|
|
13743
13911
|
disposers.forEach(fn => fn());
|
|
@@ -16254,6 +16422,16 @@ class ChannelPaginationController extends PaginationController {
|
|
|
16254
16422
|
}
|
|
16255
16423
|
}
|
|
16256
16424
|
|
|
16425
|
+
/* eslint-disable no-use-before-define */
|
|
16426
|
+
class ChannelPaginationNoPageController extends PaginationNoPageController {
|
|
16427
|
+
async getRequest(queryParams) {
|
|
16428
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/channels/list`, {
|
|
16429
|
+
params: Object.assign({}, queryParams),
|
|
16430
|
+
});
|
|
16431
|
+
return queryResponse;
|
|
16432
|
+
}
|
|
16433
|
+
}
|
|
16434
|
+
|
|
16257
16435
|
/* eslint-disable no-use-before-define */
|
|
16258
16436
|
class ChannelQueryStreamController extends QueryStreamController {
|
|
16259
16437
|
constructor(query, cacheKey, notifyChange, preparePayload, paginationController) {
|
|
@@ -16289,11 +16467,22 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
16289
16467
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
16290
16468
|
if (!collection)
|
|
16291
16469
|
return;
|
|
16292
|
-
if (this.paginationController instanceof
|
|
16293
|
-
|
|
16294
|
-
|
|
16295
|
-
|
|
16470
|
+
if (this.paginationController instanceof ChannelPaginationNoPageController)
|
|
16471
|
+
return this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
16472
|
+
if ([
|
|
16473
|
+
"onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
16474
|
+
"onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
16475
|
+
"onFetch" /* Amity.ChannelActionType.OnFetch */,
|
|
16476
|
+
"onUserMessageFeedMarkerFetch" /* Amity.ChannelActionType.OnUserMessageFeedMarkerFetch */,
|
|
16477
|
+
].includes(action)) {
|
|
16478
|
+
if (Array.isArray(payload))
|
|
16479
|
+
collection.data = [
|
|
16480
|
+
...new Set([...payload.map(({ channelId }) => channelId), ...collection.data]),
|
|
16481
|
+
];
|
|
16482
|
+
else
|
|
16483
|
+
collection.data = [...new Set([payload.channelId, ...collection.data])];
|
|
16296
16484
|
}
|
|
16485
|
+
pushToCache(this.cacheKey, collection);
|
|
16297
16486
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
16298
16487
|
};
|
|
16299
16488
|
}
|
|
@@ -16302,15 +16491,63 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
16302
16491
|
}
|
|
16303
16492
|
}
|
|
16304
16493
|
|
|
16305
|
-
|
|
16306
|
-
|
|
16307
|
-
|
|
16308
|
-
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
16494
|
+
/**
|
|
16495
|
+
* ```js
|
|
16496
|
+
* import { onChannelFetched } from '@amityco/ts-sdk'
|
|
16497
|
+
* const dispose = onChannelFetched(channel => {
|
|
16498
|
+
* // ...
|
|
16499
|
+
* })
|
|
16500
|
+
* ```
|
|
16501
|
+
*
|
|
16502
|
+
* Fired when any {@link Amity.Channel} list have been fetched
|
|
16503
|
+
*
|
|
16504
|
+
* @param callback The function to call when the event was fired
|
|
16505
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16506
|
+
*
|
|
16507
|
+
* @category Channel Events
|
|
16508
|
+
*/
|
|
16509
|
+
const onChannelFetched = (callback) => {
|
|
16510
|
+
const client = getActiveClient();
|
|
16511
|
+
const filter = async (payload) => {
|
|
16512
|
+
callback(payload);
|
|
16513
|
+
};
|
|
16514
|
+
return createEventSubscriber(client, 'onChannelFetched', 'local.channel.fetched', filter);
|
|
16515
|
+
};
|
|
16516
|
+
|
|
16517
|
+
/**
|
|
16518
|
+
* ```js
|
|
16519
|
+
* import { onFeedMarkerUpdated } from '@amityco/ts-sdk'
|
|
16520
|
+
* const dispose = onFeedMarkerUpdated(feedMarker => {
|
|
16521
|
+
* // ...
|
|
16522
|
+
* })
|
|
16523
|
+
* ```
|
|
16524
|
+
*
|
|
16525
|
+
* Fired when an {@link Amity.UserMessageFeedMarkerPayload} has been updated
|
|
16526
|
+
*
|
|
16527
|
+
* @param callback The function to call when the event was fired
|
|
16528
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16529
|
+
*
|
|
16530
|
+
* @category FeedMarker Events
|
|
16531
|
+
*/
|
|
16532
|
+
const onUserFeedMarkerFetched = (callback) => {
|
|
16533
|
+
const client = getActiveClient();
|
|
16534
|
+
const filter = (payload) => {
|
|
16535
|
+
// update sub channel unread info and channel unread info in cache
|
|
16536
|
+
persistUnreadCountInfo(payload.userMessageFeedMarker);
|
|
16537
|
+
callback(payload.userMessageFeedMarker);
|
|
16538
|
+
};
|
|
16539
|
+
return createEventSubscriber(client, 'feedMarker/onUserFeedMarkerFetched', 'local.userMessageFeedMarker.fetched', filter);
|
|
16540
|
+
};
|
|
16541
|
+
|
|
16542
|
+
const resolveUnreadInfoOnChannelEvent = (channel, callback) => {
|
|
16543
|
+
const client = getActiveClient();
|
|
16544
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
16545
|
+
const objectResolverEngine = ObjectResolverEngine$1.getInstance();
|
|
16546
|
+
objectResolverEngine.resolve(channel.channelId, "userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */);
|
|
16312
16547
|
}
|
|
16313
|
-
|
|
16548
|
+
else
|
|
16549
|
+
callback(channel);
|
|
16550
|
+
};
|
|
16314
16551
|
|
|
16315
16552
|
/* eslint-disable no-use-before-define */
|
|
16316
16553
|
class ChannelLiveCollectionController extends LiveCollectionController {
|
|
@@ -16320,7 +16557,18 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16320
16557
|
const paginationController = ChannelLiveCollectionController.getPaginationController(query);
|
|
16321
16558
|
super(paginationController, queryStreamId, cacheKey, callback);
|
|
16322
16559
|
this.query = query;
|
|
16323
|
-
this.queryStreamController = new ChannelQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this),
|
|
16560
|
+
this.queryStreamController = new ChannelQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), async (channel) => {
|
|
16561
|
+
try {
|
|
16562
|
+
const client = getActiveClient();
|
|
16563
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
16564
|
+
await prepareUnreadCountInfo(channel);
|
|
16565
|
+
}
|
|
16566
|
+
}
|
|
16567
|
+
catch (e) {
|
|
16568
|
+
console.error('Error while preparing unread count info', e);
|
|
16569
|
+
}
|
|
16570
|
+
return prepareChannelPayload(channel);
|
|
16571
|
+
}, paginationController);
|
|
16324
16572
|
this.paginationController = paginationController;
|
|
16325
16573
|
this.callback = callback.bind(this);
|
|
16326
16574
|
this.loadPage(true);
|
|
@@ -16444,15 +16692,19 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16444
16692
|
'get',
|
|
16445
16693
|
message.channelId,
|
|
16446
16694
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
16447
|
-
if (!cacheData)
|
|
16448
|
-
|
|
16449
|
-
|
|
16450
|
-
|
|
16451
|
-
|
|
16452
|
-
|
|
16695
|
+
if (!cacheData) {
|
|
16696
|
+
const objectResolverEngine = ObjectResolverEngine$1.getInstance();
|
|
16697
|
+
objectResolverEngine.resolve(message.channelId, "channel" /* Amity.ReferenceType.CHANNEL */);
|
|
16698
|
+
}
|
|
16699
|
+
else {
|
|
16700
|
+
updateChannelCache(cacheData, {
|
|
16701
|
+
lastActivity: message.createdAt,
|
|
16702
|
+
});
|
|
16703
|
+
callback(message);
|
|
16704
|
+
}
|
|
16453
16705
|
});
|
|
16454
16706
|
}, 'messageId', 'channel'),
|
|
16455
|
-
action:
|
|
16707
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16456
16708
|
},
|
|
16457
16709
|
{
|
|
16458
16710
|
// TODO: merge this code to another onMessageCreated in this file
|
|
@@ -16472,12 +16724,19 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16472
16724
|
callback(message);
|
|
16473
16725
|
});
|
|
16474
16726
|
}, 'messageId', 'channel'),
|
|
16475
|
-
action:
|
|
16727
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16728
|
+
},
|
|
16729
|
+
{ fn: onChannelDeleted, action: "onDelete" /* Amity.ChannelActionType.OnDelete */ },
|
|
16730
|
+
{ fn: onChannelUpdated, action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */ },
|
|
16731
|
+
{ fn: onChannelMuted, action: "onMute" /* Amity.ChannelActionType.OnMute */ },
|
|
16732
|
+
{
|
|
16733
|
+
fn: (callback) => {
|
|
16734
|
+
return onChannelJoined(channel => {
|
|
16735
|
+
resolveUnreadInfoOnChannelEvent(channel, callback);
|
|
16736
|
+
});
|
|
16737
|
+
},
|
|
16738
|
+
action: "onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
16476
16739
|
},
|
|
16477
|
-
{ fn: onChannelDeleted, action: 'onDelete' },
|
|
16478
|
-
{ fn: onChannelUpdated, action: 'onUpdate' },
|
|
16479
|
-
{ fn: onChannelMuted, action: 'onMute' },
|
|
16480
|
-
{ fn: onChannelJoined, action: 'onJoin' },
|
|
16481
16740
|
{
|
|
16482
16741
|
fn: (reactor) => {
|
|
16483
16742
|
const callback = (channel, member) => {
|
|
@@ -16492,17 +16751,17 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16492
16751
|
};
|
|
16493
16752
|
return onChannelLeft(callback);
|
|
16494
16753
|
},
|
|
16495
|
-
action:
|
|
16754
|
+
action: "onLeft" /* Amity.ChannelActionType.OnLeft */,
|
|
16496
16755
|
},
|
|
16497
|
-
{ fn: onChannelMemberAdded, action:
|
|
16498
|
-
{ fn: onChannelMemberRemoved, action:
|
|
16756
|
+
{ fn: onChannelMemberAdded, action: "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */ },
|
|
16757
|
+
{ fn: onChannelMemberRemoved, action: "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */ },
|
|
16499
16758
|
{
|
|
16500
16759
|
fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
16501
|
-
action:
|
|
16760
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16502
16761
|
},
|
|
16503
16762
|
{
|
|
16504
16763
|
fn: convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
|
|
16505
|
-
action:
|
|
16764
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16506
16765
|
},
|
|
16507
16766
|
{
|
|
16508
16767
|
fn: convertEventPayload((callback) => {
|
|
@@ -16528,7 +16787,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16528
16787
|
};
|
|
16529
16788
|
return onMessageCreatedMqtt(updateMessagePreview);
|
|
16530
16789
|
}, 'channelId', 'channel'),
|
|
16531
|
-
action:
|
|
16790
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16532
16791
|
},
|
|
16533
16792
|
{
|
|
16534
16793
|
fn: convertEventPayload((callback) => {
|
|
@@ -16554,7 +16813,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16554
16813
|
};
|
|
16555
16814
|
return onMessageCreatedLocal(updateMessagePreview);
|
|
16556
16815
|
}, 'channelId', 'channel'),
|
|
16557
|
-
action:
|
|
16816
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16558
16817
|
},
|
|
16559
16818
|
{
|
|
16560
16819
|
fn: convertEventPayload((callback) => {
|
|
@@ -16569,7 +16828,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16569
16828
|
};
|
|
16570
16829
|
return onMessageUpdated(updateMessagePreview);
|
|
16571
16830
|
}, 'channelId', 'channel'),
|
|
16572
|
-
action:
|
|
16831
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16573
16832
|
},
|
|
16574
16833
|
{
|
|
16575
16834
|
fn: convertEventPayload((callback) => {
|
|
@@ -16590,7 +16849,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16590
16849
|
};
|
|
16591
16850
|
return onMessageDeleted(updateMessagePreview);
|
|
16592
16851
|
}, 'channelId', 'channel'),
|
|
16593
|
-
action:
|
|
16852
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16594
16853
|
},
|
|
16595
16854
|
{
|
|
16596
16855
|
fn: convertEventPayload((callback) => {
|
|
@@ -16610,7 +16869,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16610
16869
|
};
|
|
16611
16870
|
return onSubChannelDeleted(updateMessagePreview);
|
|
16612
16871
|
}, 'channelId', 'channel'),
|
|
16613
|
-
action:
|
|
16872
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16614
16873
|
},
|
|
16615
16874
|
{
|
|
16616
16875
|
fn: convertEventPayload((callback) => {
|
|
@@ -16629,19 +16888,48 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
16629
16888
|
};
|
|
16630
16889
|
return onSubChannelUpdated(updateMessagePreview);
|
|
16631
16890
|
}, 'channelId', 'channel'),
|
|
16632
|
-
action:
|
|
16891
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16633
16892
|
},
|
|
16634
16893
|
{
|
|
16635
16894
|
fn: convertEventPayload(onUserFeedMarkerUpdated, 'entityId', 'channel'),
|
|
16636
|
-
action:
|
|
16895
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16637
16896
|
},
|
|
16638
16897
|
{
|
|
16639
16898
|
fn: convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
|
|
16640
|
-
action:
|
|
16899
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
16900
|
+
},
|
|
16901
|
+
{
|
|
16902
|
+
fn: onChannelFetched,
|
|
16903
|
+
action: "onFetch" /* Amity.ChannelActionType.OnFetch */,
|
|
16904
|
+
},
|
|
16905
|
+
{
|
|
16906
|
+
fn: (callback) => {
|
|
16907
|
+
const handleUserFeedMarkerFetch = async (marker) => {
|
|
16908
|
+
if (marker.feedMarkers) {
|
|
16909
|
+
const channelIds = marker.feedMarkers.map(feedMarker => feedMarker.entityId);
|
|
16910
|
+
const channels = channelIds
|
|
16911
|
+
.map(channelId => { var _a; return (_a = pullFromCache(['channel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
16912
|
+
.filter(Boolean);
|
|
16913
|
+
callback(channels);
|
|
16914
|
+
}
|
|
16915
|
+
};
|
|
16916
|
+
return onUserFeedMarkerFetched(handleUserFeedMarkerFetch);
|
|
16917
|
+
},
|
|
16918
|
+
action: "onUserMessageFeedMarkerFetch" /* Amity.ChannelActionType.OnUserMessageFeedMarkerFetch */,
|
|
16641
16919
|
},
|
|
16642
16920
|
];
|
|
16643
16921
|
if (this.paginationController instanceof PaginationController) {
|
|
16644
|
-
return [
|
|
16922
|
+
return [
|
|
16923
|
+
...subscriptions,
|
|
16924
|
+
{
|
|
16925
|
+
fn: (callback) => {
|
|
16926
|
+
return onChannelCreated(channel => {
|
|
16927
|
+
resolveUnreadInfoOnChannelEvent(channel, callback);
|
|
16928
|
+
});
|
|
16929
|
+
},
|
|
16930
|
+
action: "onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
16931
|
+
},
|
|
16932
|
+
];
|
|
16645
16933
|
}
|
|
16646
16934
|
return subscriptions;
|
|
16647
16935
|
}
|
|
@@ -21859,7 +22147,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
21859
22147
|
getPoll: getPoll
|
|
21860
22148
|
});
|
|
21861
22149
|
|
|
21862
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
22150
|
+
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-----";
|
|
21863
22151
|
/*
|
|
21864
22152
|
* The crypto algorithm used for importing key and signing string
|
|
21865
22153
|
*/
|