@amityco/ts-sdk 7.1.1-207e990f.0 → 7.1.1-5d7c3fd0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +1 -2
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +0 -2
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/readReceipt.d.ts +1 -12
- package/dist/@types/core/readReceipt.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +0 -10
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelDeleted.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelLeft.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/utils/constructChannelDynamicValue.d.ts.map +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +1 -0
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/enableUnreadCount.d.ts.map +1 -1
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts +4 -2
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
- package/dist/client/utils/endpoints.d.ts +1 -0
- package/dist/client/utils/endpoints.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/index.cjs.js +65 -412
- package/dist/index.esm.js +65 -412
- package/dist/index.umd.js +4 -4
- package/dist/{channelRepository → marker}/events/onChannelUnreadUpdatedLocal.d.ts +2 -2
- package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts.map +1 -0
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/utils/markReadMessage.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +1 -2
- package/src/@types/core/model.ts +0 -4
- package/src/@types/core/readReceipt.ts +1 -14
- package/src/@types/domains/channel.ts +0 -13
- package/src/@types/domains/client.ts +1 -2
- package/src/channelRepository/events/onChannelDeleted.ts +4 -17
- package/src/channelRepository/events/onChannelLeft.ts +3 -11
- package/src/channelRepository/observers/getChannel.ts +1 -3
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +1 -6
- package/src/channelRepository/utils/constructChannelDynamicValue.ts +2 -12
- package/src/channelRepository/utils/prepareChannelPayload.ts +17 -57
- package/src/client/api/createClient.ts +4 -4
- package/src/client/api/enableUnreadCount.ts +0 -1
- package/src/client/api/login.ts +1 -5
- package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +99 -70
- package/src/client/utils/endpoints.ts +1 -0
- package/src/client/utils/setClientToken.ts +8 -0
- package/src/core/model/idResolvers.ts +0 -2
- package/src/fileRepository/api/uploadFile.ts +1 -1
- package/src/fileRepository/api/uploadImage.ts +1 -1
- package/src/fileRepository/api/uploadVideo.ts +1 -1
- package/src/{channelRepository → marker}/events/onChannelUnreadUpdatedLocal.ts +3 -3
- package/src/messageRepository/events/onMessageCreated.ts +0 -34
- package/src/messageRepository/utils/markReadMessage.ts +3 -10
- package/dist/channelRepository/api/markChannelsAsReadBySegment.d.ts +0 -16
- package/dist/channelRepository/api/markChannelsAsReadBySegment.d.ts.map +0 -1
- package/dist/channelRepository/events/onChannelUnreadUpdatedLocal.d.ts.map +0 -1
- package/dist/channelRepository/utils/getLegacyChannelUnread.d.ts +0 -2
- package/dist/channelRepository/utils/getLegacyChannelUnread.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +0 -33
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +0 -3
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/marker/events/onChannelUnreadInfoUpdatedLocal.d.ts +0 -12
- package/dist/marker/events/onChannelUnreadInfoUpdatedLocal.d.ts.map +0 -1
- package/src/channelRepository/api/markChannelsAsReadBySegment.ts +0 -29
- package/src/channelRepository/utils/getLegacyChannelUnread.ts +0 -5
- package/src/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.ts +0 -267
- package/src/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.ts +0 -21
- package/src/marker/events/onChannelUnreadInfoUpdatedLocal.ts +0 -29
package/dist/index.esm.js
CHANGED
|
@@ -501,7 +501,6 @@ const idResolvers = {
|
|
|
501
501
|
messagePreviewSubChannel: ({ subChannelId }) => `${subChannelId}`,
|
|
502
502
|
channelUnreadInfo: ({ channelId }) => channelId,
|
|
503
503
|
subChannelUnreadInfo: ({ subChannelId }) => subChannelId,
|
|
504
|
-
channelUnread: ({ channelId }) => channelId,
|
|
505
504
|
channelMarker: ({ entityId, userId }) => `${entityId}#${userId}`,
|
|
506
505
|
subChannelMarker: ({ entityId, feedId, userId }) => `${entityId}#${feedId}#${userId}`,
|
|
507
506
|
messageMarker: ({ feedId, contentId, creatorId }) => `${feedId}#${contentId}#${creatorId}`,
|
|
@@ -1547,6 +1546,7 @@ const API_REGIONS = {
|
|
|
1547
1546
|
};
|
|
1548
1547
|
const URLS = {
|
|
1549
1548
|
http: 'https://apix.{region}.amity.co',
|
|
1549
|
+
upload: 'https://upload.{region}.amity.co',
|
|
1550
1550
|
mqtt: 'wss://sse.{region}.amity.co:443/mqtt',
|
|
1551
1551
|
};
|
|
1552
1552
|
function computeUrl(type, region) {
|
|
@@ -1595,13 +1595,13 @@ class NetworkActivitiesWatcher {
|
|
|
1595
1595
|
this._listener.clear();
|
|
1596
1596
|
}
|
|
1597
1597
|
}
|
|
1598
|
-
let instance$
|
|
1598
|
+
let instance$5;
|
|
1599
1599
|
var NetworkActivitiesWatcher$1 = {
|
|
1600
1600
|
getInstance: () => {
|
|
1601
|
-
if (!instance$
|
|
1602
|
-
instance$
|
|
1601
|
+
if (!instance$5) {
|
|
1602
|
+
instance$5 = new NetworkActivitiesWatcher();
|
|
1603
1603
|
}
|
|
1604
|
-
return instance$
|
|
1604
|
+
return instance$5;
|
|
1605
1605
|
},
|
|
1606
1606
|
};
|
|
1607
1607
|
|
|
@@ -21241,13 +21241,13 @@ class AnalyticsEngine {
|
|
|
21241
21241
|
this._eventCapturer.resetAllBuckets();
|
|
21242
21242
|
}
|
|
21243
21243
|
}
|
|
21244
|
-
let instance$
|
|
21244
|
+
let instance$4;
|
|
21245
21245
|
var AnalyticsEngine$1 = {
|
|
21246
21246
|
getInstance: () => {
|
|
21247
|
-
if (!instance$
|
|
21248
|
-
instance$
|
|
21247
|
+
if (!instance$4) {
|
|
21248
|
+
instance$4 = new AnalyticsEngine();
|
|
21249
21249
|
}
|
|
21250
|
-
return instance$
|
|
21250
|
+
return instance$4;
|
|
21251
21251
|
},
|
|
21252
21252
|
};
|
|
21253
21253
|
|
|
@@ -21673,221 +21673,6 @@ const getMessageReadCount = (message, marker) => {
|
|
|
21673
21673
|
getCachedMarker$2(message)) !== null && _a !== void 0 ? _a : { readCount: 0, deliveredCount: 0 };
|
|
21674
21674
|
}; // and if not found in cache use default value `0`
|
|
21675
21675
|
|
|
21676
|
-
/**
|
|
21677
|
-
*
|
|
21678
|
-
* Mark subChannel as read by readToSegment
|
|
21679
|
-
*
|
|
21680
|
-
* @param subChannelIds the IDs of the {@link Amity.SubChannel} to update
|
|
21681
|
-
* @param readToSegment the segment to mark as read
|
|
21682
|
-
* @returns a success boolean if the {@link Amity.SubChannel} was updated
|
|
21683
|
-
*
|
|
21684
|
-
* @category Channel API
|
|
21685
|
-
* @async
|
|
21686
|
-
*/
|
|
21687
|
-
const markChannelsAsReadBySegment = async (readings) => {
|
|
21688
|
-
const client = getActiveClient();
|
|
21689
|
-
try {
|
|
21690
|
-
await client.http.post('api/v3/channels/seen', { channels: readings });
|
|
21691
|
-
return true;
|
|
21692
|
-
}
|
|
21693
|
-
catch (e) {
|
|
21694
|
-
return false;
|
|
21695
|
-
}
|
|
21696
|
-
};
|
|
21697
|
-
|
|
21698
|
-
class MessageReadReceiptSyncEngine {
|
|
21699
|
-
constructor() {
|
|
21700
|
-
this.isActive = true;
|
|
21701
|
-
this.MAX_RETRY = 3;
|
|
21702
|
-
this.JOB_QUEUE_SIZE = 120;
|
|
21703
|
-
this.jobQueue = [];
|
|
21704
|
-
// Interval for message read receipt sync in seconds
|
|
21705
|
-
this.RECEIPT_SYNC_INTERVAL = 1;
|
|
21706
|
-
this.client = getActiveClient();
|
|
21707
|
-
// Get remaining unsync read receipts from cache
|
|
21708
|
-
this.getUnsyncJobs();
|
|
21709
|
-
}
|
|
21710
|
-
// Call this when client call client.login
|
|
21711
|
-
startSyncReadReceipt() {
|
|
21712
|
-
// Start timer when start receipt sync
|
|
21713
|
-
this.timer = setInterval(() => {
|
|
21714
|
-
this.syncReadReceipts();
|
|
21715
|
-
}, this.RECEIPT_SYNC_INTERVAL * 1000);
|
|
21716
|
-
}
|
|
21717
|
-
// Read receipt observer handling
|
|
21718
|
-
syncReadReceipts() {
|
|
21719
|
-
if (this.jobQueue.length === 0 || this.isActive === false)
|
|
21720
|
-
return;
|
|
21721
|
-
const readReceipts = this.getReadReceipts();
|
|
21722
|
-
if (readReceipts) {
|
|
21723
|
-
this.markReadApi(readReceipts);
|
|
21724
|
-
}
|
|
21725
|
-
}
|
|
21726
|
-
getUnsyncJobs() {
|
|
21727
|
-
var _a;
|
|
21728
|
-
// Get all read receipts that has latestSyncSegment < latestSegment
|
|
21729
|
-
const readReceipts = (_a = queryCache(['readReceipt'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
|
|
21730
|
-
return data.latestSyncSegment < data.latestSegment;
|
|
21731
|
-
});
|
|
21732
|
-
// Enqueue unsync read receipts to the job queue
|
|
21733
|
-
readReceipts === null || readReceipts === void 0 ? void 0 : readReceipts.forEach(({ data: readReceipt }) => {
|
|
21734
|
-
this.enqueueReadReceipt(readReceipt.channelId, readReceipt.latestSegment);
|
|
21735
|
-
});
|
|
21736
|
-
}
|
|
21737
|
-
getReadReceipts() {
|
|
21738
|
-
// get all read receipts from queue, now the queue is empty
|
|
21739
|
-
const syncJob = this.jobQueue.splice(0, this.jobQueue.length);
|
|
21740
|
-
if (syncJob.length === 0)
|
|
21741
|
-
return;
|
|
21742
|
-
return syncJob.filter(job => {
|
|
21743
|
-
var _a;
|
|
21744
|
-
const readReceipt = (_a = pullFromCache(['readReceipt', job.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21745
|
-
if (!readReceipt)
|
|
21746
|
-
return false;
|
|
21747
|
-
if (readReceipt.latestSegment > readReceipt.latestSyncSegment)
|
|
21748
|
-
return true;
|
|
21749
|
-
return false;
|
|
21750
|
-
});
|
|
21751
|
-
}
|
|
21752
|
-
async markReadApi(syncJobs) {
|
|
21753
|
-
var _a;
|
|
21754
|
-
// constuct payload
|
|
21755
|
-
// example: [{ channelId: 'channelId', readToSegment: 2 }]
|
|
21756
|
-
const syncJobsPayload = syncJobs.map(job => {
|
|
21757
|
-
return {
|
|
21758
|
-
channelId: job.channelId,
|
|
21759
|
-
readToSegment: job.segment,
|
|
21760
|
-
};
|
|
21761
|
-
});
|
|
21762
|
-
const response = await markChannelsAsReadBySegment(syncJobsPayload);
|
|
21763
|
-
if (response) {
|
|
21764
|
-
for (let i = 0; i < syncJobs.length; i += 1) {
|
|
21765
|
-
// update lastestSyncSegment in read receipt cache
|
|
21766
|
-
const cacheKey = ['readReceipt', syncJobs[i].channelId];
|
|
21767
|
-
const readReceiptCache = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21768
|
-
pushToCache(cacheKey, Object.assign(Object.assign({}, readReceiptCache), { latestSyncSegment: syncJobs[i].segment }));
|
|
21769
|
-
}
|
|
21770
|
-
}
|
|
21771
|
-
else {
|
|
21772
|
-
for (let i = 0; i < syncJobs.length; i += 1) {
|
|
21773
|
-
// push them back to queue if the syncing is failed and retry count is less than max retry
|
|
21774
|
-
if (syncJobs[i].retryCount >= this.MAX_RETRY)
|
|
21775
|
-
return;
|
|
21776
|
-
const updatedJob = Object.assign(Object.assign({}, syncJobs[i]), { syncState: "create" /* Amity.ReadReceiptSyncState.CREATED */, retryCount: syncJobs[i].retryCount + 1 });
|
|
21777
|
-
this.enqueueJob(updatedJob);
|
|
21778
|
-
}
|
|
21779
|
-
}
|
|
21780
|
-
}
|
|
21781
|
-
startObservingReadReceiptQueue() {
|
|
21782
|
-
if (this.client.useLegacyUnreadCount) {
|
|
21783
|
-
this.isActive = true;
|
|
21784
|
-
this.startSyncReadReceipt();
|
|
21785
|
-
}
|
|
21786
|
-
}
|
|
21787
|
-
stopObservingReadReceiptQueue() {
|
|
21788
|
-
this.isActive = false;
|
|
21789
|
-
this.jobQueue.map(job => {
|
|
21790
|
-
if (job.syncState === "syncing" /* Amity.ReadReceiptSyncState.SYNCING */) {
|
|
21791
|
-
return Object.assign(Object.assign({}, job), { syncState: "create" /* Amity.ReadReceiptSyncState.CREATED */ });
|
|
21792
|
-
}
|
|
21793
|
-
return job;
|
|
21794
|
-
});
|
|
21795
|
-
if (this.timer)
|
|
21796
|
-
clearInterval(this.timer);
|
|
21797
|
-
}
|
|
21798
|
-
// Session Management
|
|
21799
|
-
onSessionEstablished() {
|
|
21800
|
-
this.startObservingReadReceiptQueue();
|
|
21801
|
-
}
|
|
21802
|
-
onSessionDestroyed() {
|
|
21803
|
-
this.stopObservingReadReceiptQueue();
|
|
21804
|
-
this.jobQueue = [];
|
|
21805
|
-
}
|
|
21806
|
-
onTokenExpired() {
|
|
21807
|
-
this.stopObservingReadReceiptQueue();
|
|
21808
|
-
}
|
|
21809
|
-
// Network Connection Management
|
|
21810
|
-
onNetworkOffline() {
|
|
21811
|
-
// Stop observing to the read receipt queue.
|
|
21812
|
-
this.stopObservingReadReceiptQueue();
|
|
21813
|
-
}
|
|
21814
|
-
onNetworkOnline() {
|
|
21815
|
-
// Resume observing to the read receipt queue.
|
|
21816
|
-
this.startObservingReadReceiptQueue();
|
|
21817
|
-
}
|
|
21818
|
-
markRead(channelId, segment) {
|
|
21819
|
-
var _a;
|
|
21820
|
-
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
21821
|
-
const cacheKey = ['channelUnread', 'get', channelId];
|
|
21822
|
-
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21823
|
-
if (channelUnread && segment > channelUnread.readToSegment) {
|
|
21824
|
-
channelUnread.readToSegment = segment;
|
|
21825
|
-
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
21826
|
-
pushToCache(cacheKey, channelUnread);
|
|
21827
|
-
fireEvent('local.channelUnread.updated', channelUnread);
|
|
21828
|
-
}
|
|
21829
|
-
// Step 2: Enqueue the read receipt
|
|
21830
|
-
this.enqueueReadReceipt(channelId, segment);
|
|
21831
|
-
}
|
|
21832
|
-
enqueueReadReceipt(channelId, segment) {
|
|
21833
|
-
var _a;
|
|
21834
|
-
const readReceipt = (_a = pullFromCache(['readReceipt', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21835
|
-
// Create new read receipt if it's not exists and add the job to queue
|
|
21836
|
-
if (!readReceipt) {
|
|
21837
|
-
const readReceiptChannel = {
|
|
21838
|
-
channelId,
|
|
21839
|
-
latestSegment: segment,
|
|
21840
|
-
latestSyncSegment: 0,
|
|
21841
|
-
};
|
|
21842
|
-
pushToCache(['readReceipt', channelId], readReceiptChannel);
|
|
21843
|
-
}
|
|
21844
|
-
else if (readReceipt.latestSegment < segment) {
|
|
21845
|
-
// Update latestSegment in read receipt cache
|
|
21846
|
-
pushToCache(['readReceipt', channelId], Object.assign(Object.assign({}, readReceipt), { latestSegment: segment }));
|
|
21847
|
-
}
|
|
21848
|
-
else if (readReceipt.latestSyncSegment >= segment) {
|
|
21849
|
-
// Skip the job when lastSyncSegment > = segment
|
|
21850
|
-
return;
|
|
21851
|
-
}
|
|
21852
|
-
let syncJob = this.getSyncJob(channelId);
|
|
21853
|
-
if (syncJob === null || syncJob.syncState === "syncing" /* Amity.ReadReceiptSyncState.SYNCING */) {
|
|
21854
|
-
syncJob = {
|
|
21855
|
-
channelId,
|
|
21856
|
-
segment,
|
|
21857
|
-
syncState: "create" /* Amity.ReadReceiptSyncState.CREATED */,
|
|
21858
|
-
retryCount: 0,
|
|
21859
|
-
};
|
|
21860
|
-
this.enqueueJob(syncJob);
|
|
21861
|
-
}
|
|
21862
|
-
else if (syncJob.segment < segment) {
|
|
21863
|
-
syncJob.segment = segment;
|
|
21864
|
-
}
|
|
21865
|
-
}
|
|
21866
|
-
getSyncJob(channelId) {
|
|
21867
|
-
const { jobQueue } = this;
|
|
21868
|
-
const targetJob = jobQueue.find(job => job.channelId === channelId);
|
|
21869
|
-
return targetJob || null;
|
|
21870
|
-
}
|
|
21871
|
-
enqueueJob(syncJob) {
|
|
21872
|
-
if (this.jobQueue.length < this.JOB_QUEUE_SIZE) {
|
|
21873
|
-
this.jobQueue.push(syncJob);
|
|
21874
|
-
}
|
|
21875
|
-
else {
|
|
21876
|
-
// Remove oldest job when queue reach maximum capacity
|
|
21877
|
-
this.jobQueue.shift();
|
|
21878
|
-
this.jobQueue.push(syncJob);
|
|
21879
|
-
}
|
|
21880
|
-
}
|
|
21881
|
-
}
|
|
21882
|
-
let instance$4 = null;
|
|
21883
|
-
var ReadReceiptSyncEngine = {
|
|
21884
|
-
getInstance: () => {
|
|
21885
|
-
if (!instance$4)
|
|
21886
|
-
instance$4 = new MessageReadReceiptSyncEngine();
|
|
21887
|
-
return instance$4;
|
|
21888
|
-
},
|
|
21889
|
-
};
|
|
21890
|
-
|
|
21891
21676
|
/**
|
|
21892
21677
|
*
|
|
21893
21678
|
* Mark subChannel as read by readToSegment
|
|
@@ -21936,7 +21721,7 @@ const reCalculateChannelUnreadInfo = (channelId) => {
|
|
|
21936
21721
|
return channelUnreadInfo;
|
|
21937
21722
|
};
|
|
21938
21723
|
|
|
21939
|
-
class
|
|
21724
|
+
class MessageReadReceiptSyncEngine {
|
|
21940
21725
|
constructor() {
|
|
21941
21726
|
this.isActive = true;
|
|
21942
21727
|
this.MAX_RETRY = 3;
|
|
@@ -21967,7 +21752,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
21967
21752
|
getUnsyncJobs() {
|
|
21968
21753
|
var _a;
|
|
21969
21754
|
// Get all read receipts that has latestSyncSegment < latestSegment
|
|
21970
|
-
const readReceipts = (_a = queryCache(['
|
|
21755
|
+
const readReceipts = (_a = queryCache(['readReceipt'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
|
|
21971
21756
|
return data.latestSyncSegment < data.latestSegment;
|
|
21972
21757
|
});
|
|
21973
21758
|
// Enqueue unsync read receipts to the job queue
|
|
@@ -21986,7 +21771,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
21986
21771
|
return;
|
|
21987
21772
|
// Get readReceipt from cache by subChannelId
|
|
21988
21773
|
const readReceipt = (_a = pullFromCache([
|
|
21989
|
-
'
|
|
21774
|
+
'readReceipt',
|
|
21990
21775
|
syncJob.subChannelId,
|
|
21991
21776
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21992
21777
|
if (!readReceipt)
|
|
@@ -22009,10 +21794,10 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
22009
21794
|
if (response) {
|
|
22010
21795
|
this.removeSynedReceipt(syncJob.subChannelId, syncJob.segment);
|
|
22011
21796
|
const readReceiptCache = (_a = pullFromCache([
|
|
22012
|
-
'
|
|
21797
|
+
'readReceipt',
|
|
22013
21798
|
subChannelId,
|
|
22014
21799
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22015
|
-
pushToCache(['
|
|
21800
|
+
pushToCache(['readReceipt', subChannelId], Object.assign(Object.assign({}, readReceiptCache), { latestSyncSegment: segment }));
|
|
22016
21801
|
}
|
|
22017
21802
|
else if (!response) {
|
|
22018
21803
|
if (newSyncJob.retryCount > this.MAX_RETRY) {
|
|
@@ -22079,7 +21864,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
22079
21864
|
subChannelUnreadInfo.readToSegment = segment;
|
|
22080
21865
|
subChannelUnreadInfo.unreadCount = Math.max(subChannelUnreadInfo.lastSegment - segment, 0);
|
|
22081
21866
|
const channelUnreadInfo = reCalculateChannelUnreadInfo(subChannelUnreadInfo.channelId);
|
|
22082
|
-
fireEvent('local.
|
|
21867
|
+
fireEvent('local.channelUnread.updated', channelUnreadInfo);
|
|
22083
21868
|
pushToCache(cacheKey, subChannelUnreadInfo);
|
|
22084
21869
|
fireEvent('local.subChannelUnread.updated', subChannelUnreadInfo);
|
|
22085
21870
|
}
|
|
@@ -22088,10 +21873,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
22088
21873
|
}
|
|
22089
21874
|
enqueueReadReceipt(subChannelId, segment) {
|
|
22090
21875
|
var _a;
|
|
22091
|
-
const readReceipt = (_a = pullFromCache([
|
|
22092
|
-
'legacyReadReceipt',
|
|
22093
|
-
subChannelId,
|
|
22094
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21876
|
+
const readReceipt = (_a = pullFromCache(['readReceipt', subChannelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22095
21877
|
// Create new read receipt if it's not exists and add job to queue
|
|
22096
21878
|
if (!readReceipt) {
|
|
22097
21879
|
const readReceiptSubChannel = {
|
|
@@ -22099,10 +21881,10 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
22099
21881
|
latestSegment: segment,
|
|
22100
21882
|
latestSyncSegment: 0,
|
|
22101
21883
|
};
|
|
22102
|
-
pushToCache(['
|
|
21884
|
+
pushToCache(['readReceipt', subChannelId], readReceiptSubChannel);
|
|
22103
21885
|
}
|
|
22104
21886
|
else if (readReceipt.latestSegment < segment) {
|
|
22105
|
-
pushToCache(['
|
|
21887
|
+
pushToCache(['readReceipt', subChannelId], Object.assign(Object.assign({}, readReceipt), { latestSegment: segment }));
|
|
22106
21888
|
}
|
|
22107
21889
|
else if (readReceipt.latestSyncSegment >= segment) {
|
|
22108
21890
|
// Skip the job when lastSyncSegment > = segment
|
|
@@ -22145,24 +21927,18 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
22145
21927
|
}
|
|
22146
21928
|
}
|
|
22147
21929
|
let instance$3 = null;
|
|
22148
|
-
var
|
|
21930
|
+
var ReadReceiptSyncEngine = {
|
|
22149
21931
|
getInstance: () => {
|
|
22150
21932
|
if (!instance$3)
|
|
22151
|
-
instance$3 = new
|
|
21933
|
+
instance$3 = new MessageReadReceiptSyncEngine();
|
|
22152
21934
|
return instance$3;
|
|
22153
21935
|
},
|
|
22154
21936
|
};
|
|
22155
21937
|
|
|
22156
21938
|
const markReadMessage = (message) => {
|
|
22157
|
-
const
|
|
22158
|
-
|
|
22159
|
-
|
|
22160
|
-
markReadReceiptEngine.markRead(message.channelId, message.channelSegment);
|
|
22161
|
-
}
|
|
22162
|
-
else {
|
|
22163
|
-
const markReadReceiptEngine = LegacyReadReceiptSyncEngine.getInstance();
|
|
22164
|
-
markReadReceiptEngine.markRead(message.subChannelId, message.channelSegment);
|
|
22165
|
-
}
|
|
21939
|
+
const { subChannelId, channelSegment } = message;
|
|
21940
|
+
const markReadReceiptEngine = ReadReceiptSyncEngine.getInstance();
|
|
21941
|
+
markReadReceiptEngine.markRead(subChannelId, channelSegment);
|
|
22166
21942
|
};
|
|
22167
21943
|
|
|
22168
21944
|
const messageLinkedObject = (message) => {
|
|
@@ -23150,24 +22926,6 @@ const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated:
|
|
|
23150
22926
|
channels: rawPayload.channels.map(channel => convertFromRaw(channel, { isMessagePreviewUpdated: options.isMessagePreviewUpdated })),
|
|
23151
22927
|
});
|
|
23152
22928
|
};
|
|
23153
|
-
const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
23154
|
-
for (let i = 0; i < channels.length; i += 1) {
|
|
23155
|
-
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
23156
|
-
const { readToSegment, lastMentionedSegment } = channelUsers.find(channelUser => channelUser.channelId === channels[i].channelId && channelUser.userId === currentUserId) || {
|
|
23157
|
-
readToSegment: 0,
|
|
23158
|
-
lastMentionedSegment: 0,
|
|
23159
|
-
};
|
|
23160
|
-
pushToCache(cacheKey, {
|
|
23161
|
-
channelId: channels[i].channelId,
|
|
23162
|
-
lastSegment: channels[i].messageCount,
|
|
23163
|
-
readToSegment,
|
|
23164
|
-
lastMentionedSegment,
|
|
23165
|
-
unreadCount: channels[i].messageCount - readToSegment,
|
|
23166
|
-
isMentioned: lastMentionedSegment > readToSegment,
|
|
23167
|
-
isDeleted: channels[i].isDeleted,
|
|
23168
|
-
});
|
|
23169
|
-
}
|
|
23170
|
-
};
|
|
23171
22929
|
const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpdated: true }) => {
|
|
23172
22930
|
const client = getActiveClient();
|
|
23173
22931
|
const networkPreviewSetting = await client.getMessagePreviewSetting(false);
|
|
@@ -23177,34 +22935,23 @@ const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpd
|
|
|
23177
22935
|
rawPayload.messagePreviews.length > 0) {
|
|
23178
22936
|
updateChannelMessagePreviewCache(rawPayload);
|
|
23179
22937
|
}
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
|
|
23190
|
-
|
|
23191
|
-
|
|
23192
|
-
if (markerIds.length > 0) {
|
|
23193
|
-
// since the get markers method requires a channel cache to function with the reducer.
|
|
23194
|
-
preUpdateChannelCache(rawPayload, {
|
|
23195
|
-
isMessagePreviewUpdated: options.isMessagePreviewUpdated,
|
|
23196
|
-
});
|
|
23197
|
-
try {
|
|
23198
|
-
await getChannelMarkers(markerIds);
|
|
23199
|
-
}
|
|
23200
|
-
catch (e) {
|
|
23201
|
-
// empty block (from the spec, allow marker fetch to fail without having to do anything)
|
|
23202
|
-
}
|
|
22938
|
+
const markerIds = rawPayload.channels
|
|
22939
|
+
// filter channel by type. Only conversation, community and broadcast type are included.
|
|
22940
|
+
.filter(isUnreadCountSupport)
|
|
22941
|
+
.map(({ channelInternalId }) => channelInternalId);
|
|
22942
|
+
if (markerIds.length > 0) {
|
|
22943
|
+
// since the get markers method requires a channel cache to function with the reducer.
|
|
22944
|
+
preUpdateChannelCache(rawPayload, { isMessagePreviewUpdated: options.isMessagePreviewUpdated });
|
|
22945
|
+
try {
|
|
22946
|
+
await getChannelMarkers(markerIds);
|
|
22947
|
+
}
|
|
22948
|
+
catch (e) {
|
|
22949
|
+
// empty block (from the spec, allow marker fetch to fail without having to do anything)
|
|
23203
22950
|
}
|
|
23204
22951
|
}
|
|
23205
|
-
//
|
|
22952
|
+
// attach marker to channel
|
|
23206
22953
|
const channels = rawPayload.channels.map(payload => convertFromRaw(payload, { isMessagePreviewUpdated: options.isMessagePreviewUpdated }));
|
|
23207
|
-
//
|
|
22954
|
+
// user marker to channel users
|
|
23208
22955
|
const channelUsers = rawPayload.channelUsers.map(channelUser => {
|
|
23209
22956
|
return convertRawMembershipToMembership(channelUser);
|
|
23210
22957
|
});
|
|
@@ -23331,28 +23078,15 @@ const getSubChannelsUnreadCount = (channel, marker) => {
|
|
|
23331
23078
|
return (_e = (_c = marker === null || marker === void 0 ? void 0 : marker.unreadCount) !== null && _c !== void 0 ? _c : (_d = getCachedMarker(channel.channelInternalId)) === null || _d === void 0 ? void 0 : _d.unreadCount) !== null && _e !== void 0 ? _e : 0;
|
|
23332
23079
|
};
|
|
23333
23080
|
|
|
23334
|
-
const getLegacyChannelUnread = (channelId) => {
|
|
23335
|
-
var _a;
|
|
23336
|
-
return (_a = pullFromCache(['channelUnread', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23337
|
-
};
|
|
23338
|
-
|
|
23339
23081
|
const constructChannelDynamicValue = (channel) => {
|
|
23340
|
-
const client = getActiveClient();
|
|
23341
23082
|
const rest = __rest(channel, ["messageCount"]);
|
|
23342
23083
|
return shallowClone(rest, {
|
|
23343
|
-
get
|
|
23344
|
-
|
|
23345
|
-
return (_b = (_a = getLegacyChannelUnread(rest.channelId)) === null || _a === void 0 ? void 0 : _a.unreadCount) !== null && _b !== void 0 ? _b : 0;
|
|
23084
|
+
get isMentioned() {
|
|
23085
|
+
return getChannelIsMentioned(rest);
|
|
23346
23086
|
},
|
|
23347
23087
|
get subChannelsUnreadCount() {
|
|
23348
23088
|
return getSubChannelsUnreadCount(rest);
|
|
23349
23089
|
},
|
|
23350
|
-
get isMentioned() {
|
|
23351
|
-
var _a, _b;
|
|
23352
|
-
if (client.useLegacyUnreadCount)
|
|
23353
|
-
return (_b = (_a = getLegacyChannelUnread(rest.channelId)) === null || _a === void 0 ? void 0 : _a.isMentioned) !== null && _b !== void 0 ? _b : false;
|
|
23354
|
-
return getChannelIsMentioned(rest);
|
|
23355
|
-
},
|
|
23356
23090
|
});
|
|
23357
23091
|
};
|
|
23358
23092
|
|
|
@@ -23965,6 +23699,12 @@ const setClientToken = async (params) => {
|
|
|
23965
23699
|
isGlobalBanned: false,
|
|
23966
23700
|
isUserDeleted: false,
|
|
23967
23701
|
};
|
|
23702
|
+
client.upload.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
23703
|
+
client.upload.defaults.metadata = {
|
|
23704
|
+
tokenExpiry: expiresAt,
|
|
23705
|
+
isGlobalBanned: false,
|
|
23706
|
+
isUserDeleted: false,
|
|
23707
|
+
};
|
|
23968
23708
|
// manually setup the token for ws transport
|
|
23969
23709
|
if (client.ws)
|
|
23970
23710
|
client.ws.io.opts.query = { token: accessToken };
|
|
@@ -24009,21 +23749,12 @@ const onChannelDeleted = (callback) => {
|
|
|
24009
23749
|
const client = getActiveClient();
|
|
24010
23750
|
const filter = async (payload) => {
|
|
24011
23751
|
const data = await prepareChannelPayload(payload);
|
|
24012
|
-
|
|
24013
|
-
|
|
24014
|
-
data.channels.forEach(channel => {
|
|
24015
|
-
if (isConsistentMode) {
|
|
23752
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
23753
|
+
data.channels.forEach(channel => {
|
|
24016
23754
|
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
24017
23755
|
deleteChannelUnreadByChannelId(channel.channelId);
|
|
24018
|
-
}
|
|
24019
|
-
|
|
24020
|
-
const cacheKey = ['channelUnread', 'get', channel.channelId];
|
|
24021
|
-
const cache = pullFromCache(cacheKey);
|
|
24022
|
-
if (cache) {
|
|
24023
|
-
pushToCache(cacheKey, Object.assign(Object.assign({}, cache), { isDeleted: true }));
|
|
24024
|
-
}
|
|
24025
|
-
}
|
|
24026
|
-
});
|
|
23756
|
+
});
|
|
23757
|
+
}
|
|
24027
23758
|
ingestInCache(data);
|
|
24028
23759
|
callbacks$b.forEach(cb => cb(data.channels[0]));
|
|
24029
23760
|
};
|
|
@@ -24137,25 +23868,6 @@ var readReceiptSyncEngineOnLoginHandler = () => {
|
|
|
24137
23868
|
};
|
|
24138
23869
|
};
|
|
24139
23870
|
|
|
24140
|
-
var legacyReadReceiptSyncEngineOnLoginHandler = () => {
|
|
24141
|
-
const readReceiptSyncEngine = LegacyReadReceiptSyncEngine.getInstance();
|
|
24142
|
-
readReceiptSyncEngine.startSyncReadReceipt();
|
|
24143
|
-
onSessionStateChange(state => {
|
|
24144
|
-
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
24145
|
-
readReceiptSyncEngine.onSessionEstablished();
|
|
24146
|
-
}
|
|
24147
|
-
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
24148
|
-
readReceiptSyncEngine.onTokenExpired();
|
|
24149
|
-
}
|
|
24150
|
-
else {
|
|
24151
|
-
readReceiptSyncEngine.onSessionDestroyed();
|
|
24152
|
-
}
|
|
24153
|
-
});
|
|
24154
|
-
return () => {
|
|
24155
|
-
readReceiptSyncEngine.onSessionDestroyed();
|
|
24156
|
-
};
|
|
24157
|
-
};
|
|
24158
|
-
|
|
24159
23871
|
const onOnline = (callback) => {
|
|
24160
23872
|
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
24161
23873
|
window.addEventListener('online', callback);
|
|
@@ -24722,17 +24434,10 @@ const onChannelLeft = (callback) => {
|
|
|
24722
24434
|
const preparedPayload = await prepareChannelPayload(payload, {
|
|
24723
24435
|
isMessagePreviewUpdated: isLeftByMe,
|
|
24724
24436
|
});
|
|
24725
|
-
|
|
24726
|
-
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
24727
|
-
if (isLeftByMe) {
|
|
24437
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode() && isLeftByMe) {
|
|
24728
24438
|
preparedPayload.channels.forEach(channel => {
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
deleteChannelUnreadByChannelId(channel.channelId);
|
|
24732
|
-
}
|
|
24733
|
-
else if (isLegacyUnreadCount) {
|
|
24734
|
-
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
24735
|
-
}
|
|
24439
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
24440
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
24736
24441
|
});
|
|
24737
24442
|
}
|
|
24738
24443
|
const { channels, channelUsers } = preparedPayload;
|
|
@@ -25000,29 +24705,6 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
25000
24705
|
reCalculateChannelUnreadInfo(message.channelId);
|
|
25001
24706
|
});
|
|
25002
24707
|
}
|
|
25003
|
-
if (client.useLegacyUnreadCount) {
|
|
25004
|
-
rawPayload.messages.forEach(message => {
|
|
25005
|
-
var _a, _b;
|
|
25006
|
-
const channelUnread = (_a = pullFromCache([
|
|
25007
|
-
'channelUnread',
|
|
25008
|
-
'get',
|
|
25009
|
-
message.channelId,
|
|
25010
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
25011
|
-
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
25012
|
-
return;
|
|
25013
|
-
const lastSegment = message.segment;
|
|
25014
|
-
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
25015
|
-
return (mention.type === 'channel' ||
|
|
25016
|
-
(mention.type === 'user' &&
|
|
25017
|
-
client.userId &&
|
|
25018
|
-
mention.userPublicIds.includes(client.userId)));
|
|
25019
|
-
});
|
|
25020
|
-
const lastMentionSegment = isMentionedInMessage
|
|
25021
|
-
? message.segment
|
|
25022
|
-
: channelUnread.lastMentionSegment;
|
|
25023
|
-
pushToCache(['channelUnread', 'get', message.channelId], Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: lastSegment - channelUnread.readToSegment, lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) }));
|
|
25024
|
-
});
|
|
25025
|
-
}
|
|
25026
24708
|
// Update in cache
|
|
25027
24709
|
ingestInCache(payload);
|
|
25028
24710
|
payload.messages.forEach(message => {
|
|
@@ -25198,7 +24880,6 @@ const enableUnreadCount = () => {
|
|
|
25198
24880
|
if (client.isUnreadCountEnabled)
|
|
25199
24881
|
return false;
|
|
25200
24882
|
client.isUnreadCountEnabled = true;
|
|
25201
|
-
client.useLegacyUnreadCount = false;
|
|
25202
24883
|
client.emitter.emit('unreadCountEnabled', true);
|
|
25203
24884
|
return true;
|
|
25204
24885
|
};
|
|
@@ -25514,12 +25195,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
25514
25195
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
25515
25196
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
25516
25197
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
25517
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
|
|
25518
|
-
if (client.useLegacyUnreadCount) {
|
|
25519
|
-
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
25520
|
-
}
|
|
25521
|
-
else
|
|
25522
|
-
subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
|
|
25198
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), readReceiptSyncEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
|
|
25523
25199
|
const markerSyncUnsubscriber = await startMarkerSync();
|
|
25524
25200
|
subscriptions.push(markerSyncUnsubscriber);
|
|
25525
25201
|
}
|
|
@@ -25677,15 +25353,17 @@ const DEFAULT_DEBUG_SESSION = 'amity';
|
|
|
25677
25353
|
* @category Client API
|
|
25678
25354
|
* */
|
|
25679
25355
|
const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, rteEnabled = true, } = {}) => {
|
|
25680
|
-
var _a, _b;
|
|
25356
|
+
var _a, _b, _c;
|
|
25681
25357
|
const log = createLogger(debugSession);
|
|
25682
25358
|
log('client/api/createClient', {
|
|
25683
25359
|
apiKey: apiKey.replace(/.{5}$/g, 'xxxxx'),
|
|
25684
25360
|
apiRegion,
|
|
25685
25361
|
});
|
|
25686
25362
|
const httpEndpoint = (_a = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.http) !== null && _a !== void 0 ? _a : computeUrl('http', apiRegion);
|
|
25687
|
-
const
|
|
25363
|
+
const uploadEndpoint = (_b = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.upload) !== null && _b !== void 0 ? _b : computeUrl('upload', apiRegion);
|
|
25364
|
+
const mqttEndpoint = (_c = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.mqtt) !== null && _c !== void 0 ? _c : computeUrl('mqtt', apiRegion);
|
|
25688
25365
|
const http = createHttpTransport(httpEndpoint);
|
|
25366
|
+
const upload = createHttpTransport(uploadEndpoint);
|
|
25689
25367
|
let ws;
|
|
25690
25368
|
let mqtt;
|
|
25691
25369
|
if (rteEnabled) {
|
|
@@ -25700,8 +25378,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
25700
25378
|
const sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
|
|
25701
25379
|
const sessionHandler = undefined;
|
|
25702
25380
|
const isUnreadCountEnabled = false;
|
|
25703
|
-
// Legacy unread count is true by default
|
|
25704
|
-
const useLegacyUnreadCount = true;
|
|
25705
25381
|
const client = {
|
|
25706
25382
|
version: `${VERSION}`,
|
|
25707
25383
|
apiKey,
|
|
@@ -25716,6 +25392,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
25716
25392
|
http,
|
|
25717
25393
|
ws,
|
|
25718
25394
|
mqtt,
|
|
25395
|
+
upload,
|
|
25719
25396
|
emitter,
|
|
25720
25397
|
/*
|
|
25721
25398
|
* Session Components
|
|
@@ -25731,7 +25408,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
25731
25408
|
getMessagePreviewSetting,
|
|
25732
25409
|
use: () => setActiveClient(client),
|
|
25733
25410
|
isUnreadCountEnabled,
|
|
25734
|
-
useLegacyUnreadCount,
|
|
25735
25411
|
getMarkerSyncConsistentMode,
|
|
25736
25412
|
/**
|
|
25737
25413
|
* Prefix for the deviceId key in the local storage or async storage.
|
|
@@ -25745,7 +25421,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
25745
25421
|
return activeClient;
|
|
25746
25422
|
setActiveClient(client);
|
|
25747
25423
|
}
|
|
25748
|
-
catch (
|
|
25424
|
+
catch (_d) {
|
|
25749
25425
|
setActiveClient(client);
|
|
25750
25426
|
}
|
|
25751
25427
|
return client;
|
|
@@ -28534,7 +28210,7 @@ const uploadFile = async (formData, onProgress) => {
|
|
|
28534
28210
|
const headers = 'getHeaders' in formData
|
|
28535
28211
|
? formData.getHeaders()
|
|
28536
28212
|
: { 'content-type': 'multipart/form-data' };
|
|
28537
|
-
const { data } = await client.
|
|
28213
|
+
const { data } = await client.upload.post('/api/v4/files', formData, {
|
|
28538
28214
|
headers,
|
|
28539
28215
|
onUploadProgress({ loaded, total = 100 }) {
|
|
28540
28216
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -28624,7 +28300,7 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
28624
28300
|
const headers = 'getHeaders' in formData
|
|
28625
28301
|
? formData.getHeaders()
|
|
28626
28302
|
: { 'content-type': 'multipart/form-data' };
|
|
28627
|
-
const { data } = await client.
|
|
28303
|
+
const { data } = await client.upload.post('/api/v4/videos', formData, {
|
|
28628
28304
|
headers,
|
|
28629
28305
|
onUploadProgress({ loaded, total = 100 }) {
|
|
28630
28306
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -28672,7 +28348,7 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
28672
28348
|
const headers = 'getHeaders' in formData
|
|
28673
28349
|
? formData.getHeaders()
|
|
28674
28350
|
: { 'content-type': 'multipart/form-data' };
|
|
28675
|
-
const { data } = await client.
|
|
28351
|
+
const { data } = await client.upload.post('/api/v4/images', formData, {
|
|
28676
28352
|
headers,
|
|
28677
28353
|
onUploadProgress({ loaded, total = 100 }) {
|
|
28678
28354
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -32865,37 +32541,19 @@ var index$f = /*#__PURE__*/Object.freeze({
|
|
|
32865
32541
|
/**
|
|
32866
32542
|
* Internal used only
|
|
32867
32543
|
*
|
|
32868
|
-
* Fired when an {@link Amity.
|
|
32869
|
-
*
|
|
32870
|
-
* @param callback The function to call when the event was fired
|
|
32871
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
32872
|
-
*
|
|
32873
|
-
* @category ChannelMarker Events
|
|
32874
|
-
*/
|
|
32875
|
-
const onChannelUnreadInfoUpdatedLocal = (callback) => {
|
|
32876
|
-
const client = getActiveClient();
|
|
32877
|
-
const filter = (payload) => {
|
|
32878
|
-
callback(payload);
|
|
32879
|
-
};
|
|
32880
|
-
return createEventSubscriber(client, 'channelMarker/onChannelUnreadInfoUpdatedLocal', 'local.channelUnreadInfo.updated', filter);
|
|
32881
|
-
};
|
|
32882
|
-
|
|
32883
|
-
/**
|
|
32884
|
-
* Internal used only
|
|
32885
|
-
*
|
|
32886
|
-
* Fired when an {@link Amity.ChannelUnread} has been updated.
|
|
32544
|
+
* Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
|
|
32887
32545
|
*
|
|
32888
32546
|
* @param callback The function to call when the event was fired
|
|
32889
32547
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
32890
32548
|
*
|
|
32891
|
-
* @category
|
|
32549
|
+
* @category MessageMarker Events
|
|
32892
32550
|
*/
|
|
32893
32551
|
const onChannelUnreadUpdatedLocal = (callback) => {
|
|
32894
32552
|
const client = getActiveClient();
|
|
32895
32553
|
const filter = (payload) => {
|
|
32896
32554
|
callback(payload);
|
|
32897
32555
|
};
|
|
32898
|
-
return createEventSubscriber(client, '
|
|
32556
|
+
return createEventSubscriber(client, 'channelMarker/onChannelUnreadUpdatedLocal', 'local.channelUnread.updated', filter);
|
|
32899
32557
|
};
|
|
32900
32558
|
|
|
32901
32559
|
/* begin_public_function
|
|
@@ -33097,7 +32755,6 @@ const getChannel = (channelId, callback) => {
|
|
|
33097
32755
|
return onSubChannelUpdated(updateMessagePreview);
|
|
33098
32756
|
}, 'channelId', 'channel'),
|
|
33099
32757
|
convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
|
|
33100
|
-
convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
33101
32758
|
convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
|
|
33102
32759
|
], {
|
|
33103
32760
|
forceDispatch: true,
|
|
@@ -33611,10 +33268,6 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
33611
33268
|
},
|
|
33612
33269
|
action: "OnResolveUnread" /* Amity.ChannelActionType.OnResolveUnread */,
|
|
33613
33270
|
},
|
|
33614
|
-
{
|
|
33615
|
-
fn: convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
33616
|
-
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
33617
|
-
},
|
|
33618
33271
|
{
|
|
33619
33272
|
fn: convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
|
|
33620
33273
|
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|