@amityco/ts-sdk 7.1.1-c8d4edca.0 → 7.1.1-ce25d503.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.
Files changed (34) hide show
  1. package/dist/@types/domains/channel.d.ts +1 -0
  2. package/dist/@types/domains/channel.d.ts.map +1 -1
  3. package/dist/channelRepository/events/onChannelDeleted.d.ts.map +1 -1
  4. package/dist/channelRepository/events/onChannelLeft.d.ts.map +1 -1
  5. package/dist/channelRepository/events/onChannelUnreadUpdatedLocal.d.ts +2 -2
  6. package/dist/channelRepository/internalApi/getTotalChannelsUnread.d.ts +11 -0
  7. package/dist/channelRepository/internalApi/getTotalChannelsUnread.d.ts.map +1 -0
  8. package/dist/channelRepository/observers/getTotalChannelsUnread.d.ts +20 -0
  9. package/dist/channelRepository/observers/getTotalChannelsUnread.d.ts.map +1 -0
  10. package/dist/channelRepository/observers/index.d.ts +1 -0
  11. package/dist/channelRepository/observers/index.d.ts.map +1 -1
  12. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
  13. package/dist/index.cjs.js +168 -14
  14. package/dist/index.esm.js +168 -14
  15. package/dist/index.umd.js +4 -4
  16. package/dist/marker/events/onChannelUnreadInfoUpdatedLocal.d.ts +2 -2
  17. package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
  18. package/dist/messageRepository/observers/getMessage.d.ts.map +1 -1
  19. package/package.json +1 -1
  20. package/src/@types/domains/channel.ts +2 -0
  21. package/src/channelRepository/events/onChannelDeleted.ts +17 -4
  22. package/src/channelRepository/events/onChannelLeft.ts +11 -3
  23. package/src/channelRepository/events/onChannelUnreadUpdatedLocal.ts +2 -2
  24. package/src/channelRepository/internalApi/getTotalChannelsUnread.ts +38 -0
  25. package/src/channelRepository/observers/getTotalChannelsUnread.ts +129 -0
  26. package/src/channelRepository/observers/index.ts +1 -0
  27. package/src/channelRepository/utils/prepareChannelPayload.ts +1 -1
  28. package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +0 -3
  29. package/src/marker/events/onChannelUnreadInfoUpdatedLocal.ts +2 -2
  30. package/src/messageRepository/events/onMessageCreated.ts +38 -1
  31. package/src/messageRepository/observers/getMessage.ts +0 -1
  32. package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts +0 -12
  33. package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts.map +0 -1
  34. package/src/marker/events/onChannelUnreadUpdatedLocal.ts +0 -29
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Internal used only
3
3
  *
4
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
4
+ * Fired when an {@link Amity.channelUnreadInfo} 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 MessageMarker Events
9
+ * @category ChannelMarker Events
10
10
  */
11
11
  export declare const onChannelUnreadInfoUpdatedLocal: (callback: Amity.Listener<Amity.Events['local.channelUnreadInfo.updated']>) => Amity.Unsubscriber;
12
12
  //# sourceMappingURL=onChannelUnreadInfoUpdatedLocal.d.ts.map
@@ -1 +1 @@
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
+ {"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,YAmER,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACtB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YAoBR,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/observers/getMessage.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,cACV,MAAM,OAAO,CAAC,WAAW,CAAC,YAC3B,MAAM,kBAAkB,CAAC,MAAM,OAAO,CAAC,KAChD,MAAM,YAmBR,CAAC"}
1
+ {"version":3,"file":"getMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/observers/getMessage.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,cACV,MAAM,OAAO,CAAC,WAAW,CAAC,YAC3B,MAAM,kBAAkB,CAAC,MAAM,OAAO,CAAC,KAChD,MAAM,YAmBR,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "7.1.1-c8d4edca.0",
3
+ "version": "7.1.1-ce25d503.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -84,6 +84,8 @@ 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;
87
89
  };
88
90
 
89
91
  /* public type */
@@ -6,6 +6,7 @@ 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';
9
10
 
10
11
  type CallbackFn = (channel: Amity.StaticInternalChannel) => void;
11
12
  const callbacks: CallbackFn[] = [];
@@ -28,12 +29,24 @@ export const onChannelDeleted = (callback: Amity.Listener<Amity.StaticInternalCh
28
29
  const filter = async (payload: Amity.ChannelPayload) => {
29
30
  const data = await prepareChannelPayload(payload);
30
31
 
31
- if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
32
- data.channels.forEach(channel => {
32
+ const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
33
+ const isLegacyUnreadCount = client.useLegacyUnreadCount;
34
+
35
+ data.channels.forEach(channel => {
36
+ if (isConsistentMode) {
33
37
  addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
34
38
  deleteChannelUnreadByChannelId(channel.channelId);
35
- });
36
- }
39
+ } else if (isLegacyUnreadCount) {
40
+ const cacheKey = ['channelUnread', 'get', channel.channelId];
41
+ const cache = pullFromCache<Amity.ChannelUnread>(cacheKey);
42
+ if (cache) {
43
+ pushToCache(cacheKey, {
44
+ ...cache,
45
+ isDeleted: true,
46
+ });
47
+ }
48
+ }
49
+ });
37
50
 
38
51
  ingestInCache(data);
39
52
  callbacks.forEach(cb => cb(data.channels[0]));
@@ -6,6 +6,7 @@ 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';
9
10
 
10
11
  type CallbackFn = (
11
12
  channel: Amity.StaticInternalChannel,
@@ -40,10 +41,17 @@ export const onChannelLeft = (
40
41
  isMessagePreviewUpdated: isLeftByMe,
41
42
  });
42
43
 
43
- if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode() && isLeftByMe) {
44
+ const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
45
+ const isLegacyUnreadCount = client.useLegacyUnreadCount;
46
+
47
+ if (isLeftByMe) {
44
48
  preparedPayload.channels.forEach(channel => {
45
- addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
46
- deleteChannelUnreadByChannelId(channel.channelId);
49
+ if (isConsistentMode) {
50
+ addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
51
+ deleteChannelUnreadByChannelId(channel.channelId);
52
+ } else if (isLegacyUnreadCount) {
53
+ dropFromCache(['channelUnread', 'get', channel.channelId]);
54
+ }
47
55
  });
48
56
  }
49
57
 
@@ -4,12 +4,12 @@ import { createEventSubscriber } from '~/core/events';
4
4
  /**
5
5
  * Internal used only
6
6
  *
7
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
7
+ * Fired when an {@link Amity.ChannelUnread} has been updated.
8
8
  *
9
9
  * @param callback The function to call when the event was fired
10
10
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11
11
  *
12
- * @category MessageMarker Events
12
+ * @category Channel Events
13
13
  */
14
14
  export const onChannelUnreadUpdatedLocal = (
15
15
  callback: Amity.Listener<Amity.Events['local.channelUnread.updated']>,
@@ -0,0 +1,38 @@
1
+ import { queryCache } from '~/cache/api';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
+
4
+ /**
5
+ *
6
+ * Calculate user unread from {@link Amity.ChannelUnread} objects
7
+ *
8
+ * @returns the {@link Amity.UserUnread} objects
9
+ *
10
+ * @category Channel API
11
+ * @async
12
+ */
13
+
14
+ export const getTotalChannelsUnread = (): Amity.Cached<Amity.UserUnread> => {
15
+ const client = getActiveClient();
16
+ client.log('channel/getTotalChannelsUnread.locally');
17
+
18
+ const cachedChannelsUnread =
19
+ queryCache<Amity.ChannelUnread>(['channelUnread', 'get'])?.filter(({ data }) => {
20
+ return !data.isDeleted;
21
+ }) || [];
22
+
23
+ const totalChannelsUnread: Amity.UserUnread = cachedChannelsUnread?.reduce(
24
+ (acc, { data }) => {
25
+ acc.unreadCount += data.unreadCount;
26
+ acc.isMentioned = acc.isMentioned || data.isMentioned;
27
+ return acc;
28
+ },
29
+ { unreadCount: 0, isMentioned: false as boolean },
30
+ ) || { unreadCount: 0, isMentioned: false };
31
+
32
+ const cachedAt = client.cache && Date.now();
33
+
34
+ return {
35
+ data: totalChannelsUnread,
36
+ cachedAt,
37
+ };
38
+ };
@@ -0,0 +1,129 @@
1
+ import { getActiveUser } from '~/client/api/activeUser';
2
+ import { getTotalChannelsUnread as _getTotalChannelsUnread } from '../internalApi/getTotalChannelsUnread';
3
+ import { onChannelUnreadUpdatedLocal } from '../events/onChannelUnreadUpdatedLocal';
4
+ import { ASCApiError, ASCError } from '~/core/errors';
5
+ import { getActiveClient } from '~/client';
6
+ import { convertGetterPropsToStatic } from '~/utils/object';
7
+ import { createQuery, runQuery } from '~/core/query';
8
+ import {
9
+ UNSYNCED_OBJECT_CACHED_AT_MESSAGE,
10
+ UNSYNCED_OBJECT_CACHED_AT_VALUE,
11
+ } from '~/utils/constants';
12
+ import { isEqual } from '~/utils/isEqual';
13
+
14
+ /* begin_public_function
15
+ id: totalChannelsUnread.get
16
+ */
17
+ /**
18
+ * ```js
19
+ * import { ChannelRepository } from '@amityco/ts-sdk';
20
+ *
21
+ * let totalChannelsUnread;
22
+ *
23
+ * const unsubscribe = ChannelRepository.getTotalChannelsUnread(response => {
24
+ * unread = response.data;
25
+ * });
26
+ * ```
27
+ *
28
+ * Observe all mutation on a given {@link Amity.UserUnread}
29
+ *
30
+ * @returns An {@link Amity.UserUnread} function to run when willing to stop observing the message
31
+ *
32
+ * @category User Unread Live Object
33
+ *
34
+ */
35
+
36
+ export const getTotalChannelsUnread = (
37
+ callback: Amity.LiveObjectCallback<Amity.UserUnread | undefined>,
38
+ ): Amity.Unsubscriber => {
39
+ const { _id: userId } = getActiveUser();
40
+
41
+ if (!userId)
42
+ throw new ASCError(
43
+ 'The _id has not been defined in ActiveUser',
44
+ Amity.ClientError.UNKNOWN_ERROR,
45
+ Amity.ErrorLevel.ERROR,
46
+ );
47
+
48
+ const { log, cache } = getActiveClient();
49
+
50
+ if (!cache) {
51
+ console.log('For using Live Object feature you need to enable Cache!');
52
+ }
53
+
54
+ const timestamp = Date.now();
55
+ log(`liveTotalChannelsUnread(tmpid: ${timestamp}) > listen`);
56
+
57
+ const disposers: Amity.Unsubscriber[] = [];
58
+
59
+ let isUnsyncedModel = false; // for messages
60
+
61
+ let model: Amity.UserUnread | undefined;
62
+
63
+ const dispatcher = (data: Amity.LiveObject<Amity.UserUnread | undefined>) => {
64
+ const { data: userUnread } = data;
65
+
66
+ const callbackModel = userUnread
67
+ ? {
68
+ unreadCount: userUnread.unreadCount,
69
+ isMentioned: userUnread.isMentioned,
70
+ }
71
+ : undefined;
72
+
73
+ model = callbackModel ? convertGetterPropsToStatic(callbackModel) : callbackModel;
74
+
75
+ callback({
76
+ data: callbackModel
77
+ ? { ...callbackModel, isMentioned: callbackModel.isMentioned }
78
+ : callbackModel,
79
+
80
+ loading: data.loading,
81
+ error: data.error,
82
+ });
83
+ };
84
+
85
+ const realtimeRouter = (userUnread: Amity.UserUnread) => {
86
+ if (isEqual(model, userUnread)) return;
87
+
88
+ dispatcher({
89
+ loading: false,
90
+ data: userUnread,
91
+ });
92
+ };
93
+
94
+ const onFetch = () => {
95
+ const query = createQuery(async () => _getTotalChannelsUnread());
96
+
97
+ runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
98
+ if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
99
+ dispatcher({
100
+ data,
101
+ origin,
102
+ loading: false,
103
+ error: new ASCApiError(
104
+ UNSYNCED_OBJECT_CACHED_AT_MESSAGE,
105
+ Amity.ClientError.DISALOOW_UNSYNCED_OBJECT,
106
+ Amity.ErrorLevel.ERROR,
107
+ ),
108
+ });
109
+
110
+ isUnsyncedModel = true;
111
+ disposers.forEach(fn => fn());
112
+ } else if (!isUnsyncedModel) {
113
+ dispatcher({ loading, data, origin, error });
114
+ }
115
+
116
+ if (error) {
117
+ disposers.forEach(fn => fn());
118
+ }
119
+ });
120
+ };
121
+
122
+ disposers.push(onChannelUnreadUpdatedLocal(realtimeRouter));
123
+
124
+ onFetch();
125
+
126
+ return () => {
127
+ disposers.forEach(fn => fn());
128
+ };
129
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './getChannel';
2
2
  export * from './getChannels';
3
+ export * from './getTotalChannelsUnread';
@@ -71,7 +71,7 @@ const updateChannelUnread = ({
71
71
  lastSegment: channels[i].messageCount,
72
72
  readToSegment,
73
73
  lastMentionedSegment,
74
- unreadCount: channels[i].messageCount - readToSegment,
74
+ unreadCount: Math.max(channels[i].messageCount - readToSegment, 0),
75
75
  isMentioned: lastMentionedSegment > readToSegment,
76
76
  isDeleted: channels[i].isDeleted,
77
77
  });
@@ -38,7 +38,6 @@ export class MessageReadReceiptSyncEngine {
38
38
  if (this.jobQueue.length === 0 || this.isActive === false) return;
39
39
 
40
40
  const readReceipts = this.getReadReceipts();
41
- console.log('[New 🌟 readReceipts] Sync read receipts', readReceipts);
42
41
  if (readReceipts) {
43
42
  this.markReadApi(readReceipts);
44
43
  }
@@ -159,8 +158,6 @@ export class MessageReadReceiptSyncEngine {
159
158
  const cacheKey = ['channelUnread', 'get', channelId];
160
159
  const channelUnread = pullFromCache<Amity.ChannelUnread>(cacheKey)?.data;
161
160
 
162
- console.log('[New 🌟] Mark read => channel unread', channelUnread);
163
-
164
161
  if (channelUnread && segment > channelUnread.readToSegment) {
165
162
  channelUnread.readToSegment = segment;
166
163
  channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
@@ -4,12 +4,12 @@ import { createEventSubscriber } from '~/core/events';
4
4
  /**
5
5
  * Internal used only
6
6
  *
7
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
7
+ * Fired when an {@link Amity.channelUnreadInfo} has been updated.
8
8
  *
9
9
  * @param callback The function to call when the event was fired
10
10
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11
11
  *
12
- * @category MessageMarker Events
12
+ * @category ChannelMarker Events
13
13
  */
14
14
  export const onChannelUnreadInfoUpdatedLocal = (
15
15
  callback: Amity.Listener<Amity.Events['local.channelUnreadInfo.updated']>,
@@ -1,11 +1,12 @@
1
1
  import { getActiveClient } from '~/client/api/activeClient';
2
- import { createEventSubscriber } from '~/core/events';
2
+ import { createEventSubscriber, fireEvent } from '~/core/events';
3
3
  import { ingestInCache } from '~/cache/api/ingestInCache';
4
4
  import { updateSubChannelUnreadFromMessage } from '~/marker/utils/updateSubChannelUnreadFromMessage';
5
5
  import { reCalculateChannelUnreadInfo } from '~/marker/utils/reCalculateChannelUnreadInfo';
6
6
  import { getActiveUser } from '~/client/api/activeUser';
7
7
  import { markReadMessage } from '../utils/markReadMessage';
8
8
  import { prepareMessagePayload } from '../utils';
9
+ import { pullFromCache, pushToCache } from '~/cache/api';
9
10
 
10
11
  /**
11
12
  * ```js
@@ -40,6 +41,42 @@ export const onMessageCreatedMqtt = (
40
41
  });
41
42
  }
42
43
 
44
+ if (client.useLegacyUnreadCount) {
45
+ rawPayload.messages.forEach(message => {
46
+ const channelUnread = pullFromCache<Amity.ChannelUnread>([
47
+ 'channelUnread',
48
+ 'get',
49
+ message.channelId,
50
+ ])?.data;
51
+ if (!channelUnread || channelUnread.lastSegment >= message.segment) return;
52
+
53
+ const lastSegment = message.segment;
54
+ const isMentionedInMessage = message.mentionedUsers?.some(mention => {
55
+ return (
56
+ mention.type === 'channel' ||
57
+ (mention.type === 'user' &&
58
+ client.userId &&
59
+ mention.userPublicIds.includes(client.userId))
60
+ );
61
+ });
62
+
63
+ const lastMentionSegment = isMentionedInMessage
64
+ ? message.segment
65
+ : channelUnread.lastMentionSegment;
66
+
67
+ const updatedChannelUnread = {
68
+ ...channelUnread,
69
+ lastSegment,
70
+ unreadCount: Math.max(lastSegment - channelUnread.readToSegment, 0),
71
+ lastMentionSegment,
72
+ isMentioned: !(channelUnread.readToSegment >= lastMentionSegment),
73
+ };
74
+
75
+ pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
76
+ fireEvent('local.channelUnread.updated', updatedChannelUnread);
77
+ });
78
+ }
79
+
43
80
  // Update in cache
44
81
  ingestInCache(payload);
45
82
 
@@ -13,7 +13,6 @@ import {
13
13
  } from '../events';
14
14
  import { onMessageFetched } from '../events/onMessageFetched';
15
15
  import { LinkedObject } from '~/utils/linkedObject';
16
- import { date } from '~/utils/tests';
17
16
 
18
17
  /* begin_public_function
19
18
  id: message.get
@@ -1,12 +0,0 @@
1
- /**
2
- * Internal used only
3
- *
4
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
5
- *
6
- * @param callback The function to call when the event was fired
7
- * @returns an {@link Amity.Unsubscriber} function to stop listening
8
- *
9
- * @category MessageMarker Events
10
- */
11
- export declare const onChannelUnreadUpdatedLocal: (callback: Amity.Listener<Amity.Events['local.channelUnread.updated']>) => Amity.Unsubscriber;
12
- //# sourceMappingURL=onChannelUnreadUpdatedLocal.d.ts.map
@@ -1 +0,0 @@
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,29 +0,0 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
- import { createEventSubscriber } from '~/core/events';
3
-
4
- /**
5
- * Internal used only
6
- *
7
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
8
- *
9
- * @param callback The function to call when the event was fired
10
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11
- *
12
- * @category MessageMarker Events
13
- */
14
- export const onChannelUnreadUpdatedLocal = (
15
- callback: Amity.Listener<Amity.Events['local.channelUnread.updated']>,
16
- ): Amity.Unsubscriber => {
17
- const client = getActiveClient();
18
-
19
- const filter = (payload: Amity.Events['local.channelUnread.updated']) => {
20
- callback(payload);
21
- };
22
-
23
- return createEventSubscriber(
24
- client,
25
- 'channel/onChannelUnreadUpdatedLocal',
26
- 'local.channelUnread.updated',
27
- filter,
28
- );
29
- };