@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.esm.js
CHANGED
|
@@ -83,8 +83,8 @@ const PostContentType = Object.freeze({
|
|
|
83
83
|
|
|
84
84
|
function getVersion() {
|
|
85
85
|
try {
|
|
86
|
-
// the string ''v6.
|
|
87
|
-
return 'v6.
|
|
86
|
+
// the string ''v6.19.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
87
|
+
return 'v6.19.0-esm';
|
|
88
88
|
}
|
|
89
89
|
catch (error) {
|
|
90
90
|
return '__dev__';
|
|
@@ -20856,9 +20856,10 @@ const HIGH_PRIORITY_ANALYTIC_CACHE_KEY = ['analytic', 'high-priority'];
|
|
|
20856
20856
|
|
|
20857
20857
|
const syncEvent = async (events) => {
|
|
20858
20858
|
const client = getActiveClient();
|
|
20859
|
-
|
|
20859
|
+
const params = {
|
|
20860
20860
|
activities: events,
|
|
20861
|
-
}
|
|
20861
|
+
};
|
|
20862
|
+
await client.http.post('/api/v1/analytics/activities', params);
|
|
20862
20863
|
};
|
|
20863
20864
|
|
|
20864
20865
|
class AnalyticsEventSyncer {
|
|
@@ -20876,10 +20877,14 @@ class AnalyticsEventSyncer {
|
|
|
20876
20877
|
}, 10 * SECOND$1);
|
|
20877
20878
|
}
|
|
20878
20879
|
stop() {
|
|
20879
|
-
if (
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20880
|
+
if (this._timer) {
|
|
20881
|
+
clearInterval(this._timer);
|
|
20882
|
+
this._timer = undefined;
|
|
20883
|
+
}
|
|
20884
|
+
if (this._high_priority_timer) {
|
|
20885
|
+
clearInterval(this._high_priority_timer);
|
|
20886
|
+
this._high_priority_timer = undefined;
|
|
20887
|
+
}
|
|
20883
20888
|
}
|
|
20884
20889
|
async syncCapturedEvent() {
|
|
20885
20890
|
try {
|
|
@@ -21029,6 +21034,12 @@ class AnalyticsEventCapturer {
|
|
|
21029
21034
|
this._bufferNewSeenStoryReferenceIds = [];
|
|
21030
21035
|
}, 300);
|
|
21031
21036
|
}
|
|
21037
|
+
resetAllBuckets() {
|
|
21038
|
+
this._recentViewed = {};
|
|
21039
|
+
this._recentHighPriorityViewed = {};
|
|
21040
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
21041
|
+
dropFromCache(HIGH_PRIORITY_ANALYTIC_CACHE_KEY);
|
|
21042
|
+
}
|
|
21032
21043
|
markStoryAsViewed(story) {
|
|
21033
21044
|
this.markStory(story, "view" /* Amity.AnalyticEventActivityType.View */);
|
|
21034
21045
|
}
|
|
@@ -21067,21 +21078,23 @@ class AnalyticsEngine {
|
|
|
21067
21078
|
this._eventSyncer.start();
|
|
21068
21079
|
}
|
|
21069
21080
|
handleTokenExpired() {
|
|
21070
|
-
this.
|
|
21081
|
+
this._stopAndDestroy();
|
|
21071
21082
|
}
|
|
21072
21083
|
destroy() {
|
|
21084
|
+
this._stopAndDestroy();
|
|
21085
|
+
}
|
|
21086
|
+
_stopAndDestroy() {
|
|
21073
21087
|
this._eventSyncer.stop();
|
|
21074
|
-
|
|
21075
|
-
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
21088
|
+
this._eventCapturer.resetAllBuckets();
|
|
21076
21089
|
}
|
|
21077
21090
|
}
|
|
21078
|
-
let instance$
|
|
21091
|
+
let instance$3;
|
|
21079
21092
|
var AnalyticsEngine$1 = {
|
|
21080
21093
|
getInstance: () => {
|
|
21081
|
-
if (!instance$
|
|
21082
|
-
instance$
|
|
21094
|
+
if (!instance$3) {
|
|
21095
|
+
instance$3 = new AnalyticsEngine();
|
|
21083
21096
|
}
|
|
21084
|
-
return instance$
|
|
21097
|
+
return instance$3;
|
|
21085
21098
|
},
|
|
21086
21099
|
};
|
|
21087
21100
|
|
|
@@ -21680,12 +21693,12 @@ class MessageReadReceiptSyncEngine {
|
|
|
21680
21693
|
}
|
|
21681
21694
|
}
|
|
21682
21695
|
}
|
|
21683
|
-
let instance$
|
|
21696
|
+
let instance$2 = null;
|
|
21684
21697
|
var ReadReceiptSyncEngine = {
|
|
21685
21698
|
getInstance: () => {
|
|
21686
|
-
if (!instance$
|
|
21687
|
-
instance$
|
|
21688
|
-
return instance$
|
|
21699
|
+
if (!instance$2)
|
|
21700
|
+
instance$2 = new MessageReadReceiptSyncEngine();
|
|
21701
|
+
return instance$2;
|
|
21689
21702
|
},
|
|
21690
21703
|
};
|
|
21691
21704
|
|
|
@@ -22099,71 +22112,6 @@ const getChannelIsMentioned = (channel, marker) => {
|
|
|
22099
22112
|
: (_d = (_c = getCachedMarker(channel.channelId)) === null || _c === void 0 ? void 0 : _c.hasMentioned) !== null && _d !== void 0 ? _d : false;
|
|
22100
22113
|
};
|
|
22101
22114
|
|
|
22102
|
-
/**
|
|
22103
|
-
* ```js
|
|
22104
|
-
* import { getSubChannelMarkers } from '@amityco/ts-sdk'
|
|
22105
|
-
* const subChannelMarkers = await getSubChannelMarkers(['sch1', 'sch2'])
|
|
22106
|
-
* ```
|
|
22107
|
-
*
|
|
22108
|
-
* Fetches a paginable list of {@link Amity.SubChannelMarker} objects
|
|
22109
|
-
*
|
|
22110
|
-
* @param messageFeedIds the feed IDs of the {@link Amity.RawSubChannel} marker to fetch
|
|
22111
|
-
* @param page
|
|
22112
|
-
* @returns A page of {@link Amity.SubChannelMarker} objects
|
|
22113
|
-
*
|
|
22114
|
-
* @category Channel API
|
|
22115
|
-
* @async
|
|
22116
|
-
* @private
|
|
22117
|
-
*/
|
|
22118
|
-
const getUserMessageFeedMakers = async (channelIds) => {
|
|
22119
|
-
const client = getActiveClient();
|
|
22120
|
-
client.log('channel/getUserMessageFeedMakers', channelIds);
|
|
22121
|
-
const { data } = await client.http.get(`/api/v1/markers/user-message-feed`, {
|
|
22122
|
-
params: {
|
|
22123
|
-
channelIds,
|
|
22124
|
-
},
|
|
22125
|
-
});
|
|
22126
|
-
return data;
|
|
22127
|
-
};
|
|
22128
|
-
|
|
22129
|
-
const persistUnreadCountInfo = (payload) => {
|
|
22130
|
-
const { feedMarkers, userFeedMarkers } = payload;
|
|
22131
|
-
// calculate sub channel unread info and channel unread info
|
|
22132
|
-
if (feedMarkers.length > 0 && userFeedMarkers.length > 0) {
|
|
22133
|
-
const channelIds = [];
|
|
22134
|
-
const feedMarkerMap = new Map(feedMarkers.map(fm => [fm.feedId, fm]));
|
|
22135
|
-
userFeedMarkers.forEach(userFeedMarker => {
|
|
22136
|
-
const feedMarker = feedMarkerMap.get(userFeedMarker.feedId);
|
|
22137
|
-
if (!feedMarker)
|
|
22138
|
-
return;
|
|
22139
|
-
if (feedMarker.feedId === userFeedMarker.feedId) {
|
|
22140
|
-
const unreadCount = feedMarker.lastSegment - userFeedMarker.readToSegment;
|
|
22141
|
-
const subChannelUnreadInfo = {
|
|
22142
|
-
subChannelId: feedMarker.feedId,
|
|
22143
|
-
channelId: feedMarker.entityId,
|
|
22144
|
-
readToSegment: userFeedMarker.readToSegment,
|
|
22145
|
-
lastSegment: feedMarker.lastSegment,
|
|
22146
|
-
lastMentionSegment: userFeedMarker.lastMentionSegment,
|
|
22147
|
-
unreadCount: Math.max(0, unreadCount),
|
|
22148
|
-
isMentioned: userFeedMarker.isMentioned,
|
|
22149
|
-
isDeleted: feedMarker.isDeleted,
|
|
22150
|
-
createdAt: userFeedMarker.createdAt,
|
|
22151
|
-
updatedAt: userFeedMarker.updatedAt,
|
|
22152
|
-
};
|
|
22153
|
-
// update sub channel unread info in cache
|
|
22154
|
-
ingestInCache({ subChannelUnreadInfo: [subChannelUnreadInfo] });
|
|
22155
|
-
if (!channelIds.includes(feedMarker.entityId)) {
|
|
22156
|
-
channelIds.push(feedMarker.entityId);
|
|
22157
|
-
}
|
|
22158
|
-
}
|
|
22159
|
-
});
|
|
22160
|
-
// re-calculate channel unread info in cache
|
|
22161
|
-
channelIds.forEach(channelId => {
|
|
22162
|
-
reCalculateChannelUnreadInfo(channelId);
|
|
22163
|
-
});
|
|
22164
|
-
}
|
|
22165
|
-
};
|
|
22166
|
-
|
|
22167
22115
|
const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
22168
22116
|
const isUnreadCountSupport$2 = ({ type }) => MARKER_INCLUDED_CHANNEL_TYPE.includes(type);
|
|
22169
22117
|
function convertFromRaw$2(channel, options = { isMessagePreviewUpdated: true }) {
|
|
@@ -22198,15 +22146,6 @@ const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated:
|
|
|
22198
22146
|
const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpdated: true }) => {
|
|
22199
22147
|
const client = getActiveClient();
|
|
22200
22148
|
const networkPreviewSetting = await client.getMessagePreviewSetting(false);
|
|
22201
|
-
// if consistent mode is enabled, persist the unread count info to the cache
|
|
22202
|
-
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
22203
|
-
const queryPayload = await getUserMessageFeedMakers(rawPayload.channels.map(({ channelId }) => channelId));
|
|
22204
|
-
const { feedMarkers, userFeedMarkers } = queryPayload;
|
|
22205
|
-
persistUnreadCountInfo({
|
|
22206
|
-
feedMarkers,
|
|
22207
|
-
userFeedMarkers,
|
|
22208
|
-
});
|
|
22209
|
-
}
|
|
22210
22149
|
if (options.isMessagePreviewUpdated &&
|
|
22211
22150
|
networkPreviewSetting !== "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */ &&
|
|
22212
22151
|
rawPayload.messagePreviews &&
|
|
@@ -22274,6 +22213,7 @@ const getChannelByIds = async (channelIds) => {
|
|
|
22274
22213
|
const cachedAt = client.cache && Date.now();
|
|
22275
22214
|
if (client.cache)
|
|
22276
22215
|
ingestInCache(data, { cachedAt });
|
|
22216
|
+
fireEvent('local.channel.fetched', data.channels);
|
|
22277
22217
|
return {
|
|
22278
22218
|
data: data.channels,
|
|
22279
22219
|
cachedAt,
|
|
@@ -22344,6 +22284,44 @@ const getMessageMarkers = async (messageIds) => {
|
|
|
22344
22284
|
return { data: contentMarkers, cachedAt };
|
|
22345
22285
|
};
|
|
22346
22286
|
|
|
22287
|
+
const persistUnreadCountInfo = (payload) => {
|
|
22288
|
+
const { feedMarkers, userFeedMarkers } = payload;
|
|
22289
|
+
// calculate sub channel unread info and channel unread info
|
|
22290
|
+
if (feedMarkers.length > 0 && userFeedMarkers.length > 0) {
|
|
22291
|
+
const channelIds = [];
|
|
22292
|
+
const feedMarkerMap = new Map(feedMarkers.map(fm => [fm.feedId, fm]));
|
|
22293
|
+
userFeedMarkers.forEach(userFeedMarker => {
|
|
22294
|
+
const feedMarker = feedMarkerMap.get(userFeedMarker.feedId);
|
|
22295
|
+
if (!feedMarker)
|
|
22296
|
+
return;
|
|
22297
|
+
if (feedMarker.feedId === userFeedMarker.feedId) {
|
|
22298
|
+
const unreadCount = feedMarker.lastSegment - userFeedMarker.readToSegment;
|
|
22299
|
+
const subChannelUnreadInfo = {
|
|
22300
|
+
subChannelId: feedMarker.feedId,
|
|
22301
|
+
channelId: feedMarker.entityId,
|
|
22302
|
+
readToSegment: userFeedMarker.readToSegment,
|
|
22303
|
+
lastSegment: feedMarker.lastSegment,
|
|
22304
|
+
lastMentionSegment: userFeedMarker.lastMentionSegment,
|
|
22305
|
+
unreadCount: Math.max(0, unreadCount),
|
|
22306
|
+
isMentioned: userFeedMarker.isMentioned,
|
|
22307
|
+
isDeleted: feedMarker.isDeleted,
|
|
22308
|
+
createdAt: userFeedMarker.createdAt,
|
|
22309
|
+
updatedAt: userFeedMarker.updatedAt,
|
|
22310
|
+
};
|
|
22311
|
+
// update sub channel unread info in cache
|
|
22312
|
+
ingestInCache({ subChannelUnreadInfo: [subChannelUnreadInfo] });
|
|
22313
|
+
if (!channelIds.includes(feedMarker.entityId)) {
|
|
22314
|
+
channelIds.push(feedMarker.entityId);
|
|
22315
|
+
}
|
|
22316
|
+
}
|
|
22317
|
+
});
|
|
22318
|
+
// re-calculate channel unread info in cache
|
|
22319
|
+
channelIds.forEach(channelId => {
|
|
22320
|
+
reCalculateChannelUnreadInfo(channelId);
|
|
22321
|
+
});
|
|
22322
|
+
}
|
|
22323
|
+
};
|
|
22324
|
+
|
|
22347
22325
|
/**
|
|
22348
22326
|
* ```js
|
|
22349
22327
|
* import { getSubChannelMarkers } from '@amityco/ts-sdk'
|
|
@@ -22710,13 +22688,13 @@ class SessionWatcher {
|
|
|
22710
22688
|
this._listener.clear();
|
|
22711
22689
|
}
|
|
22712
22690
|
}
|
|
22713
|
-
let instance;
|
|
22691
|
+
let instance$1;
|
|
22714
22692
|
var SessionWatcher$1 = {
|
|
22715
22693
|
getInstance: () => {
|
|
22716
|
-
if (!instance) {
|
|
22717
|
-
instance = new SessionWatcher();
|
|
22694
|
+
if (!instance$1) {
|
|
22695
|
+
instance$1 = new SessionWatcher();
|
|
22718
22696
|
}
|
|
22719
|
-
return instance;
|
|
22697
|
+
return instance$1;
|
|
22720
22698
|
},
|
|
22721
22699
|
};
|
|
22722
22700
|
|
|
@@ -23619,6 +23597,174 @@ var readReceiptSyncEngineOnLoginHandler = () => {
|
|
|
23619
23597
|
};
|
|
23620
23598
|
};
|
|
23621
23599
|
|
|
23600
|
+
const onOffline = (callback) => {
|
|
23601
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
23602
|
+
window.addEventListener('offline', callback);
|
|
23603
|
+
return () => window.removeEventListener('offline', callback);
|
|
23604
|
+
}
|
|
23605
|
+
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
23606
|
+
document.addEventListener('offline', callback);
|
|
23607
|
+
return () => document.removeEventListener('offline', callback);
|
|
23608
|
+
}
|
|
23609
|
+
// Handle unsupported environment
|
|
23610
|
+
console.error('Unsupported environment');
|
|
23611
|
+
return () => console.error('Unsupported environment');
|
|
23612
|
+
};
|
|
23613
|
+
|
|
23614
|
+
/**
|
|
23615
|
+
* ```js
|
|
23616
|
+
* import { getSubChannelMarkers } from '@amityco/ts-sdk'
|
|
23617
|
+
* const subChannelMarkers = await getSubChannelMarkers(['sch1', 'sch2'])
|
|
23618
|
+
* ```
|
|
23619
|
+
*
|
|
23620
|
+
* Fetches a paginable list of {@link Amity.SubChannelMarker} objects
|
|
23621
|
+
*
|
|
23622
|
+
* @param messageFeedIds the feed IDs of the {@link Amity.RawSubChannel} marker to fetch
|
|
23623
|
+
* @param page
|
|
23624
|
+
* @returns A page of {@link Amity.SubChannelMarker} objects
|
|
23625
|
+
*
|
|
23626
|
+
* @category Channel API
|
|
23627
|
+
* @async
|
|
23628
|
+
* @private
|
|
23629
|
+
*/
|
|
23630
|
+
const getUserMessageFeedMakers = async (channelIds) => {
|
|
23631
|
+
const client = getActiveClient();
|
|
23632
|
+
client.log('channel/getUserMessageFeedMakers', channelIds);
|
|
23633
|
+
const { data } = await client.http.get(`/api/v1/markers/user-message-feed`, {
|
|
23634
|
+
params: {
|
|
23635
|
+
channelIds,
|
|
23636
|
+
},
|
|
23637
|
+
});
|
|
23638
|
+
fireEvent('local.userMessageFeedMarker.fetched', { userMessageFeedMarker: data });
|
|
23639
|
+
return data;
|
|
23640
|
+
};
|
|
23641
|
+
|
|
23642
|
+
class ObjectResolverEngine {
|
|
23643
|
+
constructor() {
|
|
23644
|
+
this.TIMER_INTERVAL_MS = SECOND$1;
|
|
23645
|
+
this.BUFFER_ID_LIMIT = 100;
|
|
23646
|
+
this.buffer = {
|
|
23647
|
+
["channel" /* Amity.ReferenceType.CHANNEL */]: [],
|
|
23648
|
+
["userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */]: [],
|
|
23649
|
+
};
|
|
23650
|
+
this.isResolvingTask = false;
|
|
23651
|
+
this.connectionListener = [];
|
|
23652
|
+
this.isConnected = true;
|
|
23653
|
+
this.addConnectionListener();
|
|
23654
|
+
}
|
|
23655
|
+
startResolver() {
|
|
23656
|
+
if (!this.timer) {
|
|
23657
|
+
this.timer = setInterval(() => {
|
|
23658
|
+
if (this.isConnected)
|
|
23659
|
+
this.resolveObjects();
|
|
23660
|
+
}, this.TIMER_INTERVAL_MS);
|
|
23661
|
+
}
|
|
23662
|
+
}
|
|
23663
|
+
stopResolver() {
|
|
23664
|
+
if (this.timer) {
|
|
23665
|
+
clearInterval(this.timer);
|
|
23666
|
+
this.timer = undefined;
|
|
23667
|
+
}
|
|
23668
|
+
}
|
|
23669
|
+
resolve(id, referenceType) {
|
|
23670
|
+
const objectIdList = this.getBuffer(referenceType);
|
|
23671
|
+
if (objectIdList.includes(id))
|
|
23672
|
+
return;
|
|
23673
|
+
if (objectIdList.length >= this.BUFFER_ID_LIMIT) {
|
|
23674
|
+
objectIdList.shift(); // Remove first element of the array
|
|
23675
|
+
}
|
|
23676
|
+
objectIdList.push(id);
|
|
23677
|
+
}
|
|
23678
|
+
addConnectionListener() {
|
|
23679
|
+
if (this.connectionListener.length > 0)
|
|
23680
|
+
return;
|
|
23681
|
+
this.connectionListener.push(onOnline(() => {
|
|
23682
|
+
this.isConnected = true;
|
|
23683
|
+
}));
|
|
23684
|
+
this.connectionListener.push(onOffline(() => {
|
|
23685
|
+
this.isConnected = false;
|
|
23686
|
+
}));
|
|
23687
|
+
}
|
|
23688
|
+
removeConnectionListener() {
|
|
23689
|
+
if (this.connectionListener.length > 0)
|
|
23690
|
+
this.connectionListener.forEach(listener => listener());
|
|
23691
|
+
}
|
|
23692
|
+
resolveObjects() {
|
|
23693
|
+
if (this.isResolvingTask) {
|
|
23694
|
+
return;
|
|
23695
|
+
}
|
|
23696
|
+
this.isResolvingTask = true;
|
|
23697
|
+
// Get first 100 ids for all reference type supported.
|
|
23698
|
+
const channelIds = this.getBuffer("channel" /* Amity.ReferenceType.CHANNEL */);
|
|
23699
|
+
const userMessageFeedMarkerIds = this.getBuffer("userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */);
|
|
23700
|
+
// Clear buffer
|
|
23701
|
+
this.clearBuffer();
|
|
23702
|
+
// Send Requests.
|
|
23703
|
+
// Incase of failure: Ignore
|
|
23704
|
+
// Incase of success: Persist in Domain DB & Notify Live collection
|
|
23705
|
+
if (channelIds.length > 0)
|
|
23706
|
+
getChannelByIds(channelIds);
|
|
23707
|
+
if (userMessageFeedMarkerIds.length > 0)
|
|
23708
|
+
getUserMessageFeedMakers(userMessageFeedMarkerIds);
|
|
23709
|
+
// After sending request
|
|
23710
|
+
this.isResolvingTask = false;
|
|
23711
|
+
}
|
|
23712
|
+
clearBuffer() {
|
|
23713
|
+
this.buffer = {
|
|
23714
|
+
["channel" /* Amity.ReferenceType.CHANNEL */]: [],
|
|
23715
|
+
["userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */]: [],
|
|
23716
|
+
};
|
|
23717
|
+
}
|
|
23718
|
+
getBuffer(referenceType) {
|
|
23719
|
+
return this.buffer[referenceType];
|
|
23720
|
+
}
|
|
23721
|
+
// Session Management : SessionComponent
|
|
23722
|
+
onSessionEstablished() {
|
|
23723
|
+
this.startResolver();
|
|
23724
|
+
this.addConnectionListener();
|
|
23725
|
+
}
|
|
23726
|
+
onSessionDestroyed() {
|
|
23727
|
+
// Stop timer
|
|
23728
|
+
this.stopResolver();
|
|
23729
|
+
// Clear buffer
|
|
23730
|
+
this.clearBuffer();
|
|
23731
|
+
// Reset state
|
|
23732
|
+
this.isResolvingTask = false;
|
|
23733
|
+
// remove connection listener
|
|
23734
|
+
this.removeConnectionListener();
|
|
23735
|
+
}
|
|
23736
|
+
onTokenExpired() {
|
|
23737
|
+
this.stopResolver();
|
|
23738
|
+
}
|
|
23739
|
+
}
|
|
23740
|
+
let instance = null;
|
|
23741
|
+
var ObjectResolverEngine$1 = {
|
|
23742
|
+
getInstance: () => {
|
|
23743
|
+
if (!instance)
|
|
23744
|
+
instance = new ObjectResolverEngine();
|
|
23745
|
+
return instance;
|
|
23746
|
+
},
|
|
23747
|
+
};
|
|
23748
|
+
|
|
23749
|
+
var objectResolverEngineOnLoginHandler = () => {
|
|
23750
|
+
const objectResolverEngine = ObjectResolverEngine$1.getInstance();
|
|
23751
|
+
objectResolverEngine.startResolver();
|
|
23752
|
+
onSessionStateChange(state => {
|
|
23753
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
23754
|
+
objectResolverEngine.onSessionEstablished();
|
|
23755
|
+
}
|
|
23756
|
+
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
23757
|
+
objectResolverEngine.onTokenExpired();
|
|
23758
|
+
}
|
|
23759
|
+
else {
|
|
23760
|
+
objectResolverEngine.onSessionDestroyed();
|
|
23761
|
+
}
|
|
23762
|
+
});
|
|
23763
|
+
return () => {
|
|
23764
|
+
objectResolverEngine.onSessionDestroyed();
|
|
23765
|
+
};
|
|
23766
|
+
};
|
|
23767
|
+
|
|
23622
23768
|
/* begin_public_function
|
|
23623
23769
|
id: client.logout
|
|
23624
23770
|
*/
|
|
@@ -24218,22 +24364,21 @@ const onMessageCreatedLocal = (callback) => {
|
|
|
24218
24364
|
};
|
|
24219
24365
|
};
|
|
24220
24366
|
|
|
24221
|
-
const persistOptimisticUnreadInfo = (
|
|
24222
|
-
|
|
24223
|
-
|
|
24224
|
-
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
|
|
24228
|
-
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
|
|
24232
|
-
|
|
24233
|
-
|
|
24234
|
-
|
|
24235
|
-
|
|
24236
|
-
});
|
|
24367
|
+
const persistOptimisticUnreadInfo = (subChannelOptimisticInfo) => {
|
|
24368
|
+
const { channelId, subChannelId, createdAt, updatedAt } = subChannelOptimisticInfo;
|
|
24369
|
+
const subChannelUnreadInfo = {
|
|
24370
|
+
channelId,
|
|
24371
|
+
subChannelId,
|
|
24372
|
+
unreadCount: 0,
|
|
24373
|
+
readToSegment: 0,
|
|
24374
|
+
lastMentionSegment: 0,
|
|
24375
|
+
lastSegment: 0,
|
|
24376
|
+
isMentioned: false,
|
|
24377
|
+
isDeleted: false,
|
|
24378
|
+
createdAt,
|
|
24379
|
+
updatedAt,
|
|
24380
|
+
};
|
|
24381
|
+
pushToCache(['subChannelUnreadInfo', 'get', subChannelUnreadInfo.subChannelId], subChannelUnreadInfo);
|
|
24237
24382
|
};
|
|
24238
24383
|
|
|
24239
24384
|
/**
|
|
@@ -24257,7 +24402,14 @@ const onSubChannelCreated = (callback) => {
|
|
|
24257
24402
|
const payload = await prepareSubChannelPayload(rawPayload);
|
|
24258
24403
|
// optimistically create subChannelUnreadInfo
|
|
24259
24404
|
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
24260
|
-
|
|
24405
|
+
rawPayload.messageFeeds.forEach(subChannel => {
|
|
24406
|
+
persistOptimisticUnreadInfo({
|
|
24407
|
+
channelId: subChannel.channelId,
|
|
24408
|
+
subChannelId: subChannel.messageFeedId,
|
|
24409
|
+
createdAt: subChannel.createdAt,
|
|
24410
|
+
updatedAt: subChannel.updatedAt,
|
|
24411
|
+
});
|
|
24412
|
+
});
|
|
24261
24413
|
}
|
|
24262
24414
|
ingestInCache(payload);
|
|
24263
24415
|
callback(payload.messageFeeds[0]);
|
|
@@ -24673,7 +24825,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
24673
24825
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
24674
24826
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
24675
24827
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
24676
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), readReceiptSyncEngineOnLoginHandler());
|
|
24828
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), readReceiptSyncEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
|
|
24677
24829
|
const markerSyncUnsubscriber = await startMarkerSync();
|
|
24678
24830
|
subscriptions.push(markerSyncUnsubscriber);
|
|
24679
24831
|
}
|
|
@@ -25239,6 +25391,7 @@ const liveObject = (id, callback, key, fetcher, eventHandlers, options) => {
|
|
|
25239
25391
|
dispatcher({ loading: false, data: eventModel, origin: 'event' });
|
|
25240
25392
|
};
|
|
25241
25393
|
const onFetch = () => {
|
|
25394
|
+
// TODO: Ihis `@ts-ignore` is bring back to fix the build and it needs to be removed later
|
|
25242
25395
|
// @ts-ignore
|
|
25243
25396
|
const query = createQuery(fetcher, id, true);
|
|
25244
25397
|
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
@@ -29507,6 +29660,18 @@ const updateChannel = async (channelId, patch) => {
|
|
|
29507
29660
|
};
|
|
29508
29661
|
/* end_public_function */
|
|
29509
29662
|
|
|
29663
|
+
const prepareUnreadCountInfo = async (rawPayload) => {
|
|
29664
|
+
const client = getActiveClient();
|
|
29665
|
+
// if consistent mode is enabled, persist the unread count info to the cache
|
|
29666
|
+
const queryPayload = await getUserMessageFeedMakers(rawPayload.channels.map(({ channelId }) => channelId));
|
|
29667
|
+
const { feedMarkers, userFeedMarkers } = queryPayload;
|
|
29668
|
+
persistUnreadCountInfo({
|
|
29669
|
+
feedMarkers,
|
|
29670
|
+
userFeedMarkers,
|
|
29671
|
+
});
|
|
29672
|
+
client.log('channel/prepareUnreadCountInfo', rawPayload.channels);
|
|
29673
|
+
};
|
|
29674
|
+
|
|
29510
29675
|
/**
|
|
29511
29676
|
* ```js
|
|
29512
29677
|
* import { getChannel } from '@amityco/ts-sdk'
|
|
@@ -29529,6 +29694,9 @@ const getChannel$1 = async (channelId) => {
|
|
|
29529
29694
|
try {
|
|
29530
29695
|
const { data: payload } = await client.http.get(`/api/v3/channels/${encodeURIComponent(channelId)}`);
|
|
29531
29696
|
data = await prepareChannelPayload(payload);
|
|
29697
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
29698
|
+
prepareUnreadCountInfo(payload);
|
|
29699
|
+
}
|
|
29532
29700
|
}
|
|
29533
29701
|
catch (error) {
|
|
29534
29702
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
@@ -29792,8 +29960,8 @@ const observeChannel = (channelId, callback) => {
|
|
|
29792
29960
|
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, result);
|
|
29793
29961
|
};
|
|
29794
29962
|
const disposers = [];
|
|
29795
|
-
disposers.push(onChannelUpdated(data => router({ data, loading: false, origin: 'event' },
|
|
29796
|
-
runQuery(createQuery(getChannel$1, channelId), result => result.data && router(result,
|
|
29963
|
+
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 */)));
|
|
29964
|
+
runQuery(createQuery(getChannel$1, channelId), result => result.data && router(result, "onFetch" /* Amity.ChannelActionType.OnFetch */));
|
|
29797
29965
|
return () => {
|
|
29798
29966
|
log(`observeChannel(tmpid: ${timestamp}) > dispose`);
|
|
29799
29967
|
disposers.forEach(fn => fn());
|
|
@@ -29827,7 +29995,7 @@ const observeChannels = (callback) => {
|
|
|
29827
29995
|
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, channel);
|
|
29828
29996
|
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, channel);
|
|
29829
29997
|
};
|
|
29830
|
-
disposers.push(onChannelCreated(data => router(data,
|
|
29998
|
+
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 */)));
|
|
29831
29999
|
return () => {
|
|
29832
30000
|
log(`observeChannels(tmpid: ${timestamp}) > dispose`);
|
|
29833
30001
|
disposers.forEach(fn => fn());
|
|
@@ -32344,6 +32512,16 @@ class ChannelPaginationController extends PaginationController {
|
|
|
32344
32512
|
}
|
|
32345
32513
|
}
|
|
32346
32514
|
|
|
32515
|
+
/* eslint-disable no-use-before-define */
|
|
32516
|
+
class ChannelPaginationNoPageController extends PaginationNoPageController {
|
|
32517
|
+
async getRequest(queryParams) {
|
|
32518
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/channels/list`, {
|
|
32519
|
+
params: Object.assign({}, queryParams),
|
|
32520
|
+
});
|
|
32521
|
+
return queryResponse;
|
|
32522
|
+
}
|
|
32523
|
+
}
|
|
32524
|
+
|
|
32347
32525
|
/* eslint-disable no-use-before-define */
|
|
32348
32526
|
class ChannelQueryStreamController extends QueryStreamController {
|
|
32349
32527
|
constructor(query, cacheKey, notifyChange, preparePayload, paginationController) {
|
|
@@ -32379,11 +32557,22 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
32379
32557
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32380
32558
|
if (!collection)
|
|
32381
32559
|
return;
|
|
32382
|
-
if (this.paginationController instanceof
|
|
32383
|
-
|
|
32384
|
-
|
|
32385
|
-
|
|
32560
|
+
if (this.paginationController instanceof ChannelPaginationNoPageController)
|
|
32561
|
+
return this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
32562
|
+
if ([
|
|
32563
|
+
"onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
32564
|
+
"onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
32565
|
+
"onFetch" /* Amity.ChannelActionType.OnFetch */,
|
|
32566
|
+
"onUserMessageFeedMarkerFetch" /* Amity.ChannelActionType.OnUserMessageFeedMarkerFetch */,
|
|
32567
|
+
].includes(action)) {
|
|
32568
|
+
if (Array.isArray(payload))
|
|
32569
|
+
collection.data = [
|
|
32570
|
+
...new Set([...payload.map(({ channelId }) => channelId), ...collection.data]),
|
|
32571
|
+
];
|
|
32572
|
+
else
|
|
32573
|
+
collection.data = [...new Set([payload.channelId, ...collection.data])];
|
|
32386
32574
|
}
|
|
32575
|
+
pushToCache(this.cacheKey, collection);
|
|
32387
32576
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
32388
32577
|
};
|
|
32389
32578
|
}
|
|
@@ -32392,15 +32581,63 @@ class ChannelQueryStreamController extends QueryStreamController {
|
|
|
32392
32581
|
}
|
|
32393
32582
|
}
|
|
32394
32583
|
|
|
32395
|
-
|
|
32396
|
-
|
|
32397
|
-
|
|
32398
|
-
|
|
32399
|
-
|
|
32400
|
-
|
|
32401
|
-
|
|
32584
|
+
/**
|
|
32585
|
+
* ```js
|
|
32586
|
+
* import { onChannelFetched } from '@amityco/ts-sdk'
|
|
32587
|
+
* const dispose = onChannelFetched(channel => {
|
|
32588
|
+
* // ...
|
|
32589
|
+
* })
|
|
32590
|
+
* ```
|
|
32591
|
+
*
|
|
32592
|
+
* Fired when any {@link Amity.Channel} list have been fetched
|
|
32593
|
+
*
|
|
32594
|
+
* @param callback The function to call when the event was fired
|
|
32595
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
32596
|
+
*
|
|
32597
|
+
* @category Channel Events
|
|
32598
|
+
*/
|
|
32599
|
+
const onChannelFetched = (callback) => {
|
|
32600
|
+
const client = getActiveClient();
|
|
32601
|
+
const filter = async (payload) => {
|
|
32602
|
+
callback(payload);
|
|
32603
|
+
};
|
|
32604
|
+
return createEventSubscriber(client, 'onChannelFetched', 'local.channel.fetched', filter);
|
|
32605
|
+
};
|
|
32606
|
+
|
|
32607
|
+
/**
|
|
32608
|
+
* ```js
|
|
32609
|
+
* import { onFeedMarkerUpdated } from '@amityco/ts-sdk'
|
|
32610
|
+
* const dispose = onFeedMarkerUpdated(feedMarker => {
|
|
32611
|
+
* // ...
|
|
32612
|
+
* })
|
|
32613
|
+
* ```
|
|
32614
|
+
*
|
|
32615
|
+
* Fired when an {@link Amity.UserMessageFeedMarkerPayload} has been updated
|
|
32616
|
+
*
|
|
32617
|
+
* @param callback The function to call when the event was fired
|
|
32618
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
32619
|
+
*
|
|
32620
|
+
* @category FeedMarker Events
|
|
32621
|
+
*/
|
|
32622
|
+
const onUserFeedMarkerFetched = (callback) => {
|
|
32623
|
+
const client = getActiveClient();
|
|
32624
|
+
const filter = (payload) => {
|
|
32625
|
+
// update sub channel unread info and channel unread info in cache
|
|
32626
|
+
persistUnreadCountInfo(payload.userMessageFeedMarker);
|
|
32627
|
+
callback(payload.userMessageFeedMarker);
|
|
32628
|
+
};
|
|
32629
|
+
return createEventSubscriber(client, 'feedMarker/onUserFeedMarkerFetched', 'local.userMessageFeedMarker.fetched', filter);
|
|
32630
|
+
};
|
|
32631
|
+
|
|
32632
|
+
const resolveUnreadInfoOnChannelEvent = (channel, callback) => {
|
|
32633
|
+
const client = getActiveClient();
|
|
32634
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
32635
|
+
const objectResolverEngine = ObjectResolverEngine$1.getInstance();
|
|
32636
|
+
objectResolverEngine.resolve(channel.channelId, "userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */);
|
|
32402
32637
|
}
|
|
32403
|
-
|
|
32638
|
+
else
|
|
32639
|
+
callback(channel);
|
|
32640
|
+
};
|
|
32404
32641
|
|
|
32405
32642
|
/* eslint-disable no-use-before-define */
|
|
32406
32643
|
class ChannelLiveCollectionController extends LiveCollectionController {
|
|
@@ -32410,7 +32647,18 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32410
32647
|
const paginationController = ChannelLiveCollectionController.getPaginationController(query);
|
|
32411
32648
|
super(paginationController, queryStreamId, cacheKey, callback);
|
|
32412
32649
|
this.query = query;
|
|
32413
|
-
this.queryStreamController = new ChannelQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this),
|
|
32650
|
+
this.queryStreamController = new ChannelQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), async (channel) => {
|
|
32651
|
+
try {
|
|
32652
|
+
const client = getActiveClient();
|
|
32653
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
32654
|
+
await prepareUnreadCountInfo(channel);
|
|
32655
|
+
}
|
|
32656
|
+
}
|
|
32657
|
+
catch (e) {
|
|
32658
|
+
console.error('Error while preparing unread count info', e);
|
|
32659
|
+
}
|
|
32660
|
+
return prepareChannelPayload(channel);
|
|
32661
|
+
}, paginationController);
|
|
32414
32662
|
this.paginationController = paginationController;
|
|
32415
32663
|
this.callback = callback.bind(this);
|
|
32416
32664
|
this.loadPage(true);
|
|
@@ -32534,15 +32782,19 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32534
32782
|
'get',
|
|
32535
32783
|
message.channelId,
|
|
32536
32784
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
32537
|
-
if (!cacheData)
|
|
32538
|
-
|
|
32539
|
-
|
|
32540
|
-
|
|
32541
|
-
|
|
32542
|
-
|
|
32785
|
+
if (!cacheData) {
|
|
32786
|
+
const objectResolverEngine = ObjectResolverEngine$1.getInstance();
|
|
32787
|
+
objectResolverEngine.resolve(message.channelId, "channel" /* Amity.ReferenceType.CHANNEL */);
|
|
32788
|
+
}
|
|
32789
|
+
else {
|
|
32790
|
+
updateChannelCache(cacheData, {
|
|
32791
|
+
lastActivity: message.createdAt,
|
|
32792
|
+
});
|
|
32793
|
+
callback(message);
|
|
32794
|
+
}
|
|
32543
32795
|
});
|
|
32544
32796
|
}, 'messageId', 'channel'),
|
|
32545
|
-
action:
|
|
32797
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32546
32798
|
},
|
|
32547
32799
|
{
|
|
32548
32800
|
// TODO: merge this code to another onMessageCreated in this file
|
|
@@ -32562,12 +32814,19 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32562
32814
|
callback(message);
|
|
32563
32815
|
});
|
|
32564
32816
|
}, 'messageId', 'channel'),
|
|
32565
|
-
action:
|
|
32817
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32818
|
+
},
|
|
32819
|
+
{ fn: onChannelDeleted, action: "onDelete" /* Amity.ChannelActionType.OnDelete */ },
|
|
32820
|
+
{ fn: onChannelUpdated, action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */ },
|
|
32821
|
+
{ fn: onChannelMuted, action: "onMute" /* Amity.ChannelActionType.OnMute */ },
|
|
32822
|
+
{
|
|
32823
|
+
fn: (callback) => {
|
|
32824
|
+
return onChannelJoined(channel => {
|
|
32825
|
+
resolveUnreadInfoOnChannelEvent(channel, callback);
|
|
32826
|
+
});
|
|
32827
|
+
},
|
|
32828
|
+
action: "onJoin" /* Amity.ChannelActionType.OnJoin */,
|
|
32566
32829
|
},
|
|
32567
|
-
{ fn: onChannelDeleted, action: 'onDelete' },
|
|
32568
|
-
{ fn: onChannelUpdated, action: 'onUpdate' },
|
|
32569
|
-
{ fn: onChannelMuted, action: 'onMute' },
|
|
32570
|
-
{ fn: onChannelJoined, action: 'onJoin' },
|
|
32571
32830
|
{
|
|
32572
32831
|
fn: (reactor) => {
|
|
32573
32832
|
const callback = (channel, member) => {
|
|
@@ -32582,17 +32841,17 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32582
32841
|
};
|
|
32583
32842
|
return onChannelLeft(callback);
|
|
32584
32843
|
},
|
|
32585
|
-
action:
|
|
32844
|
+
action: "onLeft" /* Amity.ChannelActionType.OnLeft */,
|
|
32586
32845
|
},
|
|
32587
|
-
{ fn: onChannelMemberAdded, action:
|
|
32588
|
-
{ fn: onChannelMemberRemoved, action:
|
|
32846
|
+
{ fn: onChannelMemberAdded, action: "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */ },
|
|
32847
|
+
{ fn: onChannelMemberRemoved, action: "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */ },
|
|
32589
32848
|
{
|
|
32590
32849
|
fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
|
|
32591
|
-
action:
|
|
32850
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32592
32851
|
},
|
|
32593
32852
|
{
|
|
32594
32853
|
fn: convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
|
|
32595
|
-
action:
|
|
32854
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32596
32855
|
},
|
|
32597
32856
|
{
|
|
32598
32857
|
fn: convertEventPayload((callback) => {
|
|
@@ -32618,7 +32877,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32618
32877
|
};
|
|
32619
32878
|
return onMessageCreatedMqtt(updateMessagePreview);
|
|
32620
32879
|
}, 'channelId', 'channel'),
|
|
32621
|
-
action:
|
|
32880
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32622
32881
|
},
|
|
32623
32882
|
{
|
|
32624
32883
|
fn: convertEventPayload((callback) => {
|
|
@@ -32644,7 +32903,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32644
32903
|
};
|
|
32645
32904
|
return onMessageCreatedLocal(updateMessagePreview);
|
|
32646
32905
|
}, 'channelId', 'channel'),
|
|
32647
|
-
action:
|
|
32906
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32648
32907
|
},
|
|
32649
32908
|
{
|
|
32650
32909
|
fn: convertEventPayload((callback) => {
|
|
@@ -32659,7 +32918,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32659
32918
|
};
|
|
32660
32919
|
return onMessageUpdated(updateMessagePreview);
|
|
32661
32920
|
}, 'channelId', 'channel'),
|
|
32662
|
-
action:
|
|
32921
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32663
32922
|
},
|
|
32664
32923
|
{
|
|
32665
32924
|
fn: convertEventPayload((callback) => {
|
|
@@ -32680,7 +32939,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32680
32939
|
};
|
|
32681
32940
|
return onMessageDeleted(updateMessagePreview);
|
|
32682
32941
|
}, 'channelId', 'channel'),
|
|
32683
|
-
action:
|
|
32942
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32684
32943
|
},
|
|
32685
32944
|
{
|
|
32686
32945
|
fn: convertEventPayload((callback) => {
|
|
@@ -32700,7 +32959,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32700
32959
|
};
|
|
32701
32960
|
return onSubChannelDeleted(updateMessagePreview);
|
|
32702
32961
|
}, 'channelId', 'channel'),
|
|
32703
|
-
action:
|
|
32962
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32704
32963
|
},
|
|
32705
32964
|
{
|
|
32706
32965
|
fn: convertEventPayload((callback) => {
|
|
@@ -32719,19 +32978,48 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
32719
32978
|
};
|
|
32720
32979
|
return onSubChannelUpdated(updateMessagePreview);
|
|
32721
32980
|
}, 'channelId', 'channel'),
|
|
32722
|
-
action:
|
|
32981
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32723
32982
|
},
|
|
32724
32983
|
{
|
|
32725
32984
|
fn: convertEventPayload(onUserFeedMarkerUpdated, 'entityId', 'channel'),
|
|
32726
|
-
action:
|
|
32985
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32727
32986
|
},
|
|
32728
32987
|
{
|
|
32729
32988
|
fn: convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
|
|
32730
|
-
action:
|
|
32989
|
+
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
32990
|
+
},
|
|
32991
|
+
{
|
|
32992
|
+
fn: onChannelFetched,
|
|
32993
|
+
action: "onFetch" /* Amity.ChannelActionType.OnFetch */,
|
|
32994
|
+
},
|
|
32995
|
+
{
|
|
32996
|
+
fn: (callback) => {
|
|
32997
|
+
const handleUserFeedMarkerFetch = async (marker) => {
|
|
32998
|
+
if (marker.feedMarkers) {
|
|
32999
|
+
const channelIds = marker.feedMarkers.map(feedMarker => feedMarker.entityId);
|
|
33000
|
+
const channels = channelIds
|
|
33001
|
+
.map(channelId => { var _a; return (_a = pullFromCache(['channel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
33002
|
+
.filter(Boolean);
|
|
33003
|
+
callback(channels);
|
|
33004
|
+
}
|
|
33005
|
+
};
|
|
33006
|
+
return onUserFeedMarkerFetched(handleUserFeedMarkerFetch);
|
|
33007
|
+
},
|
|
33008
|
+
action: "onUserMessageFeedMarkerFetch" /* Amity.ChannelActionType.OnUserMessageFeedMarkerFetch */,
|
|
32731
33009
|
},
|
|
32732
33010
|
];
|
|
32733
33011
|
if (this.paginationController instanceof PaginationController) {
|
|
32734
|
-
return [
|
|
33012
|
+
return [
|
|
33013
|
+
...subscriptions,
|
|
33014
|
+
{
|
|
33015
|
+
fn: (callback) => {
|
|
33016
|
+
return onChannelCreated(channel => {
|
|
33017
|
+
resolveUnreadInfoOnChannelEvent(channel, callback);
|
|
33018
|
+
});
|
|
33019
|
+
},
|
|
33020
|
+
action: "onCreate" /* Amity.ChannelActionType.OnCreate */,
|
|
33021
|
+
},
|
|
33022
|
+
];
|
|
32735
33023
|
}
|
|
32736
33024
|
return subscriptions;
|
|
32737
33025
|
}
|
|
@@ -37949,7 +38237,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
37949
38237
|
getPoll: getPoll
|
|
37950
38238
|
});
|
|
37951
38239
|
|
|
37952
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
38240
|
+
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-----";
|
|
37953
38241
|
/*
|
|
37954
38242
|
* The crypto algorithm used for importing key and signing string
|
|
37955
38243
|
*/
|