@amityco/ts-sdk 7.5.3-bab1d06.0 → 7.5.3-d42be10.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/client/api/enableUnreadCount.d.ts.map +1 -1
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
- package/dist/index.cjs.js +430 -319
- package/dist/index.esm.js +430 -319
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/client/api/enableUnreadCount.ts +22 -0
- package/src/client/api/login.ts +4 -0
- package/src/client/utils/markerSyncEngine.ts +24 -3
- package/src/reactionRepository/api/addReaction.ts +1 -1
package/package.json
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import { ASCError } from '~/core/errors';
|
|
2
|
+
import { getActiveClient } from './activeClient';
|
|
3
|
+
|
|
1
4
|
export const enableUnreadCount = () => {
|
|
5
|
+
const client = getActiveClient();
|
|
6
|
+
|
|
7
|
+
client.log('client/api/isUnreadCountEnabled', client.isUnreadCountEnabled);
|
|
8
|
+
|
|
9
|
+
if (!client) {
|
|
10
|
+
throw new ASCError(
|
|
11
|
+
'There is no active client',
|
|
12
|
+
Amity.ClientError.UNKNOWN_ERROR,
|
|
13
|
+
Amity.ErrorLevel.FATAL,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (client.isUnreadCountEnabled) return false;
|
|
18
|
+
|
|
19
|
+
client.isUnreadCountEnabled = true;
|
|
20
|
+
client.useLegacyUnreadCount = false;
|
|
21
|
+
|
|
22
|
+
client.emitter.emit('unreadCountEnabled', true);
|
|
23
|
+
|
|
2
24
|
return true;
|
|
3
25
|
};
|
package/src/client/api/login.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { onTokenTerminated } from '../events/onTokenTerminated';
|
|
|
26
26
|
import { setClientToken } from '../utils/setClientToken';
|
|
27
27
|
import { removeChannelMarkerCache } from '../utils/removeChannelMarkerCache';
|
|
28
28
|
import { initializeMessagePreviewSetting } from '../utils/messagePreviewEngine';
|
|
29
|
+
import { startMarkerSync } from '../utils/markerSyncEngine';
|
|
29
30
|
import { ASCError } from '~/core/errors';
|
|
30
31
|
import SessionWatcher from '../utils/SessionWatcher';
|
|
31
32
|
|
|
@@ -206,6 +207,9 @@ export const login = async (
|
|
|
206
207
|
if (client.useLegacyUnreadCount) {
|
|
207
208
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
208
209
|
} else subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
|
|
210
|
+
|
|
211
|
+
const markerSyncUnsubscriber = await startMarkerSync();
|
|
212
|
+
subscriptions.push(markerSyncUnsubscriber);
|
|
209
213
|
}
|
|
210
214
|
|
|
211
215
|
return true;
|
|
@@ -14,6 +14,7 @@ import { onSubChannelDeleted } from '~/subChannelRepository/events/onSubChannelD
|
|
|
14
14
|
import { isUnreadCountSupport } from '~/subChannelRepository/utils';
|
|
15
15
|
|
|
16
16
|
import { markerSync } from '../api/markerSync';
|
|
17
|
+
import { enableUnreadCount } from '../api/enableUnreadCount';
|
|
17
18
|
|
|
18
19
|
import { onOnline } from './onOnline';
|
|
19
20
|
import { onUserFeedMarkerUpdated } from '~/marker/events/onUserFeedMarkerUpdated';
|
|
@@ -26,7 +27,7 @@ let isSyncRunning = false;
|
|
|
26
27
|
let disposers: (() => void)[] = [];
|
|
27
28
|
let isWaitingForResponse = false;
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
let isConsistentMode = true;
|
|
30
31
|
let deviceLastSyncAt: Date | null = null;
|
|
31
32
|
|
|
32
33
|
const getDeviceLastSyncAt = () => {
|
|
@@ -177,7 +178,17 @@ const unRegisterEventListeners = () => {
|
|
|
177
178
|
disposers = [];
|
|
178
179
|
};
|
|
179
180
|
|
|
180
|
-
export const startMarkerSync = async () =>
|
|
181
|
+
export const startMarkerSync = async () => {
|
|
182
|
+
await fetchDeviceLastSyncAt();
|
|
183
|
+
pushMarkerSyncEvent(Amity.MarkerSyncEvent.START_SYNCING);
|
|
184
|
+
|
|
185
|
+
isConsistentMode = true;
|
|
186
|
+
isSyncRunning = true;
|
|
187
|
+
|
|
188
|
+
registerEventListeners();
|
|
189
|
+
|
|
190
|
+
return unRegisterEventListeners;
|
|
191
|
+
};
|
|
181
192
|
|
|
182
193
|
/**
|
|
183
194
|
```js
|
|
@@ -190,7 +201,17 @@ export const startMarkerSync = async () => Promise.resolve();
|
|
|
190
201
|
*
|
|
191
202
|
* @category Marker API
|
|
192
203
|
*/
|
|
193
|
-
export const startUnreadSync = async () =>
|
|
204
|
+
export const startUnreadSync = async () => {
|
|
205
|
+
await fetchDeviceLastSyncAt();
|
|
206
|
+
pushMarkerSyncEvent(Amity.MarkerSyncEvent.START_SYNCING);
|
|
207
|
+
|
|
208
|
+
enableUnreadCount();
|
|
209
|
+
|
|
210
|
+
isConsistentMode = false;
|
|
211
|
+
isSyncRunning = true;
|
|
212
|
+
|
|
213
|
+
registerEventListeners();
|
|
214
|
+
};
|
|
194
215
|
|
|
195
216
|
/**
|
|
196
217
|
```js
|