@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
|
@@ -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.userMessageFeedMarkers} has been resolved by Object Rsesolver
|
|
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 MessageMarker 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onChannelUnreadUpdatedLocal.d.ts","sourceRoot":"","sources":["../../../src/marker/events/onChannelUnreadUpdatedLocal.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,aAC5B,MAAM,QAAQ,CAAC,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC,KACpE,MAAM,YAaR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onMessageCreated.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/events/onMessageCreated.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onMessageCreated.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/events/onMessageCreated.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,aACrB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YA+BR,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACtB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YAoBR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markReadMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/utils/markReadMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markReadMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/utils/markReadMessage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,YAAa,MAAM,eAAe,SAK7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -237,8 +237,7 @@ declare global {
|
|
|
237
237
|
};
|
|
238
238
|
|
|
239
239
|
'local.subChannelUnread.updated': Amity.SubChannelUnreadInfo;
|
|
240
|
-
'local.
|
|
241
|
-
'local.channelUnread.updated': Amity.ChannelUnread;
|
|
240
|
+
'local.channelUnread.updated': Amity.ChannelUnreadInfo;
|
|
242
241
|
|
|
243
242
|
'local.story.created': Amity.StoryPayload;
|
|
244
243
|
'local.story.updated': Amity.StoryPayload;
|
package/src/@types/core/model.ts
CHANGED
|
@@ -25,8 +25,6 @@ declare global {
|
|
|
25
25
|
channelUnreadInfo: Amity.ChannelUnreadInfo;
|
|
26
26
|
subChannelUnreadInfo: Amity.SubChannelUnreadInfo;
|
|
27
27
|
|
|
28
|
-
channelUnread: Amity.ChannelUnread;
|
|
29
|
-
|
|
30
28
|
channelMarker: Amity.ChannelMarker;
|
|
31
29
|
subChannelMarker: Amity.SubChannelMarker;
|
|
32
30
|
messageMarker: Amity.MessageMarker;
|
|
@@ -86,8 +84,6 @@ declare global {
|
|
|
86
84
|
channelUnreadInfo: Pick<Amity.ChannelUnreadInfo, 'channelId'>;
|
|
87
85
|
subChannelUnreadInfo: Pick<Amity.SubChannelUnreadInfo, 'subChannelId'>;
|
|
88
86
|
|
|
89
|
-
channelUnread: Pick<Amity.ChannelUnread, 'channelId'>;
|
|
90
|
-
|
|
91
87
|
channelMarker: Pick<Amity.ChannelMarker, 'entityId' | 'userId'>;
|
|
92
88
|
subChannelMarker: Pick<Amity.SubChannelMarker, 'feedId' | 'entityId' | 'userId'>;
|
|
93
89
|
messageMarker: Pick<Amity.MessageMarker, 'feedId' | 'contentId' | 'creatorId'>;
|
|
@@ -8,25 +8,12 @@ declare global {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
type ReadReceipt = {
|
|
11
|
-
channelId: Amity.Channel['channelId'];
|
|
12
|
-
latestSegment: number;
|
|
13
|
-
latestSyncSegment: number;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type ReadReceiptSyncJob = {
|
|
17
|
-
channelId: Amity.Channel['channelId'];
|
|
18
|
-
segment: number;
|
|
19
|
-
syncState: ReadReceiptSyncState;
|
|
20
|
-
retryCount: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type LegacyReadReceipt = {
|
|
24
11
|
subChannelId: Amity.SubChannel['subChannelId'];
|
|
25
12
|
latestSegment: number;
|
|
26
13
|
latestSyncSegment: number;
|
|
27
14
|
};
|
|
28
15
|
|
|
29
|
-
type
|
|
16
|
+
type ReadReceiptSyncJob = {
|
|
30
17
|
subChannelId: Amity.SubChannel['subChannelId'];
|
|
31
18
|
segment: number;
|
|
32
19
|
syncState: ReadReceiptSyncState;
|
|
@@ -84,8 +84,6 @@ declare global {
|
|
|
84
84
|
> & {
|
|
85
85
|
isMentioned: boolean;
|
|
86
86
|
subChannelsUnreadCount: number;
|
|
87
|
-
// legacy unread count does not use the maker service
|
|
88
|
-
unreadCount: number;
|
|
89
87
|
};
|
|
90
88
|
|
|
91
89
|
/* public type */
|
|
@@ -139,16 +137,5 @@ declare global {
|
|
|
139
137
|
Amity.Membership<'channel'>['userId'],
|
|
140
138
|
Pick<QueryChannelMembers, 'page'>
|
|
141
139
|
>;
|
|
142
|
-
|
|
143
|
-
// Use for channel's unread count value stored in the local cache
|
|
144
|
-
type ChannelUnread = {
|
|
145
|
-
channelId: Amity.Channel['channelId'];
|
|
146
|
-
unreadCount: number;
|
|
147
|
-
isMentioned: boolean;
|
|
148
|
-
readToSegment: number;
|
|
149
|
-
lastSegment: number;
|
|
150
|
-
lastMentionSegment: number;
|
|
151
|
-
isDeleted: boolean;
|
|
152
|
-
};
|
|
153
140
|
}
|
|
154
141
|
}
|
|
@@ -36,6 +36,7 @@ declare global {
|
|
|
36
36
|
|
|
37
37
|
log: Logger;
|
|
38
38
|
http: AxiosInstance;
|
|
39
|
+
upload: AxiosInstance;
|
|
39
40
|
mqtt?: Amity.MqttClient;
|
|
40
41
|
ws?: SocketIOClient.Socket;
|
|
41
42
|
emitter: Emitter<Amity.Events>;
|
|
@@ -56,8 +57,6 @@ declare global {
|
|
|
56
57
|
|
|
57
58
|
isUnreadCountEnabled: boolean;
|
|
58
59
|
|
|
59
|
-
useLegacyUnreadCount: boolean;
|
|
60
|
-
|
|
61
60
|
use: () => void;
|
|
62
61
|
|
|
63
62
|
accessTokenExpiryWatcher: (sessionHandler: Amity.SessionHandler) => Amity.Unsubscriber;
|
|
@@ -6,7 +6,6 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
6
6
|
import { prepareChannelPayload } from '../utils/prepareChannelPayload';
|
|
7
7
|
import { addFlagIsDeletedSubChannelUnreadByChannelId } from '~/marker/utils/addFlagIsDeletedSubChannelUnreadByChannelId';
|
|
8
8
|
import { deleteChannelUnreadByChannelId } from '../../marker/utils/deleteChannelUnreadByChannelId';
|
|
9
|
-
import { dropFromCache, pullFromCache, pushToCache } from '~/cache/api';
|
|
10
9
|
|
|
11
10
|
type CallbackFn = (channel: Amity.StaticInternalChannel) => void;
|
|
12
11
|
const callbacks: CallbackFn[] = [];
|
|
@@ -29,24 +28,12 @@ export const onChannelDeleted = (callback: Amity.Listener<Amity.StaticInternalCh
|
|
|
29
28
|
const filter = async (payload: Amity.ChannelPayload) => {
|
|
30
29
|
const data = await prepareChannelPayload(payload);
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
data.channels.forEach(channel => {
|
|
36
|
-
if (isConsistentMode) {
|
|
31
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
32
|
+
data.channels.forEach(channel => {
|
|
37
33
|
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
38
34
|
deleteChannelUnreadByChannelId(channel.channelId);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const cache = pullFromCache<Amity.ChannelUnread>(cacheKey);
|
|
42
|
-
if (cache) {
|
|
43
|
-
pushToCache(cacheKey, {
|
|
44
|
-
...cache,
|
|
45
|
-
isDeleted: true,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
50
37
|
|
|
51
38
|
ingestInCache(data);
|
|
52
39
|
callbacks.forEach(cb => cb(data.channels[0]));
|
|
@@ -6,7 +6,6 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
6
6
|
import { prepareChannelPayload } from '../utils';
|
|
7
7
|
import { deleteChannelUnreadByChannelId } from '../../marker/utils/deleteChannelUnreadByChannelId';
|
|
8
8
|
import { addFlagIsDeletedSubChannelUnreadByChannelId } from '~/marker/utils/addFlagIsDeletedSubChannelUnreadByChannelId';
|
|
9
|
-
import { dropFromCache } from '~/cache/api';
|
|
10
9
|
|
|
11
10
|
type CallbackFn = (
|
|
12
11
|
channel: Amity.StaticInternalChannel,
|
|
@@ -41,17 +40,10 @@ export const onChannelLeft = (
|
|
|
41
40
|
isMessagePreviewUpdated: isLeftByMe,
|
|
42
41
|
});
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
46
|
-
|
|
47
|
-
if (isLeftByMe) {
|
|
43
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode() && isLeftByMe) {
|
|
48
44
|
preparedPayload.channels.forEach(channel => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
deleteChannelUnreadByChannelId(channel.channelId);
|
|
52
|
-
} else if (isLegacyUnreadCount) {
|
|
53
|
-
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
54
|
-
}
|
|
45
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
46
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
55
47
|
});
|
|
56
48
|
}
|
|
57
49
|
|
|
@@ -32,9 +32,8 @@ import { isEqual } from '~/utils/isEqual';
|
|
|
32
32
|
import { updateChannelCache } from '../utils/updateChannelCache';
|
|
33
33
|
import { onChannelMarkerUpdated } from '~/marker/events/onChannelMarkerUpdated';
|
|
34
34
|
import { onSubChannelCreated } from '~/subChannelRepository';
|
|
35
|
-
import {
|
|
35
|
+
import { onChannelUnreadUpdatedLocal } from '~/marker/events/onChannelUnreadUpdatedLocal';
|
|
36
36
|
import { constructChannelObject } from '../utils/constructChannelObject';
|
|
37
|
-
import { onChannelUnreadUpdatedLocal } from '../events/onChannelUnreadUpdatedLocal';
|
|
38
37
|
|
|
39
38
|
/* begin_public_function
|
|
40
39
|
id: channel.get
|
|
@@ -296,7 +295,6 @@ export const getChannel = (
|
|
|
296
295
|
'channel',
|
|
297
296
|
),
|
|
298
297
|
convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
|
|
299
|
-
convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
300
298
|
convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
|
|
301
299
|
],
|
|
302
300
|
{
|
|
@@ -55,9 +55,8 @@ import { prepareUnreadCountInfo } from '~/channelRepository/utils/prepareUnreadC
|
|
|
55
55
|
import { resolveUnreadInfoOnChannelEvent } from '~/channelRepository/utils/resolveUnreadInfoOnChannelEvent';
|
|
56
56
|
import { onChannelResolved } from '~/channelRepository/events/onChannelResolved';
|
|
57
57
|
import { onUserMessageFeedMarkerResolved } from '~/marker/events/onUserMessageFeedMarkerResolved';
|
|
58
|
-
import {
|
|
58
|
+
import { onChannelUnreadUpdatedLocal } from '~/marker/events/onChannelUnreadUpdatedLocal';
|
|
59
59
|
import { constructChannelObject } from '~/channelRepository/utils/constructChannelObject';
|
|
60
|
-
import { onChannelUnreadUpdatedLocal } from '~/channelRepository/events/onChannelUnreadUpdatedLocal';
|
|
61
60
|
|
|
62
61
|
export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
63
62
|
'channel',
|
|
@@ -567,10 +566,6 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
567
566
|
},
|
|
568
567
|
action: Amity.ChannelActionType.OnResolveUnread,
|
|
569
568
|
},
|
|
570
|
-
{
|
|
571
|
-
fn: convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
572
|
-
action: Amity.ChannelActionType.OnUpdate,
|
|
573
|
-
},
|
|
574
569
|
{
|
|
575
570
|
fn: convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
|
|
576
571
|
action: Amity.ChannelActionType.OnUpdate,
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import { get } from 'http';
|
|
2
1
|
import { shallowClone } from '~/utils/shallowClone';
|
|
3
2
|
import { getChannelIsMentioned } from './getChannelIsMentioned';
|
|
4
3
|
import { getSubChannelsUnreadCount } from './getSubChannelsUnreadCount';
|
|
5
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
6
|
-
import { getLegacyChannelUnread } from './getLegacyChannelUnread';
|
|
7
4
|
|
|
8
5
|
export const constructChannelDynamicValue = (
|
|
9
6
|
channel: Amity.StaticInternalChannel,
|
|
10
7
|
): Amity.InternalChannel => {
|
|
11
|
-
const client = getActiveClient();
|
|
12
8
|
const { messageCount, ...rest } = channel;
|
|
13
|
-
|
|
14
9
|
return shallowClone(rest, {
|
|
15
|
-
get
|
|
16
|
-
return
|
|
10
|
+
get isMentioned() {
|
|
11
|
+
return getChannelIsMentioned(rest);
|
|
17
12
|
},
|
|
18
13
|
get subChannelsUnreadCount() {
|
|
19
14
|
return getSubChannelsUnreadCount(rest);
|
|
20
15
|
},
|
|
21
|
-
get isMentioned() {
|
|
22
|
-
if (client.useLegacyUnreadCount)
|
|
23
|
-
return getLegacyChannelUnread(rest.channelId)?.isMentioned ?? false;
|
|
24
|
-
return getChannelIsMentioned(rest);
|
|
25
|
-
},
|
|
26
16
|
});
|
|
27
17
|
};
|
|
@@ -5,8 +5,9 @@ import { getChannelMarkers } from '~/marker/api/getChannelMarkers';
|
|
|
5
5
|
import { updateChannelMessagePreviewCache } from '~/messagePreview/utils';
|
|
6
6
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
7
7
|
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
8
|
+
import { getSubChannelsUnreadCount } from './getSubChannelsUnreadCount';
|
|
9
|
+
import { getChannelIsMentioned } from './getChannelIsMentioned';
|
|
8
10
|
import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
|
|
9
|
-
import { pushToCache } from '~/cache/api';
|
|
10
11
|
|
|
11
12
|
export const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
12
13
|
export const isUnreadCountSupport = ({ type }: Pick<Amity.RawChannel, 'type'>) =>
|
|
@@ -47,37 +48,6 @@ export const preUpdateChannelCache = (
|
|
|
47
48
|
});
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
const updateChannelUnread = ({
|
|
51
|
-
currentUserId,
|
|
52
|
-
channels,
|
|
53
|
-
channelUsers,
|
|
54
|
-
}: {
|
|
55
|
-
currentUserId: Amity.User['userId'];
|
|
56
|
-
channels: Amity.RawChannel[];
|
|
57
|
-
channelUsers: Amity.RawMembership<'channel'>[];
|
|
58
|
-
}) => {
|
|
59
|
-
for (let i = 0; i < channels.length; i += 1) {
|
|
60
|
-
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
61
|
-
const { readToSegment, lastMentionedSegment } = channelUsers.find(
|
|
62
|
-
channelUser =>
|
|
63
|
-
channelUser.channelId === channels[i].channelId && channelUser.userId === currentUserId,
|
|
64
|
-
) || {
|
|
65
|
-
readToSegment: 0,
|
|
66
|
-
lastMentionedSegment: 0,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
pushToCache(cacheKey, {
|
|
70
|
-
channelId: channels[i].channelId,
|
|
71
|
-
lastSegment: channels[i].messageCount,
|
|
72
|
-
readToSegment,
|
|
73
|
-
lastMentionedSegment,
|
|
74
|
-
unreadCount: channels[i].messageCount - readToSegment,
|
|
75
|
-
isMentioned: lastMentionedSegment > readToSegment,
|
|
76
|
-
isDeleted: channels[i].isDeleted,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
51
|
export const prepareChannelPayload = async (
|
|
82
52
|
rawPayload: Amity.ChannelPayload,
|
|
83
53
|
options: { isMessagePreviewUpdated?: boolean } = { isMessagePreviewUpdated: true },
|
|
@@ -94,38 +64,28 @@ export const prepareChannelPayload = async (
|
|
|
94
64
|
updateChannelMessagePreviewCache(rawPayload);
|
|
95
65
|
}
|
|
96
66
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// since the get markers method requires a channel cache to function with the reducer.
|
|
111
|
-
preUpdateChannelCache(rawPayload, {
|
|
112
|
-
isMessagePreviewUpdated: options.isMessagePreviewUpdated,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
await getChannelMarkers(markerIds);
|
|
117
|
-
} catch (e) {
|
|
118
|
-
// empty block (from the spec, allow marker fetch to fail without having to do anything)
|
|
119
|
-
}
|
|
67
|
+
const markerIds = rawPayload.channels
|
|
68
|
+
// filter channel by type. Only conversation, community and broadcast type are included.
|
|
69
|
+
.filter(isUnreadCountSupport)
|
|
70
|
+
.map(({ channelInternalId }) => channelInternalId);
|
|
71
|
+
|
|
72
|
+
if (markerIds.length > 0) {
|
|
73
|
+
// since the get markers method requires a channel cache to function with the reducer.
|
|
74
|
+
preUpdateChannelCache(rawPayload, { isMessagePreviewUpdated: options.isMessagePreviewUpdated });
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
await getChannelMarkers(markerIds);
|
|
78
|
+
} catch (e) {
|
|
79
|
+
// empty block (from the spec, allow marker fetch to fail without having to do anything)
|
|
120
80
|
}
|
|
121
81
|
}
|
|
122
82
|
|
|
123
|
-
//
|
|
83
|
+
// attach marker to channel
|
|
124
84
|
const channels = rawPayload.channels.map(payload =>
|
|
125
85
|
convertFromRaw(payload, { isMessagePreviewUpdated: options.isMessagePreviewUpdated }),
|
|
126
86
|
);
|
|
127
87
|
|
|
128
|
-
//
|
|
88
|
+
// user marker to channel users
|
|
129
89
|
const channelUsers: Amity.Membership<'channel'>[] = rawPayload.channelUsers.map(channelUser => {
|
|
130
90
|
return convertRawMembershipToMembership<'channel'>(channelUser);
|
|
131
91
|
});
|
|
@@ -50,7 +50,7 @@ export const createClient = (
|
|
|
50
50
|
rteEnabled = true,
|
|
51
51
|
}: {
|
|
52
52
|
debugSession?: string;
|
|
53
|
-
apiEndpoint?: { http?: string; mqtt?: string };
|
|
53
|
+
apiEndpoint?: { http?: string; mqtt?: string; upload?: string };
|
|
54
54
|
prefixDeviceIdKey?: string;
|
|
55
55
|
rteEnabled?: boolean;
|
|
56
56
|
} = {},
|
|
@@ -63,9 +63,11 @@ export const createClient = (
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
const httpEndpoint = apiEndpoint?.http ?? computeUrl('http', apiRegion);
|
|
66
|
+
const uploadEndpoint = apiEndpoint?.upload ?? computeUrl('upload', apiRegion);
|
|
66
67
|
const mqttEndpoint = apiEndpoint?.mqtt ?? computeUrl('mqtt', apiRegion);
|
|
67
68
|
|
|
68
69
|
const http = createHttpTransport(httpEndpoint);
|
|
70
|
+
const upload = createHttpTransport(uploadEndpoint);
|
|
69
71
|
|
|
70
72
|
let ws;
|
|
71
73
|
let mqtt;
|
|
@@ -86,8 +88,6 @@ export const createClient = (
|
|
|
86
88
|
const sessionHandler = undefined;
|
|
87
89
|
|
|
88
90
|
const isUnreadCountEnabled = false;
|
|
89
|
-
// Legacy unread count is true by default
|
|
90
|
-
const useLegacyUnreadCount = true;
|
|
91
91
|
|
|
92
92
|
const client = {
|
|
93
93
|
version: `${VERSION}`,
|
|
@@ -105,6 +105,7 @@ export const createClient = (
|
|
|
105
105
|
http,
|
|
106
106
|
ws,
|
|
107
107
|
mqtt,
|
|
108
|
+
upload,
|
|
108
109
|
emitter,
|
|
109
110
|
|
|
110
111
|
/*
|
|
@@ -124,7 +125,6 @@ export const createClient = (
|
|
|
124
125
|
use: () => setActiveClient(client),
|
|
125
126
|
|
|
126
127
|
isUnreadCountEnabled,
|
|
127
|
-
useLegacyUnreadCount,
|
|
128
128
|
|
|
129
129
|
getMarkerSyncConsistentMode,
|
|
130
130
|
|
package/src/client/api/login.ts
CHANGED
|
@@ -11,7 +11,6 @@ import { onUserDeleted } from '~/userRepository/events/onUserDeleted';
|
|
|
11
11
|
|
|
12
12
|
import analyticsEngineOnLoginHandler from '~/analytic/utils/analyticsEngineOnLoginHandler';
|
|
13
13
|
import readReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler';
|
|
14
|
-
import legacyReadReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler';
|
|
15
14
|
import objectResolverEngineOnLoginHandler from '~/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler';
|
|
16
15
|
import { logout } from './logout';
|
|
17
16
|
|
|
@@ -201,13 +200,10 @@ export const login = async (
|
|
|
201
200
|
|
|
202
201
|
markReadEngineOnLoginHandler(),
|
|
203
202
|
analyticsEngineOnLoginHandler(),
|
|
203
|
+
readReceiptSyncEngineOnLoginHandler(),
|
|
204
204
|
objectResolverEngineOnLoginHandler(),
|
|
205
205
|
);
|
|
206
206
|
|
|
207
|
-
if (client.useLegacyUnreadCount) {
|
|
208
|
-
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
209
|
-
} else subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
|
|
210
|
-
|
|
211
207
|
const markerSyncUnsubscriber = await startMarkerSync();
|
|
212
208
|
subscriptions.push(markerSyncUnsubscriber);
|
|
213
209
|
}
|