@amityco/ts-sdk 7.1.1-ce25d503.0 → 7.1.1-dbdbe662.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 +2 -2
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
- package/dist/index.cjs.js +20 -8
- package/dist/index.esm.js +20 -8
- package/dist/index.umd.js +1 -1
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +2 -2
- package/src/channelRepository/utils/prepareChannelPayload.ts +16 -7
- package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +5 -1
- package/src/messageRepository/events/onMessageCreated.ts +8 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onMessageCreated.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/events/onMessageCreated.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,aACrB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,
|
|
1
|
+
{"version":3,"file":"onMessageCreated.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/events/onMessageCreated.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,aACrB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YA0ER,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACtB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YAoBR,CAAC"}
|
package/package.json
CHANGED
|
@@ -145,9 +145,9 @@ declare global {
|
|
|
145
145
|
channelId: Amity.Channel['channelId'];
|
|
146
146
|
unreadCount: number;
|
|
147
147
|
isMentioned: boolean;
|
|
148
|
-
readToSegment: number;
|
|
148
|
+
readToSegment: number | null;
|
|
149
149
|
lastSegment: number;
|
|
150
|
-
lastMentionSegment: number;
|
|
150
|
+
lastMentionSegment: number | null;
|
|
151
151
|
isDeleted: boolean;
|
|
152
152
|
};
|
|
153
153
|
}
|
|
@@ -58,21 +58,30 @@ const updateChannelUnread = ({
|
|
|
58
58
|
}) => {
|
|
59
59
|
for (let i = 0; i < channels.length; i += 1) {
|
|
60
60
|
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
61
|
-
const
|
|
61
|
+
const channelUser = channelUsers.find(
|
|
62
62
|
channelUser =>
|
|
63
63
|
channelUser.channelId === channels[i].channelId && channelUser.userId === currentUserId,
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
let unreadCount = 0;
|
|
67
|
+
let readToSegment = null;
|
|
68
|
+
let lastMentionedSegment = null;
|
|
69
|
+
let isMentioned = false;
|
|
70
|
+
|
|
71
|
+
if (channelUser) {
|
|
72
|
+
readToSegment = channelUser.readToSegment;
|
|
73
|
+
lastMentionedSegment = channelUser.lastMentionedSegment;
|
|
74
|
+
unreadCount = Math.max(channels[i].messageCount - readToSegment, 0);
|
|
75
|
+
isMentioned = lastMentionedSegment > readToSegment;
|
|
76
|
+
}
|
|
68
77
|
|
|
69
78
|
pushToCache(cacheKey, {
|
|
70
79
|
channelId: channels[i].channelId,
|
|
71
80
|
lastSegment: channels[i].messageCount,
|
|
72
81
|
readToSegment,
|
|
73
82
|
lastMentionedSegment,
|
|
74
|
-
unreadCount
|
|
75
|
-
isMentioned
|
|
83
|
+
unreadCount,
|
|
84
|
+
isMentioned,
|
|
76
85
|
isDeleted: channels[i].isDeleted,
|
|
77
86
|
});
|
|
78
87
|
}
|
|
@@ -158,7 +158,11 @@ export class MessageReadReceiptSyncEngine {
|
|
|
158
158
|
const cacheKey = ['channelUnread', 'get', channelId];
|
|
159
159
|
const channelUnread = pullFromCache<Amity.ChannelUnread>(cacheKey)?.data;
|
|
160
160
|
|
|
161
|
-
if (
|
|
161
|
+
if (
|
|
162
|
+
typeof channelUnread?.readToSegment === 'number' &&
|
|
163
|
+
channelUnread &&
|
|
164
|
+
segment > channelUnread.readToSegment
|
|
165
|
+
) {
|
|
162
166
|
channelUnread.readToSegment = segment;
|
|
163
167
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
164
168
|
|
|
@@ -48,7 +48,14 @@ export const onMessageCreatedMqtt = (
|
|
|
48
48
|
'get',
|
|
49
49
|
message.channelId,
|
|
50
50
|
])?.data;
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
!channelUnread ||
|
|
54
|
+
channelUnread.lastSegment >= message.segment ||
|
|
55
|
+
typeof channelUnread.readToSegment !== 'number' ||
|
|
56
|
+
typeof channelUnread.lastMentionSegment !== 'number'
|
|
57
|
+
)
|
|
58
|
+
return;
|
|
52
59
|
|
|
53
60
|
const lastSegment = message.segment;
|
|
54
61
|
const isMentionedInMessage = message.mentionedUsers?.some(mention => {
|