@amityco/ts-sdk 7.1.1-c8d4edca.0 → 7.1.1-e887d15f.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/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.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/events/onChannelUnreadUpdatedLocal.d.ts +2 -2
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
- package/dist/index.cjs.js +46 -13
- package/dist/index.esm.js +46 -13
- package/dist/index.umd.js +1 -1
- package/dist/marker/events/onChannelUnreadInfoUpdatedLocal.d.ts +2 -2
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +2 -0
- package/src/channelRepository/events/onChannelDeleted.ts +10 -4
- package/src/channelRepository/events/onChannelLeft.ts +11 -3
- package/src/channelRepository/events/onChannelUnreadUpdatedLocal.ts +2 -2
- package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +0 -3
- package/src/marker/events/onChannelUnreadInfoUpdatedLocal.ts +2 -2
- package/src/messageRepository/events/onMessageCreated.ts +34 -0
- package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts +0 -12
- package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts.map +0 -1
- package/src/marker/events/onChannelUnreadUpdatedLocal.ts +0 -29
|
@@ -53,6 +53,7 @@ declare global {
|
|
|
53
53
|
type InternalChannel<T extends ChannelType = any> = Omit<StaticInternalChannel<T>, 'messageCount'> & {
|
|
54
54
|
isMentioned: boolean;
|
|
55
55
|
subChannelsUnreadCount: number;
|
|
56
|
+
unreadCount: number;
|
|
56
57
|
};
|
|
57
58
|
type Channel<T extends ChannelType = any> = InternalChannel<T> & {
|
|
58
59
|
messagePreview?: Amity.MessageP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B,EAAE,MAAM,CAAC,CAClC,CAAC;QAGF,KAAK,aAAa,GAAG;YACnB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACtC,WAAW,EAAE,MAAM,CAAC;YACpB,WAAW,EAAE,OAAO,CAAC;YACrB,aAAa,EAAE,MAAM,CAAC;YACtB,WAAW,EAAE,MAAM,CAAC;YACpB,kBAAkB,EAAE,MAAM,CAAC;YAC3B,SAAS,EAAE,OAAO,CAAC;SACpB,CAAC;KACH;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onChannelDeleted.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/events/onChannelDeleted.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onChannelDeleted.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/events/onChannelDeleted.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,gBAAgB,aAAc,MAAM,QAAQ,CAAC,MAAM,qBAAqB,CAAC,eA4BrF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onChannelLeft.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/events/onChannelLeft.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onChannelLeft.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/events/onChannelLeft.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,aAAa,uBACJ,MAAM,qBAAqB,UAAU,MAAM,UAAU,CAAC,SAAS,CAAC,KAAK,IAAI,eAyC9F,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal used only
|
|
3
3
|
*
|
|
4
|
-
* Fired when an {@link Amity.
|
|
4
|
+
* Fired when an {@link Amity.ChannelUnread} has been updated.
|
|
5
5
|
*
|
|
6
6
|
* @param callback The function to call when the event was fired
|
|
7
7
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8
8
|
*
|
|
9
|
-
* @category
|
|
9
|
+
* @category Channel Events
|
|
10
10
|
*/
|
|
11
11
|
export declare const onChannelUnreadUpdatedLocal: (callback: Amity.Listener<Amity.Events['local.channelUnread.updated']>) => Amity.Unsubscriber;
|
|
12
12
|
//# sourceMappingURL=onChannelUnreadUpdatedLocal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readReceiptSyncEngine.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts"],"names":[],"mappings":"AAKA,qBAAa,4BAA4B;IACvC,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,QAAQ,CAAQ;IAExB,OAAO,CAAC,SAAS,CAAK;IAEtB,OAAO,CAAC,cAAc,CAAO;IAE7B,OAAO,CAAC,QAAQ,CAAkC;IAElD,OAAO,CAAC,KAAK,CAA2B;IAGxC,OAAO,CAAC,qBAAqB,CAAK;;IASlC,oBAAoB;IAQpB,gBAAgB,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"readReceiptSyncEngine.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts"],"names":[],"mappings":"AAKA,qBAAa,4BAA4B;IACvC,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,QAAQ,CAAQ;IAExB,OAAO,CAAC,SAAS,CAAK;IAEtB,OAAO,CAAC,cAAc,CAAO;IAE7B,OAAO,CAAC,QAAQ,CAAkC;IAElD,OAAO,CAAC,KAAK,CAA2B;IAGxC,OAAO,CAAC,qBAAqB,CAAK;;IASlC,oBAAoB;IAQpB,gBAAgB,IAAI,IAAI;IASxB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,eAAe;YAaT,WAAW;IAuCzB,OAAO,CAAC,8BAA8B;IAOtC,OAAO,CAAC,6BAA6B;IAerC,oBAAoB,IAAI,IAAI;IAI5B,kBAAkB,IAAI,IAAI;IAK1B,cAAc,IAAI,IAAI;IAKtB,gBAAgB,IAAI,IAAI;IAKxB,eAAe,IAAI,IAAI;IAKvB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAiBlD,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,UAAU;CASnB;;;;AAID,wBAME"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -5627,7 +5627,6 @@ class MessageReadReceiptSyncEngine {
|
|
|
5627
5627
|
if (this.jobQueue.length === 0 || this.isActive === false)
|
|
5628
5628
|
return;
|
|
5629
5629
|
const readReceipts = this.getReadReceipts();
|
|
5630
|
-
console.log('[New 🌟 readReceipts] Sync read receipts', readReceipts);
|
|
5631
5630
|
if (readReceipts) {
|
|
5632
5631
|
this.markReadApi(readReceipts);
|
|
5633
5632
|
}
|
|
@@ -5729,7 +5728,6 @@ class MessageReadReceiptSyncEngine {
|
|
|
5729
5728
|
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
5730
5729
|
const cacheKey = ['channelUnread', 'get', channelId];
|
|
5731
5730
|
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
5732
|
-
console.log('[New 🌟] Mark read => channel unread', channelUnread);
|
|
5733
5731
|
if (channelUnread && segment > channelUnread.readToSegment) {
|
|
5734
5732
|
channelUnread.readToSegment = segment;
|
|
5735
5733
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
@@ -7919,12 +7917,17 @@ const onChannelDeleted = (callback) => {
|
|
|
7919
7917
|
const client = getActiveClient();
|
|
7920
7918
|
const filter = async (payload) => {
|
|
7921
7919
|
const data = await prepareChannelPayload(payload);
|
|
7922
|
-
|
|
7923
|
-
|
|
7920
|
+
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
7921
|
+
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
7922
|
+
data.channels.forEach(channel => {
|
|
7923
|
+
if (isConsistentMode) {
|
|
7924
7924
|
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
7925
7925
|
deleteChannelUnreadByChannelId(channel.channelId);
|
|
7926
|
-
}
|
|
7927
|
-
|
|
7926
|
+
}
|
|
7927
|
+
else if (isLegacyUnreadCount) {
|
|
7928
|
+
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
7929
|
+
}
|
|
7930
|
+
});
|
|
7928
7931
|
ingestInCache(data);
|
|
7929
7932
|
callbacks$b.forEach(cb => cb(data.channels[0]));
|
|
7930
7933
|
};
|
|
@@ -8623,10 +8626,17 @@ const onChannelLeft = (callback) => {
|
|
|
8623
8626
|
const preparedPayload = await prepareChannelPayload(payload, {
|
|
8624
8627
|
isMessagePreviewUpdated: isLeftByMe,
|
|
8625
8628
|
});
|
|
8626
|
-
|
|
8629
|
+
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
8630
|
+
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
8631
|
+
if (isLeftByMe) {
|
|
8627
8632
|
preparedPayload.channels.forEach(channel => {
|
|
8628
|
-
|
|
8629
|
-
|
|
8633
|
+
if (isConsistentMode) {
|
|
8634
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
8635
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
8636
|
+
}
|
|
8637
|
+
else if (isLegacyUnreadCount) {
|
|
8638
|
+
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
8639
|
+
}
|
|
8630
8640
|
});
|
|
8631
8641
|
}
|
|
8632
8642
|
const { channels, channelUsers } = preparedPayload;
|
|
@@ -8894,6 +8904,29 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
8894
8904
|
reCalculateChannelUnreadInfo(message.channelId);
|
|
8895
8905
|
});
|
|
8896
8906
|
}
|
|
8907
|
+
if (client.useLegacyUnreadCount) {
|
|
8908
|
+
rawPayload.messages.forEach(message => {
|
|
8909
|
+
var _a, _b;
|
|
8910
|
+
const channelUnread = (_a = pullFromCache([
|
|
8911
|
+
'channelUnread',
|
|
8912
|
+
'get',
|
|
8913
|
+
message.channelId,
|
|
8914
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
8915
|
+
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
8916
|
+
return;
|
|
8917
|
+
const lastSegment = message.segment;
|
|
8918
|
+
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
8919
|
+
return (mention.type === 'channel' ||
|
|
8920
|
+
(mention.type === 'user' &&
|
|
8921
|
+
client.userId &&
|
|
8922
|
+
mention.userPublicIds.includes(client.userId)));
|
|
8923
|
+
});
|
|
8924
|
+
const lastMentionSegment = isMentionedInMessage
|
|
8925
|
+
? message.segment
|
|
8926
|
+
: channelUnread.lastMentionSegment;
|
|
8927
|
+
pushToCache(['channelUnread', 'get', message.channelId], Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: lastSegment - channelUnread.readToSegment, lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) }));
|
|
8928
|
+
});
|
|
8929
|
+
}
|
|
8897
8930
|
// Update in cache
|
|
8898
8931
|
ingestInCache(payload);
|
|
8899
8932
|
payload.messages.forEach(message => {
|
|
@@ -16736,12 +16769,12 @@ var index$f = /*#__PURE__*/Object.freeze({
|
|
|
16736
16769
|
/**
|
|
16737
16770
|
* Internal used only
|
|
16738
16771
|
*
|
|
16739
|
-
* Fired when an {@link Amity.
|
|
16772
|
+
* Fired when an {@link Amity.channelUnreadInfo} has been updated.
|
|
16740
16773
|
*
|
|
16741
16774
|
* @param callback The function to call when the event was fired
|
|
16742
16775
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16743
16776
|
*
|
|
16744
|
-
* @category
|
|
16777
|
+
* @category ChannelMarker Events
|
|
16745
16778
|
*/
|
|
16746
16779
|
const onChannelUnreadInfoUpdatedLocal = (callback) => {
|
|
16747
16780
|
const client = getActiveClient();
|
|
@@ -16754,12 +16787,12 @@ const onChannelUnreadInfoUpdatedLocal = (callback) => {
|
|
|
16754
16787
|
/**
|
|
16755
16788
|
* Internal used only
|
|
16756
16789
|
*
|
|
16757
|
-
* Fired when an {@link Amity.
|
|
16790
|
+
* Fired when an {@link Amity.ChannelUnread} has been updated.
|
|
16758
16791
|
*
|
|
16759
16792
|
* @param callback The function to call when the event was fired
|
|
16760
16793
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16761
16794
|
*
|
|
16762
|
-
* @category
|
|
16795
|
+
* @category Channel Events
|
|
16763
16796
|
*/
|
|
16764
16797
|
const onChannelUnreadUpdatedLocal = (callback) => {
|
|
16765
16798
|
const client = getActiveClient();
|
package/dist/index.esm.js
CHANGED
|
@@ -21719,7 +21719,6 @@ class MessageReadReceiptSyncEngine {
|
|
|
21719
21719
|
if (this.jobQueue.length === 0 || this.isActive === false)
|
|
21720
21720
|
return;
|
|
21721
21721
|
const readReceipts = this.getReadReceipts();
|
|
21722
|
-
console.log('[New 🌟 readReceipts] Sync read receipts', readReceipts);
|
|
21723
21722
|
if (readReceipts) {
|
|
21724
21723
|
this.markReadApi(readReceipts);
|
|
21725
21724
|
}
|
|
@@ -21821,7 +21820,6 @@ class MessageReadReceiptSyncEngine {
|
|
|
21821
21820
|
// Step 1: Optimistic update of channelUnread.readToSegment to message.segment and update unreadCount value
|
|
21822
21821
|
const cacheKey = ['channelUnread', 'get', channelId];
|
|
21823
21822
|
const channelUnread = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21824
|
-
console.log('[New 🌟] Mark read => channel unread', channelUnread);
|
|
21825
21823
|
if (channelUnread && segment > channelUnread.readToSegment) {
|
|
21826
21824
|
channelUnread.readToSegment = segment;
|
|
21827
21825
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
@@ -24011,12 +24009,17 @@ const onChannelDeleted = (callback) => {
|
|
|
24011
24009
|
const client = getActiveClient();
|
|
24012
24010
|
const filter = async (payload) => {
|
|
24013
24011
|
const data = await prepareChannelPayload(payload);
|
|
24014
|
-
|
|
24015
|
-
|
|
24012
|
+
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
24013
|
+
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
24014
|
+
data.channels.forEach(channel => {
|
|
24015
|
+
if (isConsistentMode) {
|
|
24016
24016
|
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
24017
24017
|
deleteChannelUnreadByChannelId(channel.channelId);
|
|
24018
|
-
}
|
|
24019
|
-
|
|
24018
|
+
}
|
|
24019
|
+
else if (isLegacyUnreadCount) {
|
|
24020
|
+
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
24021
|
+
}
|
|
24022
|
+
});
|
|
24020
24023
|
ingestInCache(data);
|
|
24021
24024
|
callbacks$b.forEach(cb => cb(data.channels[0]));
|
|
24022
24025
|
};
|
|
@@ -24715,10 +24718,17 @@ const onChannelLeft = (callback) => {
|
|
|
24715
24718
|
const preparedPayload = await prepareChannelPayload(payload, {
|
|
24716
24719
|
isMessagePreviewUpdated: isLeftByMe,
|
|
24717
24720
|
});
|
|
24718
|
-
|
|
24721
|
+
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
24722
|
+
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
24723
|
+
if (isLeftByMe) {
|
|
24719
24724
|
preparedPayload.channels.forEach(channel => {
|
|
24720
|
-
|
|
24721
|
-
|
|
24725
|
+
if (isConsistentMode) {
|
|
24726
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
24727
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
24728
|
+
}
|
|
24729
|
+
else if (isLegacyUnreadCount) {
|
|
24730
|
+
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
24731
|
+
}
|
|
24722
24732
|
});
|
|
24723
24733
|
}
|
|
24724
24734
|
const { channels, channelUsers } = preparedPayload;
|
|
@@ -24986,6 +24996,29 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
24986
24996
|
reCalculateChannelUnreadInfo(message.channelId);
|
|
24987
24997
|
});
|
|
24988
24998
|
}
|
|
24999
|
+
if (client.useLegacyUnreadCount) {
|
|
25000
|
+
rawPayload.messages.forEach(message => {
|
|
25001
|
+
var _a, _b;
|
|
25002
|
+
const channelUnread = (_a = pullFromCache([
|
|
25003
|
+
'channelUnread',
|
|
25004
|
+
'get',
|
|
25005
|
+
message.channelId,
|
|
25006
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
25007
|
+
if (!channelUnread || channelUnread.lastSegment >= message.segment)
|
|
25008
|
+
return;
|
|
25009
|
+
const lastSegment = message.segment;
|
|
25010
|
+
const isMentionedInMessage = (_b = message.mentionedUsers) === null || _b === void 0 ? void 0 : _b.some(mention => {
|
|
25011
|
+
return (mention.type === 'channel' ||
|
|
25012
|
+
(mention.type === 'user' &&
|
|
25013
|
+
client.userId &&
|
|
25014
|
+
mention.userPublicIds.includes(client.userId)));
|
|
25015
|
+
});
|
|
25016
|
+
const lastMentionSegment = isMentionedInMessage
|
|
25017
|
+
? message.segment
|
|
25018
|
+
: channelUnread.lastMentionSegment;
|
|
25019
|
+
pushToCache(['channelUnread', 'get', message.channelId], Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: lastSegment - channelUnread.readToSegment, lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) }));
|
|
25020
|
+
});
|
|
25021
|
+
}
|
|
24989
25022
|
// Update in cache
|
|
24990
25023
|
ingestInCache(payload);
|
|
24991
25024
|
payload.messages.forEach(message => {
|
|
@@ -32828,12 +32861,12 @@ var index$f = /*#__PURE__*/Object.freeze({
|
|
|
32828
32861
|
/**
|
|
32829
32862
|
* Internal used only
|
|
32830
32863
|
*
|
|
32831
|
-
* Fired when an {@link Amity.
|
|
32864
|
+
* Fired when an {@link Amity.channelUnreadInfo} has been updated.
|
|
32832
32865
|
*
|
|
32833
32866
|
* @param callback The function to call when the event was fired
|
|
32834
32867
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
32835
32868
|
*
|
|
32836
|
-
* @category
|
|
32869
|
+
* @category ChannelMarker Events
|
|
32837
32870
|
*/
|
|
32838
32871
|
const onChannelUnreadInfoUpdatedLocal = (callback) => {
|
|
32839
32872
|
const client = getActiveClient();
|
|
@@ -32846,12 +32879,12 @@ const onChannelUnreadInfoUpdatedLocal = (callback) => {
|
|
|
32846
32879
|
/**
|
|
32847
32880
|
* Internal used only
|
|
32848
32881
|
*
|
|
32849
|
-
* Fired when an {@link Amity.
|
|
32882
|
+
* Fired when an {@link Amity.ChannelUnread} has been updated.
|
|
32850
32883
|
*
|
|
32851
32884
|
* @param callback The function to call when the event was fired
|
|
32852
32885
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
32853
32886
|
*
|
|
32854
|
-
* @category
|
|
32887
|
+
* @category Channel Events
|
|
32855
32888
|
*/
|
|
32856
32889
|
const onChannelUnreadUpdatedLocal = (callback) => {
|
|
32857
32890
|
const client = getActiveClient();
|