@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.cjs.js
CHANGED
|
@@ -516,7 +516,6 @@ const idResolvers = {
|
|
|
516
516
|
messagePreviewSubChannel: ({ subChannelId }) => `${subChannelId}`,
|
|
517
517
|
channelUnreadInfo: ({ channelId }) => channelId,
|
|
518
518
|
subChannelUnreadInfo: ({ subChannelId }) => subChannelId,
|
|
519
|
-
channelUnread: ({ channelId }) => channelId,
|
|
520
519
|
channelMarker: ({ entityId, userId }) => `${entityId}#${userId}`,
|
|
521
520
|
subChannelMarker: ({ entityId, feedId, userId }) => `${entityId}#${feedId}#${userId}`,
|
|
522
521
|
messageMarker: ({ feedId, contentId, creatorId }) => `${feedId}#${contentId}#${creatorId}`,
|
|
@@ -1562,6 +1561,7 @@ const API_REGIONS = {
|
|
|
1562
1561
|
};
|
|
1563
1562
|
const URLS = {
|
|
1564
1563
|
http: 'https://apix.{region}.amity.co',
|
|
1564
|
+
upload: 'https://upload.{region}.amity.co',
|
|
1565
1565
|
mqtt: 'wss://sse.{region}.amity.co:443/mqtt',
|
|
1566
1566
|
};
|
|
1567
1567
|
function computeUrl(type, region) {
|
|
@@ -1610,13 +1610,13 @@ class NetworkActivitiesWatcher {
|
|
|
1610
1610
|
this._listener.clear();
|
|
1611
1611
|
}
|
|
1612
1612
|
}
|
|
1613
|
-
let instance$
|
|
1613
|
+
let instance$5;
|
|
1614
1614
|
var NetworkActivitiesWatcher$1 = {
|
|
1615
1615
|
getInstance: () => {
|
|
1616
|
-
if (!instance$
|
|
1617
|
-
instance$
|
|
1616
|
+
if (!instance$5) {
|
|
1617
|
+
instance$5 = new NetworkActivitiesWatcher();
|
|
1618
1618
|
}
|
|
1619
|
-
return instance$
|
|
1619
|
+
return instance$5;
|
|
1620
1620
|
},
|
|
1621
1621
|
};
|
|
1622
1622
|
|
|
@@ -5149,13 +5149,13 @@ class AnalyticsEngine {
|
|
|
5149
5149
|
this._eventCapturer.resetAllBuckets();
|
|
5150
5150
|
}
|
|
5151
5151
|
}
|
|
5152
|
-
let instance$
|
|
5152
|
+
let instance$4;
|
|
5153
5153
|
var AnalyticsEngine$1 = {
|
|
5154
5154
|
getInstance: () => {
|
|
5155
|
-
if (!instance$
|
|
5156
|
-
instance$
|
|
5155
|
+
if (!instance$4) {
|
|
5156
|
+
instance$4 = new AnalyticsEngine();
|
|
5157
5157
|
}
|
|
5158
|
-
return instance$
|
|
5158
|
+
return instance$4;
|
|
5159
5159
|
},
|
|
5160
5160
|
};
|
|
5161
5161
|
|
|
@@ -5581,221 +5581,6 @@ const getMessageReadCount = (message, marker) => {
|
|
|
5581
5581
|
getCachedMarker$2(message)) !== null && _a !== void 0 ? _a : { readCount: 0, deliveredCount: 0 };
|
|
5582
5582
|
}; // and if not found in cache use default value `0`
|
|
5583
5583
|
|
|
5584
|
-
/**
|
|
5585
|
-
*
|
|
5586
|
-
* Mark subChannel as read by readToSegment
|
|
5587
|
-
*
|
|
5588
|
-
* @param subChannelIds the IDs of the {@link Amity.SubChannel} to update
|
|
5589
|
-
* @param readToSegment the segment to mark as read
|
|
5590
|
-
* @returns a success boolean if the {@link Amity.SubChannel} was updated
|
|
5591
|
-
*
|
|
5592
|
-
* @category Channel API
|
|
5593
|
-
* @async
|
|
5594
|
-
*/
|
|
5595
|
-
const markChannelsAsReadBySegment = async (readings) => {
|
|
5596
|
-
const client = getActiveClient();
|
|
5597
|
-
try {
|
|
5598
|
-
await client.http.post('api/v3/channels/seen', { channels: readings });
|
|
5599
|
-
return true;
|
|
5600
|
-
}
|
|
5601
|
-
catch (e) {
|
|
5602
|
-
return false;
|
|
5603
|
-
}
|
|
5604
|
-
};
|
|
5605
|
-
|
|
5606
|
-
class MessageReadReceiptSyncEngine {
|
|
5607
|
-
constructor() {
|
|
5608
|
-
this.isActive = true;
|
|
5609
|
-
this.MAX_RETRY = 3;
|
|
5610
|
-
this.JOB_QUEUE_SIZE = 120;
|
|
5611
|
-
this.jobQueue = [];
|
|
5612
|
-
// Interval for message read receipt sync in seconds
|
|
5613
|
-
this.RECEIPT_SYNC_INTERVAL = 1;
|
|
5614
|
-
this.client = getActiveClient();
|
|
5615
|
-
// Get remaining unsync read receipts from cache
|
|
5616
|
-
this.getUnsyncJobs();
|
|
5617
|
-
}
|
|
5618
|
-
// Call this when client call client.login
|
|
5619
|
-
startSyncReadReceipt() {
|
|
5620
|
-
// Start timer when start receipt sync
|
|
5621
|
-
this.timer = setInterval(() => {
|
|
5622
|
-
this.syncReadReceipts();
|
|
5623
|
-
}, this.RECEIPT_SYNC_INTERVAL * 1000);
|
|
5624
|
-
}
|
|
5625
|
-
// Read receipt observer handling
|
|
5626
|
-
syncReadReceipts() {
|
|
5627
|
-
if (this.jobQueue.length === 0 || this.isActive === false)
|
|
5628
|
-
return;
|
|
5629
|
-
const readReceipts = this.getReadReceipts();
|
|
5630
|
-
if (readReceipts) {
|
|
5631
|
-
this.markReadApi(readReceipts);
|
|
5632
|
-
}
|
|
5633
|
-
}
|
|
5634
|
-
getUnsyncJobs() {
|
|
5635
|
-
var _a;
|
|
5636
|
-
// Get all read receipts that has latestSyncSegment < latestSegment
|
|
5637
|
-
const readReceipts = (_a = queryCache(['readReceipt'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
|
|
5638
|
-
return data.latestSyncSegment < data.latestSegment;
|
|
5639
|
-
});
|
|
5640
|
-
// Enqueue unsync read receipts to the job queue
|
|
5641
|
-
readReceipts === null || readReceipts === void 0 ? void 0 : readReceipts.forEach(({ data: readReceipt }) => {
|
|
5642
|
-
this.enqueueReadReceipt(readReceipt.channelId, readReceipt.latestSegment);
|
|
5643
|
-
});
|
|
5644
|
-
}
|
|
5645
|
-
getReadReceipts() {
|
|
5646
|
-
// get all read receipts from queue, now the queue is empty
|
|
5647
|
-
const syncJob = this.jobQueue.splice(0, this.jobQueue.length);
|
|
5648
|
-
if (syncJob.length === 0)
|
|
5649
|
-
return;
|
|
5650
|
-
return syncJob.filter(job => {
|
|
5651
|
-
var _a;
|
|
5652
|
-
const readReceipt = (_a = pullFromCache(['readReceipt', job.channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
5653
|
-
if (!readReceipt)
|
|
5654
|
-
return false;
|
|
5655
|
-
if (readReceipt.latestSegment > readReceipt.latestSyncSegment)
|
|
5656
|
-
return true;
|
|
5657
|
-
return false;
|
|
5658
|
-
});
|
|
5659
|
-
}
|
|
5660
|
-
async markReadApi(syncJobs) {
|
|
5661
|
-
var _a;
|
|
5662
|
-
// constuct payload
|
|
5663
|
-
// example: [{ channelId: 'channelId', readToSegment: 2 }]
|
|
5664
|
-
const syncJobsPayload = syncJobs.map(job => {
|
|
5665
|
-
return {
|
|
5666
|
-
channelId: job.channelId,
|
|
5667
|
-
readToSegment: job.segment,
|
|
5668
|
-
};
|
|
5669
|
-
});
|
|
5670
|
-
const response = await markChannelsAsReadBySegment(syncJobsPayload);
|
|
5671
|
-
if (response) {
|
|
5672
|
-
for (let i = 0; i < syncJobs.length; i += 1) {
|
|
5673
|
-
// update lastestSyncSegment in read receipt cache
|
|
5674
|
-
const cacheKey = ['readReceipt', syncJobs[i].channelId];
|
|
5675
|
-
const readReceiptCache = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
5676
|
-
pushToCache(cacheKey, Object.assign(Object.assign({}, readReceiptCache), { latestSyncSegment: syncJobs[i].segment }));
|
|
5677
|
-
}
|
|
5678
|
-
}
|
|
5679
|
-
else {
|
|
5680
|
-
for (let i = 0; i < syncJobs.length; i += 1) {
|
|
5681
|
-
// push them back to queue if the syncing is failed and retry count is less than max retry
|
|
5682
|
-
if (syncJobs[i].retryCount >= this.MAX_RETRY)
|
|
5683
|
-
return;
|
|
5684
|
-
const updatedJob = Object.assign(Object.assign({}, syncJobs[i]), { syncState: "create" /* Amity.ReadReceiptSyncState.CREATED */, retryCount: syncJobs[i].retryCount + 1 });
|
|
5685
|
-
this.enqueueJob(updatedJob);
|
|
5686
|
-
}
|
|
5687
|
-
}
|
|
5688
|
-
}
|
|
5689
|
-
startObservingReadReceiptQueue() {
|
|
5690
|
-
if (this.client.useLegacyUnreadCount) {
|
|
5691
|
-
this.isActive = true;
|
|
5692
|
-
this.startSyncReadReceipt();
|
|
5693
|
-
}
|
|
5694
|
-
}
|
|
5695
|
-
stopObservingReadReceiptQueue() {
|
|
5696
|
-
this.isActive = false;
|
|
5697
|
-
this.jobQueue.map(job => {
|
|
5698
|
-
if (job.syncState === "syncing" /* Amity.ReadReceiptSyncState.SYNCING */) {
|
|
5699
|
-
return Object.assign(Object.assign({}, job), { syncState: "create" /* Amity.ReadReceiptSyncState.CREATED */ });
|
|
5700
|
-
}
|
|
5701
|
-
return job;
|
|
5702
|
-
});
|
|
5703
|
-
if (this.timer)
|
|
5704
|
-
clearInterval(this.timer);
|
|
5705
|
-
}
|
|
5706
|
-
// Session Management
|
|
5707
|
-
onSessionEstablished() {
|
|
5708
|
-
this.startObservingReadReceiptQueue();
|
|
5709
|
-
}
|
|
5710
|
-
onSessionDestroyed() {
|
|
5711
|
-
this.stopObservingReadReceiptQueue();
|
|
5712
|
-
this.jobQueue = [];
|
|
5713
|
-
}
|
|
5714
|
-
onTokenExpired() {
|
|
5715
|
-
this.stopObservingReadReceiptQueue();
|
|
5716
|
-
}
|
|
5717
|
-
// Network Connection Management
|
|
5718
|
-
onNetworkOffline() {
|
|
5719
|
-
// Stop observing to the read receipt queue.
|
|
5720
|
-
this.stopObservingReadReceiptQueue();
|
|
5721
|
-
}
|
|
5722
|
-
onNetworkOnline() {
|
|
5723
|
-
// Resume observing to the read receipt queue.
|
|
5724
|
-
this.startObservingReadReceiptQueue();
|
|
5725
|
-
}
|
|
5726
|
-
markRead(channelId, segment) {
|
|
5727
|
-
var _a;
|
|
5728
|
-
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
5729
|
-
const cacheKey = ['channelUnread', 'get', channelId];
|
|
5730
|
-
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
5731
|
-
if (channelUnread && segment > channelUnread.readToSegment) {
|
|
5732
|
-
channelUnread.readToSegment = segment;
|
|
5733
|
-
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
5734
|
-
pushToCache(cacheKey, channelUnread);
|
|
5735
|
-
fireEvent('local.channelUnread.updated', channelUnread);
|
|
5736
|
-
}
|
|
5737
|
-
// Step 2: Enqueue the read receipt
|
|
5738
|
-
this.enqueueReadReceipt(channelId, segment);
|
|
5739
|
-
}
|
|
5740
|
-
enqueueReadReceipt(channelId, segment) {
|
|
5741
|
-
var _a;
|
|
5742
|
-
const readReceipt = (_a = pullFromCache(['readReceipt', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
5743
|
-
// Create new read receipt if it's not exists and add the job to queue
|
|
5744
|
-
if (!readReceipt) {
|
|
5745
|
-
const readReceiptChannel = {
|
|
5746
|
-
channelId,
|
|
5747
|
-
latestSegment: segment,
|
|
5748
|
-
latestSyncSegment: 0,
|
|
5749
|
-
};
|
|
5750
|
-
pushToCache(['readReceipt', channelId], readReceiptChannel);
|
|
5751
|
-
}
|
|
5752
|
-
else if (readReceipt.latestSegment < segment) {
|
|
5753
|
-
// Update latestSegment in read receipt cache
|
|
5754
|
-
pushToCache(['readReceipt', channelId], Object.assign(Object.assign({}, readReceipt), { latestSegment: segment }));
|
|
5755
|
-
}
|
|
5756
|
-
else if (readReceipt.latestSyncSegment >= segment) {
|
|
5757
|
-
// Skip the job when lastSyncSegment > = segment
|
|
5758
|
-
return;
|
|
5759
|
-
}
|
|
5760
|
-
let syncJob = this.getSyncJob(channelId);
|
|
5761
|
-
if (syncJob === null || syncJob.syncState === "syncing" /* Amity.ReadReceiptSyncState.SYNCING */) {
|
|
5762
|
-
syncJob = {
|
|
5763
|
-
channelId,
|
|
5764
|
-
segment,
|
|
5765
|
-
syncState: "create" /* Amity.ReadReceiptSyncState.CREATED */,
|
|
5766
|
-
retryCount: 0,
|
|
5767
|
-
};
|
|
5768
|
-
this.enqueueJob(syncJob);
|
|
5769
|
-
}
|
|
5770
|
-
else if (syncJob.segment < segment) {
|
|
5771
|
-
syncJob.segment = segment;
|
|
5772
|
-
}
|
|
5773
|
-
}
|
|
5774
|
-
getSyncJob(channelId) {
|
|
5775
|
-
const { jobQueue } = this;
|
|
5776
|
-
const targetJob = jobQueue.find(job => job.channelId === channelId);
|
|
5777
|
-
return targetJob || null;
|
|
5778
|
-
}
|
|
5779
|
-
enqueueJob(syncJob) {
|
|
5780
|
-
if (this.jobQueue.length < this.JOB_QUEUE_SIZE) {
|
|
5781
|
-
this.jobQueue.push(syncJob);
|
|
5782
|
-
}
|
|
5783
|
-
else {
|
|
5784
|
-
// Remove oldest job when queue reach maximum capacity
|
|
5785
|
-
this.jobQueue.shift();
|
|
5786
|
-
this.jobQueue.push(syncJob);
|
|
5787
|
-
}
|
|
5788
|
-
}
|
|
5789
|
-
}
|
|
5790
|
-
let instance$4 = null;
|
|
5791
|
-
var ReadReceiptSyncEngine = {
|
|
5792
|
-
getInstance: () => {
|
|
5793
|
-
if (!instance$4)
|
|
5794
|
-
instance$4 = new MessageReadReceiptSyncEngine();
|
|
5795
|
-
return instance$4;
|
|
5796
|
-
},
|
|
5797
|
-
};
|
|
5798
|
-
|
|
5799
5584
|
/**
|
|
5800
5585
|
*
|
|
5801
5586
|
* Mark subChannel as read by readToSegment
|
|
@@ -5844,7 +5629,7 @@ const reCalculateChannelUnreadInfo = (channelId) => {
|
|
|
5844
5629
|
return channelUnreadInfo;
|
|
5845
5630
|
};
|
|
5846
5631
|
|
|
5847
|
-
class
|
|
5632
|
+
class MessageReadReceiptSyncEngine {
|
|
5848
5633
|
constructor() {
|
|
5849
5634
|
this.isActive = true;
|
|
5850
5635
|
this.MAX_RETRY = 3;
|
|
@@ -5875,7 +5660,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
5875
5660
|
getUnsyncJobs() {
|
|
5876
5661
|
var _a;
|
|
5877
5662
|
// Get all read receipts that has latestSyncSegment < latestSegment
|
|
5878
|
-
const readReceipts = (_a = queryCache(['
|
|
5663
|
+
const readReceipts = (_a = queryCache(['readReceipt'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
|
|
5879
5664
|
return data.latestSyncSegment < data.latestSegment;
|
|
5880
5665
|
});
|
|
5881
5666
|
// Enqueue unsync read receipts to the job queue
|
|
@@ -5894,7 +5679,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
5894
5679
|
return;
|
|
5895
5680
|
// Get readReceipt from cache by subChannelId
|
|
5896
5681
|
const readReceipt = (_a = pullFromCache([
|
|
5897
|
-
'
|
|
5682
|
+
'readReceipt',
|
|
5898
5683
|
syncJob.subChannelId,
|
|
5899
5684
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
5900
5685
|
if (!readReceipt)
|
|
@@ -5917,10 +5702,10 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
5917
5702
|
if (response) {
|
|
5918
5703
|
this.removeSynedReceipt(syncJob.subChannelId, syncJob.segment);
|
|
5919
5704
|
const readReceiptCache = (_a = pullFromCache([
|
|
5920
|
-
'
|
|
5705
|
+
'readReceipt',
|
|
5921
5706
|
subChannelId,
|
|
5922
5707
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
5923
|
-
pushToCache(['
|
|
5708
|
+
pushToCache(['readReceipt', subChannelId], Object.assign(Object.assign({}, readReceiptCache), { latestSyncSegment: segment }));
|
|
5924
5709
|
}
|
|
5925
5710
|
else if (!response) {
|
|
5926
5711
|
if (newSyncJob.retryCount > this.MAX_RETRY) {
|
|
@@ -5987,7 +5772,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
5987
5772
|
subChannelUnreadInfo.readToSegment = segment;
|
|
5988
5773
|
subChannelUnreadInfo.unreadCount = Math.max(subChannelUnreadInfo.lastSegment - segment, 0);
|
|
5989
5774
|
const channelUnreadInfo = reCalculateChannelUnreadInfo(subChannelUnreadInfo.channelId);
|
|
5990
|
-
fireEvent('local.
|
|
5775
|
+
fireEvent('local.channelUnread.updated', channelUnreadInfo);
|
|
5991
5776
|
pushToCache(cacheKey, subChannelUnreadInfo);
|
|
5992
5777
|
fireEvent('local.subChannelUnread.updated', subChannelUnreadInfo);
|
|
5993
5778
|
}
|
|
@@ -5996,10 +5781,7 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
5996
5781
|
}
|
|
5997
5782
|
enqueueReadReceipt(subChannelId, segment) {
|
|
5998
5783
|
var _a;
|
|
5999
|
-
const readReceipt = (_a = pullFromCache([
|
|
6000
|
-
'legacyReadReceipt',
|
|
6001
|
-
subChannelId,
|
|
6002
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
5784
|
+
const readReceipt = (_a = pullFromCache(['readReceipt', subChannelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6003
5785
|
// Create new read receipt if it's not exists and add job to queue
|
|
6004
5786
|
if (!readReceipt) {
|
|
6005
5787
|
const readReceiptSubChannel = {
|
|
@@ -6007,10 +5789,10 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
6007
5789
|
latestSegment: segment,
|
|
6008
5790
|
latestSyncSegment: 0,
|
|
6009
5791
|
};
|
|
6010
|
-
pushToCache(['
|
|
5792
|
+
pushToCache(['readReceipt', subChannelId], readReceiptSubChannel);
|
|
6011
5793
|
}
|
|
6012
5794
|
else if (readReceipt.latestSegment < segment) {
|
|
6013
|
-
pushToCache(['
|
|
5795
|
+
pushToCache(['readReceipt', subChannelId], Object.assign(Object.assign({}, readReceipt), { latestSegment: segment }));
|
|
6014
5796
|
}
|
|
6015
5797
|
else if (readReceipt.latestSyncSegment >= segment) {
|
|
6016
5798
|
// Skip the job when lastSyncSegment > = segment
|
|
@@ -6053,24 +5835,18 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
6053
5835
|
}
|
|
6054
5836
|
}
|
|
6055
5837
|
let instance$3 = null;
|
|
6056
|
-
var
|
|
5838
|
+
var ReadReceiptSyncEngine = {
|
|
6057
5839
|
getInstance: () => {
|
|
6058
5840
|
if (!instance$3)
|
|
6059
|
-
instance$3 = new
|
|
5841
|
+
instance$3 = new MessageReadReceiptSyncEngine();
|
|
6060
5842
|
return instance$3;
|
|
6061
5843
|
},
|
|
6062
5844
|
};
|
|
6063
5845
|
|
|
6064
5846
|
const markReadMessage = (message) => {
|
|
6065
|
-
const
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
markReadReceiptEngine.markRead(message.channelId, message.channelSegment);
|
|
6069
|
-
}
|
|
6070
|
-
else {
|
|
6071
|
-
const markReadReceiptEngine = LegacyReadReceiptSyncEngine.getInstance();
|
|
6072
|
-
markReadReceiptEngine.markRead(message.subChannelId, message.channelSegment);
|
|
6073
|
-
}
|
|
5847
|
+
const { subChannelId, channelSegment } = message;
|
|
5848
|
+
const markReadReceiptEngine = ReadReceiptSyncEngine.getInstance();
|
|
5849
|
+
markReadReceiptEngine.markRead(subChannelId, channelSegment);
|
|
6074
5850
|
};
|
|
6075
5851
|
|
|
6076
5852
|
const messageLinkedObject = (message) => {
|
|
@@ -7058,24 +6834,6 @@ const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated:
|
|
|
7058
6834
|
channels: rawPayload.channels.map(channel => convertFromRaw(channel, { isMessagePreviewUpdated: options.isMessagePreviewUpdated })),
|
|
7059
6835
|
});
|
|
7060
6836
|
};
|
|
7061
|
-
const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
|
|
7062
|
-
for (let i = 0; i < channels.length; i += 1) {
|
|
7063
|
-
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
7064
|
-
const { readToSegment, lastMentionedSegment } = channelUsers.find(channelUser => channelUser.channelId === channels[i].channelId && channelUser.userId === currentUserId) || {
|
|
7065
|
-
readToSegment: 0,
|
|
7066
|
-
lastMentionedSegment: 0,
|
|
7067
|
-
};
|
|
7068
|
-
pushToCache(cacheKey, {
|
|
7069
|
-
channelId: channels[i].channelId,
|
|
7070
|
-
lastSegment: channels[i].messageCount,
|
|
7071
|
-
readToSegment,
|
|
7072
|
-
lastMentionedSegment,
|
|
7073
|
-
unreadCount: channels[i].messageCount - readToSegment,
|
|
7074
|
-
isMentioned: lastMentionedSegment > readToSegment,
|
|
7075
|
-
isDeleted: channels[i].isDeleted,
|
|
7076
|
-
});
|
|
7077
|
-
}
|
|
7078
|
-
};
|
|
7079
6837
|
const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpdated: true }) => {
|
|
7080
6838
|
const client = getActiveClient();
|
|
7081
6839
|
const networkPreviewSetting = await client.getMessagePreviewSetting(false);
|
|
@@ -7085,34 +6843,23 @@ const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpd
|
|
|
7085
6843
|
rawPayload.messagePreviews.length > 0) {
|
|
7086
6844
|
updateChannelMessagePreviewCache(rawPayload);
|
|
7087
6845
|
}
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
if (markerIds.length > 0) {
|
|
7101
|
-
// since the get markers method requires a channel cache to function with the reducer.
|
|
7102
|
-
preUpdateChannelCache(rawPayload, {
|
|
7103
|
-
isMessagePreviewUpdated: options.isMessagePreviewUpdated,
|
|
7104
|
-
});
|
|
7105
|
-
try {
|
|
7106
|
-
await getChannelMarkers(markerIds);
|
|
7107
|
-
}
|
|
7108
|
-
catch (e) {
|
|
7109
|
-
// empty block (from the spec, allow marker fetch to fail without having to do anything)
|
|
7110
|
-
}
|
|
6846
|
+
const markerIds = rawPayload.channels
|
|
6847
|
+
// filter channel by type. Only conversation, community and broadcast type are included.
|
|
6848
|
+
.filter(isUnreadCountSupport)
|
|
6849
|
+
.map(({ channelInternalId }) => channelInternalId);
|
|
6850
|
+
if (markerIds.length > 0) {
|
|
6851
|
+
// since the get markers method requires a channel cache to function with the reducer.
|
|
6852
|
+
preUpdateChannelCache(rawPayload, { isMessagePreviewUpdated: options.isMessagePreviewUpdated });
|
|
6853
|
+
try {
|
|
6854
|
+
await getChannelMarkers(markerIds);
|
|
6855
|
+
}
|
|
6856
|
+
catch (e) {
|
|
6857
|
+
// empty block (from the spec, allow marker fetch to fail without having to do anything)
|
|
7111
6858
|
}
|
|
7112
6859
|
}
|
|
7113
|
-
//
|
|
6860
|
+
// attach marker to channel
|
|
7114
6861
|
const channels = rawPayload.channels.map(payload => convertFromRaw(payload, { isMessagePreviewUpdated: options.isMessagePreviewUpdated }));
|
|
7115
|
-
//
|
|
6862
|
+
// user marker to channel users
|
|
7116
6863
|
const channelUsers = rawPayload.channelUsers.map(channelUser => {
|
|
7117
6864
|
return convertRawMembershipToMembership(channelUser);
|
|
7118
6865
|
});
|
|
@@ -7239,28 +6986,15 @@ const getSubChannelsUnreadCount = (channel, marker) => {
|
|
|
7239
6986
|
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;
|
|
7240
6987
|
};
|
|
7241
6988
|
|
|
7242
|
-
const getLegacyChannelUnread = (channelId) => {
|
|
7243
|
-
var _a;
|
|
7244
|
-
return (_a = pullFromCache(['channelUnread', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
7245
|
-
};
|
|
7246
|
-
|
|
7247
6989
|
const constructChannelDynamicValue = (channel) => {
|
|
7248
|
-
const client = getActiveClient();
|
|
7249
6990
|
const rest = __rest(channel, ["messageCount"]);
|
|
7250
6991
|
return shallowClone(rest, {
|
|
7251
|
-
get
|
|
7252
|
-
|
|
7253
|
-
return (_b = (_a = getLegacyChannelUnread(rest.channelId)) === null || _a === void 0 ? void 0 : _a.unreadCount) !== null && _b !== void 0 ? _b : 0;
|
|
6992
|
+
get isMentioned() {
|
|
6993
|
+
return getChannelIsMentioned(rest);
|
|
7254
6994
|
},
|
|
7255
6995
|
get subChannelsUnreadCount() {
|
|
7256
6996
|
return getSubChannelsUnreadCount(rest);
|
|
7257
6997
|
},
|
|
7258
|
-
get isMentioned() {
|
|
7259
|
-
var _a, _b;
|
|
7260
|
-
if (client.useLegacyUnreadCount)
|
|
7261
|
-
return (_b = (_a = getLegacyChannelUnread(rest.channelId)) === null || _a === void 0 ? void 0 : _a.isMentioned) !== null && _b !== void 0 ? _b : false;
|
|
7262
|
-
return getChannelIsMentioned(rest);
|
|
7263
|
-
},
|
|
7264
6998
|
});
|
|
7265
6999
|
};
|
|
7266
7000
|
|
|
@@ -7873,6 +7607,12 @@ const setClientToken = async (params) => {
|
|
|
7873
7607
|
isGlobalBanned: false,
|
|
7874
7608
|
isUserDeleted: false,
|
|
7875
7609
|
};
|
|
7610
|
+
client.upload.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
7611
|
+
client.upload.defaults.metadata = {
|
|
7612
|
+
tokenExpiry: expiresAt,
|
|
7613
|
+
isGlobalBanned: false,
|
|
7614
|
+
isUserDeleted: false,
|
|
7615
|
+
};
|
|
7876
7616
|
// manually setup the token for ws transport
|
|
7877
7617
|
if (client.ws)
|
|
7878
7618
|
client.ws.io.opts.query = { token: accessToken };
|
|
@@ -7917,21 +7657,12 @@ const onChannelDeleted = (callback) => {
|
|
|
7917
7657
|
const client = getActiveClient();
|
|
7918
7658
|
const filter = async (payload) => {
|
|
7919
7659
|
const data = await prepareChannelPayload(payload);
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
data.channels.forEach(channel => {
|
|
7923
|
-
if (isConsistentMode) {
|
|
7660
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
7661
|
+
data.channels.forEach(channel => {
|
|
7924
7662
|
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
7925
7663
|
deleteChannelUnreadByChannelId(channel.channelId);
|
|
7926
|
-
}
|
|
7927
|
-
|
|
7928
|
-
const cacheKey = ['channelUnread', 'get', channel.channelId];
|
|
7929
|
-
const cache = pullFromCache(cacheKey);
|
|
7930
|
-
if (cache) {
|
|
7931
|
-
pushToCache(cacheKey, Object.assign(Object.assign({}, cache), { isDeleted: true }));
|
|
7932
|
-
}
|
|
7933
|
-
}
|
|
7934
|
-
});
|
|
7664
|
+
});
|
|
7665
|
+
}
|
|
7935
7666
|
ingestInCache(data);
|
|
7936
7667
|
callbacks$b.forEach(cb => cb(data.channels[0]));
|
|
7937
7668
|
};
|
|
@@ -8045,25 +7776,6 @@ var readReceiptSyncEngineOnLoginHandler = () => {
|
|
|
8045
7776
|
};
|
|
8046
7777
|
};
|
|
8047
7778
|
|
|
8048
|
-
var legacyReadReceiptSyncEngineOnLoginHandler = () => {
|
|
8049
|
-
const readReceiptSyncEngine = LegacyReadReceiptSyncEngine.getInstance();
|
|
8050
|
-
readReceiptSyncEngine.startSyncReadReceipt();
|
|
8051
|
-
onSessionStateChange(state => {
|
|
8052
|
-
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
8053
|
-
readReceiptSyncEngine.onSessionEstablished();
|
|
8054
|
-
}
|
|
8055
|
-
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
8056
|
-
readReceiptSyncEngine.onTokenExpired();
|
|
8057
|
-
}
|
|
8058
|
-
else {
|
|
8059
|
-
readReceiptSyncEngine.onSessionDestroyed();
|
|
8060
|
-
}
|
|
8061
|
-
});
|
|
8062
|
-
return () => {
|
|
8063
|
-
readReceiptSyncEngine.onSessionDestroyed();
|
|
8064
|
-
};
|
|
8065
|
-
};
|
|
8066
|
-
|
|
8067
7779
|
const onOnline = (callback) => {
|
|
8068
7780
|
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
8069
7781
|
window.addEventListener('online', callback);
|
|
@@ -8630,17 +8342,10 @@ const onChannelLeft = (callback) => {
|
|
|
8630
8342
|
const preparedPayload = await prepareChannelPayload(payload, {
|
|
8631
8343
|
isMessagePreviewUpdated: isLeftByMe,
|
|
8632
8344
|
});
|
|
8633
|
-
|
|
8634
|
-
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
8635
|
-
if (isLeftByMe) {
|
|
8345
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode() && isLeftByMe) {
|
|
8636
8346
|
preparedPayload.channels.forEach(channel => {
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
deleteChannelUnreadByChannelId(channel.channelId);
|
|
8640
|
-
}
|
|
8641
|
-
else if (isLegacyUnreadCount) {
|
|
8642
|
-
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
8643
|
-
}
|
|
8347
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
8348
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
8644
8349
|
});
|
|
8645
8350
|
}
|
|
8646
8351
|
const { channels, channelUsers } = preparedPayload;
|
|
@@ -8908,29 +8613,6 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
8908
8613
|
reCalculateChannelUnreadInfo(message.channelId);
|
|
8909
8614
|
});
|
|
8910
8615
|
}
|
|
8911
|
-
if (client.useLegacyUnreadCount) {
|
|
8912
|
-
rawPayload.messages.forEach(message => {
|
|
8913
|
-
var _a, _b;
|
|
8914
|
-
const channelUnread = (_a = pullFromCache([
|
|
8915
|
-
'channelUnread',
|
|
8916
|
-
'get',
|
|
8917
|
-
message.channelId,
|
|
8918
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
8919
|
-
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
8920
|
-
return;
|
|
8921
|
-
const lastSegment = message.segment;
|
|
8922
|
-
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
8923
|
-
return (mention.type === 'channel' ||
|
|
8924
|
-
(mention.type === 'user' &&
|
|
8925
|
-
client.userId &&
|
|
8926
|
-
mention.userPublicIds.includes(client.userId)));
|
|
8927
|
-
});
|
|
8928
|
-
const lastMentionSegment = isMentionedInMessage
|
|
8929
|
-
? message.segment
|
|
8930
|
-
: channelUnread.lastMentionSegment;
|
|
8931
|
-
pushToCache(['channelUnread', 'get', message.channelId], Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: lastSegment - channelUnread.readToSegment, lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) }));
|
|
8932
|
-
});
|
|
8933
|
-
}
|
|
8934
8616
|
// Update in cache
|
|
8935
8617
|
ingestInCache(payload);
|
|
8936
8618
|
payload.messages.forEach(message => {
|
|
@@ -9106,7 +8788,6 @@ const enableUnreadCount = () => {
|
|
|
9106
8788
|
if (client.isUnreadCountEnabled)
|
|
9107
8789
|
return false;
|
|
9108
8790
|
client.isUnreadCountEnabled = true;
|
|
9109
|
-
client.useLegacyUnreadCount = false;
|
|
9110
8791
|
client.emitter.emit('unreadCountEnabled', true);
|
|
9111
8792
|
return true;
|
|
9112
8793
|
};
|
|
@@ -9422,12 +9103,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
9422
9103
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
9423
9104
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
9424
9105
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
9425
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
|
|
9426
|
-
if (client.useLegacyUnreadCount) {
|
|
9427
|
-
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
9428
|
-
}
|
|
9429
|
-
else
|
|
9430
|
-
subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
|
|
9106
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), readReceiptSyncEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
|
|
9431
9107
|
const markerSyncUnsubscriber = await startMarkerSync();
|
|
9432
9108
|
subscriptions.push(markerSyncUnsubscriber);
|
|
9433
9109
|
}
|
|
@@ -9585,15 +9261,17 @@ const DEFAULT_DEBUG_SESSION = 'amity';
|
|
|
9585
9261
|
* @category Client API
|
|
9586
9262
|
* */
|
|
9587
9263
|
const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, rteEnabled = true, } = {}) => {
|
|
9588
|
-
var _a, _b;
|
|
9264
|
+
var _a, _b, _c;
|
|
9589
9265
|
const log = createLogger(debugSession);
|
|
9590
9266
|
log('client/api/createClient', {
|
|
9591
9267
|
apiKey: apiKey.replace(/.{5}$/g, 'xxxxx'),
|
|
9592
9268
|
apiRegion,
|
|
9593
9269
|
});
|
|
9594
9270
|
const httpEndpoint = (_a = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.http) !== null && _a !== void 0 ? _a : computeUrl('http', apiRegion);
|
|
9595
|
-
const
|
|
9271
|
+
const uploadEndpoint = (_b = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.upload) !== null && _b !== void 0 ? _b : computeUrl('upload', apiRegion);
|
|
9272
|
+
const mqttEndpoint = (_c = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.mqtt) !== null && _c !== void 0 ? _c : computeUrl('mqtt', apiRegion);
|
|
9596
9273
|
const http = createHttpTransport(httpEndpoint);
|
|
9274
|
+
const upload = createHttpTransport(uploadEndpoint);
|
|
9597
9275
|
let ws;
|
|
9598
9276
|
let mqtt;
|
|
9599
9277
|
if (rteEnabled) {
|
|
@@ -9608,8 +9286,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9608
9286
|
const sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
|
|
9609
9287
|
const sessionHandler = undefined;
|
|
9610
9288
|
const isUnreadCountEnabled = false;
|
|
9611
|
-
// Legacy unread count is true by default
|
|
9612
|
-
const useLegacyUnreadCount = true;
|
|
9613
9289
|
const client = {
|
|
9614
9290
|
version: `${VERSION}`,
|
|
9615
9291
|
apiKey,
|
|
@@ -9624,6 +9300,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9624
9300
|
http,
|
|
9625
9301
|
ws,
|
|
9626
9302
|
mqtt,
|
|
9303
|
+
upload,
|
|
9627
9304
|
emitter,
|
|
9628
9305
|
/*
|
|
9629
9306
|
* Session Components
|
|
@@ -9639,7 +9316,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9639
9316
|
getMessagePreviewSetting,
|
|
9640
9317
|
use: () => setActiveClient(client),
|
|
9641
9318
|
isUnreadCountEnabled,
|
|
9642
|
-
useLegacyUnreadCount,
|
|
9643
9319
|
getMarkerSyncConsistentMode,
|
|
9644
9320
|
/**
|
|
9645
9321
|
* Prefix for the deviceId key in the local storage or async storage.
|
|
@@ -9653,7 +9329,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9653
9329
|
return activeClient;
|
|
9654
9330
|
setActiveClient(client);
|
|
9655
9331
|
}
|
|
9656
|
-
catch (
|
|
9332
|
+
catch (_d) {
|
|
9657
9333
|
setActiveClient(client);
|
|
9658
9334
|
}
|
|
9659
9335
|
return client;
|
|
@@ -12442,7 +12118,7 @@ const uploadFile = async (formData, onProgress) => {
|
|
|
12442
12118
|
const headers = 'getHeaders' in formData
|
|
12443
12119
|
? formData.getHeaders()
|
|
12444
12120
|
: { 'content-type': 'multipart/form-data' };
|
|
12445
|
-
const { data } = await client.
|
|
12121
|
+
const { data } = await client.upload.post('/api/v4/files', formData, {
|
|
12446
12122
|
headers,
|
|
12447
12123
|
onUploadProgress({ loaded, total = 100 }) {
|
|
12448
12124
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -12532,7 +12208,7 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
12532
12208
|
const headers = 'getHeaders' in formData
|
|
12533
12209
|
? formData.getHeaders()
|
|
12534
12210
|
: { 'content-type': 'multipart/form-data' };
|
|
12535
|
-
const { data } = await client.
|
|
12211
|
+
const { data } = await client.upload.post('/api/v4/videos', formData, {
|
|
12536
12212
|
headers,
|
|
12537
12213
|
onUploadProgress({ loaded, total = 100 }) {
|
|
12538
12214
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -12580,7 +12256,7 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
12580
12256
|
const headers = 'getHeaders' in formData
|
|
12581
12257
|
? formData.getHeaders()
|
|
12582
12258
|
: { 'content-type': 'multipart/form-data' };
|
|
12583
|
-
const { data } = await client.
|
|
12259
|
+
const { data } = await client.upload.post('/api/v4/images', formData, {
|
|
12584
12260
|
headers,
|
|
12585
12261
|
onUploadProgress({ loaded, total = 100 }) {
|
|
12586
12262
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -16773,37 +16449,19 @@ var index$f = /*#__PURE__*/Object.freeze({
|
|
|
16773
16449
|
/**
|
|
16774
16450
|
* Internal used only
|
|
16775
16451
|
*
|
|
16776
|
-
* Fired when an {@link Amity.
|
|
16777
|
-
*
|
|
16778
|
-
* @param callback The function to call when the event was fired
|
|
16779
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16780
|
-
*
|
|
16781
|
-
* @category ChannelMarker Events
|
|
16782
|
-
*/
|
|
16783
|
-
const onChannelUnreadInfoUpdatedLocal = (callback) => {
|
|
16784
|
-
const client = getActiveClient();
|
|
16785
|
-
const filter = (payload) => {
|
|
16786
|
-
callback(payload);
|
|
16787
|
-
};
|
|
16788
|
-
return createEventSubscriber(client, 'channelMarker/onChannelUnreadInfoUpdatedLocal', 'local.channelUnreadInfo.updated', filter);
|
|
16789
|
-
};
|
|
16790
|
-
|
|
16791
|
-
/**
|
|
16792
|
-
* Internal used only
|
|
16793
|
-
*
|
|
16794
|
-
* Fired when an {@link Amity.ChannelUnread} has been updated.
|
|
16452
|
+
* Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
|
|
16795
16453
|
*
|
|
16796
16454
|
* @param callback The function to call when the event was fired
|
|
16797
16455
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16798
16456
|
*
|
|
16799
|
-
* @category
|
|
16457
|
+
* @category MessageMarker Events
|
|
16800
16458
|
*/
|
|
16801
16459
|
const onChannelUnreadUpdatedLocal = (callback) => {
|
|
16802
16460
|
const client = getActiveClient();
|
|
16803
16461
|
const filter = (payload) => {
|
|
16804
16462
|
callback(payload);
|
|
16805
16463
|
};
|
|
16806
|
-
return createEventSubscriber(client, '
|
|
16464
|
+
return createEventSubscriber(client, 'channelMarker/onChannelUnreadUpdatedLocal', 'local.channelUnread.updated', filter);
|
|
16807
16465
|
};
|
|
16808
16466
|
|
|
16809
16467
|
/* begin_public_function
|
|
@@ -17005,7 +16663,6 @@ const getChannel = (channelId, callback) => {
|
|
|
17005
16663
|
return onSubChannelUpdated(updateMessagePreview);
|
|
17006
16664
|
}, 'channelId', 'channel'),
|
|
17007
16665
|
convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
|
|
17008
|
-
convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
17009
16666
|
convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
|
|
17010
16667
|
], {
|
|
17011
16668
|
forceDispatch: true,
|
|
@@ -17519,10 +17176,6 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
17519
17176
|
},
|
|
17520
17177
|
action: "OnResolveUnread" /* Amity.ChannelActionType.OnResolveUnread */,
|
|
17521
17178
|
},
|
|
17522
|
-
{
|
|
17523
|
-
fn: convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
17524
|
-
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|
|
17525
|
-
},
|
|
17526
17179
|
{
|
|
17527
17180
|
fn: convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
|
|
17528
17181
|
action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
|