@amityco/ts-sdk 7.1.1-a5f8c762.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 (27) hide show
  1. package/dist/channelRepository/events/onChannelDeleted.d.ts.map +1 -1
  2. package/dist/channelRepository/events/onChannelUnreadUpdatedLocal.d.ts +2 -2
  3. package/dist/channelRepository/internalApi/getTotalChannelsUnread.d.ts +11 -0
  4. package/dist/channelRepository/internalApi/getTotalChannelsUnread.d.ts.map +1 -0
  5. package/dist/channelRepository/observers/getTotalChannelsUnread.d.ts +20 -0
  6. package/dist/channelRepository/observers/getTotalChannelsUnread.d.ts.map +1 -0
  7. package/dist/channelRepository/observers/index.d.ts +1 -0
  8. package/dist/channelRepository/observers/index.d.ts.map +1 -1
  9. package/dist/index.cjs.js +128 -7
  10. package/dist/index.esm.js +128 -7
  11. package/dist/index.umd.js +4 -4
  12. package/dist/marker/events/onChannelUnreadInfoUpdatedLocal.d.ts +2 -2
  13. package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
  14. package/dist/messageRepository/observers/getMessage.d.ts.map +1 -1
  15. package/package.json +1 -1
  16. package/src/channelRepository/events/onChannelDeleted.ts +9 -2
  17. package/src/channelRepository/events/onChannelUnreadUpdatedLocal.ts +2 -2
  18. package/src/channelRepository/internalApi/getTotalChannelsUnread.ts +38 -0
  19. package/src/channelRepository/observers/getTotalChannelsUnread.ts +129 -0
  20. package/src/channelRepository/observers/index.ts +1 -0
  21. package/src/channelRepository/utils/prepareChannelPayload.ts +1 -1
  22. package/src/marker/events/onChannelUnreadInfoUpdatedLocal.ts +2 -2
  23. package/src/messageRepository/events/onMessageCreated.ts +7 -4
  24. package/src/messageRepository/observers/getMessage.ts +0 -1
  25. package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts +0 -12
  26. package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts.map +0 -1
  27. package/src/marker/events/onChannelUnreadUpdatedLocal.ts +0 -29
@@ -1 +1 @@
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
+ {"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,eAmCrF,CAAC"}
@@ -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.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 MessageMarker Events
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
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * Calculate user unread from {@link Amity.ChannelUnread} objects
4
+ *
5
+ * @returns the {@link Amity.UserUnread} objects
6
+ *
7
+ * @category Channel API
8
+ * @async
9
+ */
10
+ export declare const getTotalChannelsUnread: () => Amity.Cached<Amity.UserUnread>;
11
+ //# sourceMappingURL=getTotalChannelsUnread.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTotalChannelsUnread.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/internalApi/getTotalChannelsUnread.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,eAAO,MAAM,sBAAsB,QAAO,MAAM,MAAM,CAAC,MAAM,UAAU,CAwBtE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ```js
3
+ * import { ChannelRepository } from '@amityco/ts-sdk';
4
+ *
5
+ * let totalChannelsUnread;
6
+ *
7
+ * const unsubscribe = ChannelRepository.getTotalChannelsUnread(response => {
8
+ * unread = response.data;
9
+ * });
10
+ * ```
11
+ *
12
+ * Observe all mutation on a given {@link Amity.UserUnread}
13
+ *
14
+ * @returns An {@link Amity.UserUnread} function to run when willing to stop observing the message
15
+ *
16
+ * @category User Unread Live Object
17
+ *
18
+ */
19
+ export declare const getTotalChannelsUnread: (callback: Amity.LiveObjectCallback<Amity.UserUnread | undefined>) => Amity.Unsubscriber;
20
+ //# sourceMappingURL=getTotalChannelsUnread.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTotalChannelsUnread.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/observers/getTotalChannelsUnread.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,sBAAsB,aACvB,MAAM,kBAAkB,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,KAC/D,MAAM,YA2FR,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './getChannel';
2
2
  export * from './getChannels';
3
+ export * from './getTotalChannelsUnread';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -7070,7 +7070,7 @@ const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
7070
7070
  lastSegment: channels[i].messageCount,
7071
7071
  readToSegment,
7072
7072
  lastMentionedSegment,
7073
- unreadCount: channels[i].messageCount - readToSegment,
7073
+ unreadCount: Math.max(channels[i].messageCount - readToSegment, 0),
7074
7074
  isMentioned: lastMentionedSegment > readToSegment,
7075
7075
  isDeleted: channels[i].isDeleted,
7076
7076
  });
@@ -7925,7 +7925,11 @@ const onChannelDeleted = (callback) => {
7925
7925
  deleteChannelUnreadByChannelId(channel.channelId);
7926
7926
  }
7927
7927
  else if (isLegacyUnreadCount) {
7928
- dropFromCache(['channelUnread', 'get', channel.channelId]);
7928
+ const cacheKey = ['channelUnread', 'get', channel.channelId];
7929
+ const cache = pullFromCache(cacheKey);
7930
+ if (cache) {
7931
+ pushToCache(cacheKey, Object.assign(Object.assign({}, cache), { isDeleted: true }));
7932
+ }
7929
7933
  }
7930
7934
  });
7931
7935
  ingestInCache(data);
@@ -8924,7 +8928,9 @@ const onMessageCreatedMqtt = (callback) => {
8924
8928
  const lastMentionSegment = isMentionedInMessage
8925
8929
  ? message.segment
8926
8930
  : channelUnread.lastMentionSegment;
8927
- pushToCache(['channelUnread', 'get', message.channelId], Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: lastSegment - channelUnread.readToSegment, lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) }));
8931
+ const updatedChannelUnread = Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: Math.max(lastSegment - channelUnread.readToSegment, 0), lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) });
8932
+ pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
8933
+ fireEvent('local.channelUnread.updated', updatedChannelUnread);
8928
8934
  });
8929
8935
  }
8930
8936
  // Update in cache
@@ -16769,12 +16775,12 @@ var index$f = /*#__PURE__*/Object.freeze({
16769
16775
  /**
16770
16776
  * Internal used only
16771
16777
  *
16772
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
16778
+ * Fired when an {@link Amity.channelUnreadInfo} has been updated.
16773
16779
  *
16774
16780
  * @param callback The function to call when the event was fired
16775
16781
  * @returns an {@link Amity.Unsubscriber} function to stop listening
16776
16782
  *
16777
- * @category MessageMarker Events
16783
+ * @category ChannelMarker Events
16778
16784
  */
16779
16785
  const onChannelUnreadInfoUpdatedLocal = (callback) => {
16780
16786
  const client = getActiveClient();
@@ -16787,12 +16793,12 @@ const onChannelUnreadInfoUpdatedLocal = (callback) => {
16787
16793
  /**
16788
16794
  * Internal used only
16789
16795
  *
16790
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
16796
+ * Fired when an {@link Amity.ChannelUnread} has been updated.
16791
16797
  *
16792
16798
  * @param callback The function to call when the event was fired
16793
16799
  * @returns an {@link Amity.Unsubscriber} function to stop listening
16794
16800
  *
16795
- * @category MessageMarker Events
16801
+ * @category Channel Events
16796
16802
  */
16797
16803
  const onChannelUnreadUpdatedLocal = (callback) => {
16798
16804
  const client = getActiveClient();
@@ -17584,6 +17590,120 @@ const getChannels = (params, callback, config) => {
17584
17590
  };
17585
17591
  /* end_public_function */
17586
17592
 
17593
+ /**
17594
+ *
17595
+ * Calculate user unread from {@link Amity.ChannelUnread} objects
17596
+ *
17597
+ * @returns the {@link Amity.UserUnread} objects
17598
+ *
17599
+ * @category Channel API
17600
+ * @async
17601
+ */
17602
+ const getTotalChannelsUnread$1 = () => {
17603
+ var _a;
17604
+ const client = getActiveClient();
17605
+ client.log('channel/getTotalChannelsUnread.locally');
17606
+ const cachedChannelsUnread = ((_a = queryCache(['channelUnread', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
17607
+ return !data.isDeleted;
17608
+ })) || [];
17609
+ const totalChannelsUnread = (cachedChannelsUnread === null || cachedChannelsUnread === void 0 ? void 0 : cachedChannelsUnread.reduce((acc, { data }) => {
17610
+ acc.unreadCount += data.unreadCount;
17611
+ acc.isMentioned = acc.isMentioned || data.isMentioned;
17612
+ return acc;
17613
+ }, { unreadCount: 0, isMentioned: false })) || { unreadCount: 0, isMentioned: false };
17614
+ const cachedAt = client.cache && Date.now();
17615
+ return {
17616
+ data: totalChannelsUnread,
17617
+ cachedAt,
17618
+ };
17619
+ };
17620
+
17621
+ /* begin_public_function
17622
+ id: totalChannelsUnread.get
17623
+ */
17624
+ /**
17625
+ * ```js
17626
+ * import { ChannelRepository } from '@amityco/ts-sdk';
17627
+ *
17628
+ * let totalChannelsUnread;
17629
+ *
17630
+ * const unsubscribe = ChannelRepository.getTotalChannelsUnread(response => {
17631
+ * unread = response.data;
17632
+ * });
17633
+ * ```
17634
+ *
17635
+ * Observe all mutation on a given {@link Amity.UserUnread}
17636
+ *
17637
+ * @returns An {@link Amity.UserUnread} function to run when willing to stop observing the message
17638
+ *
17639
+ * @category User Unread Live Object
17640
+ *
17641
+ */
17642
+ const getTotalChannelsUnread = (callback) => {
17643
+ const { _id: userId } = getActiveUser();
17644
+ if (!userId)
17645
+ throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
17646
+ const { log, cache } = getActiveClient();
17647
+ if (!cache) {
17648
+ console.log('For using Live Object feature you need to enable Cache!');
17649
+ }
17650
+ const timestamp = Date.now();
17651
+ log(`liveTotalChannelsUnread(tmpid: ${timestamp}) > listen`);
17652
+ const disposers = [];
17653
+ let isUnsyncedModel = false; // for messages
17654
+ let model;
17655
+ const dispatcher = (data) => {
17656
+ const { data: userUnread } = data;
17657
+ const callbackModel = userUnread
17658
+ ? {
17659
+ unreadCount: userUnread.unreadCount,
17660
+ isMentioned: userUnread.isMentioned,
17661
+ }
17662
+ : undefined;
17663
+ model = callbackModel ? convertGetterPropsToStatic(callbackModel) : callbackModel;
17664
+ callback({
17665
+ data: callbackModel
17666
+ ? Object.assign(Object.assign({}, callbackModel), { isMentioned: callbackModel.isMentioned }) : callbackModel,
17667
+ loading: data.loading,
17668
+ error: data.error,
17669
+ });
17670
+ };
17671
+ const realtimeRouter = (userUnread) => {
17672
+ if (isEqual(model, userUnread))
17673
+ return;
17674
+ dispatcher({
17675
+ loading: false,
17676
+ data: userUnread,
17677
+ });
17678
+ };
17679
+ const onFetch = () => {
17680
+ const query = createQuery(async () => getTotalChannelsUnread$1());
17681
+ runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
17682
+ if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
17683
+ dispatcher({
17684
+ data,
17685
+ origin,
17686
+ loading: false,
17687
+ error: new ASCApiError(UNSYNCED_OBJECT_CACHED_AT_MESSAGE, 800800 /* Amity.ClientError.DISALOOW_UNSYNCED_OBJECT */, "error" /* Amity.ErrorLevel.ERROR */),
17688
+ });
17689
+ isUnsyncedModel = true;
17690
+ disposers.forEach(fn => fn());
17691
+ }
17692
+ else if (!isUnsyncedModel) {
17693
+ dispatcher({ loading, data, origin, error });
17694
+ }
17695
+ if (error) {
17696
+ disposers.forEach(fn => fn());
17697
+ }
17698
+ });
17699
+ };
17700
+ disposers.push(onChannelUnreadUpdatedLocal(realtimeRouter));
17701
+ onFetch();
17702
+ return () => {
17703
+ disposers.forEach(fn => fn());
17704
+ };
17705
+ };
17706
+
17587
17707
  /* begin_public_function
17588
17708
  id: channel.member.add
17589
17709
  */
@@ -18187,6 +18307,7 @@ var index$c = /*#__PURE__*/Object.freeze({
18187
18307
  onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
18188
18308
  getChannel: getChannel,
18189
18309
  getChannels: getChannels,
18310
+ getTotalChannelsUnread: getTotalChannelsUnread,
18190
18311
  MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
18191
18312
  isUnreadCountSupport: isUnreadCountSupport,
18192
18313
  convertFromRaw: convertFromRaw,
package/dist/index.esm.js CHANGED
@@ -23162,7 +23162,7 @@ const updateChannelUnread = ({ currentUserId, channels, channelUsers, }) => {
23162
23162
  lastSegment: channels[i].messageCount,
23163
23163
  readToSegment,
23164
23164
  lastMentionedSegment,
23165
- unreadCount: channels[i].messageCount - readToSegment,
23165
+ unreadCount: Math.max(channels[i].messageCount - readToSegment, 0),
23166
23166
  isMentioned: lastMentionedSegment > readToSegment,
23167
23167
  isDeleted: channels[i].isDeleted,
23168
23168
  });
@@ -24017,7 +24017,11 @@ const onChannelDeleted = (callback) => {
24017
24017
  deleteChannelUnreadByChannelId(channel.channelId);
24018
24018
  }
24019
24019
  else if (isLegacyUnreadCount) {
24020
- dropFromCache(['channelUnread', 'get', channel.channelId]);
24020
+ const cacheKey = ['channelUnread', 'get', channel.channelId];
24021
+ const cache = pullFromCache(cacheKey);
24022
+ if (cache) {
24023
+ pushToCache(cacheKey, Object.assign(Object.assign({}, cache), { isDeleted: true }));
24024
+ }
24021
24025
  }
24022
24026
  });
24023
24027
  ingestInCache(data);
@@ -25016,7 +25020,9 @@ const onMessageCreatedMqtt = (callback) => {
25016
25020
  const lastMentionSegment = isMentionedInMessage
25017
25021
  ? message.segment
25018
25022
  : channelUnread.lastMentionSegment;
25019
- pushToCache(['channelUnread', 'get', message.channelId], Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: lastSegment - channelUnread.readToSegment, lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) }));
25023
+ const updatedChannelUnread = Object.assign(Object.assign({}, channelUnread), { lastSegment, unreadCount: Math.max(lastSegment - channelUnread.readToSegment, 0), lastMentionSegment, isMentioned: !(channelUnread.readToSegment >= lastMentionSegment) });
25024
+ pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
25025
+ fireEvent('local.channelUnread.updated', updatedChannelUnread);
25020
25026
  });
25021
25027
  }
25022
25028
  // Update in cache
@@ -32861,12 +32867,12 @@ var index$f = /*#__PURE__*/Object.freeze({
32861
32867
  /**
32862
32868
  * Internal used only
32863
32869
  *
32864
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
32870
+ * Fired when an {@link Amity.channelUnreadInfo} has been updated.
32865
32871
  *
32866
32872
  * @param callback The function to call when the event was fired
32867
32873
  * @returns an {@link Amity.Unsubscriber} function to stop listening
32868
32874
  *
32869
- * @category MessageMarker Events
32875
+ * @category ChannelMarker Events
32870
32876
  */
32871
32877
  const onChannelUnreadInfoUpdatedLocal = (callback) => {
32872
32878
  const client = getActiveClient();
@@ -32879,12 +32885,12 @@ const onChannelUnreadInfoUpdatedLocal = (callback) => {
32879
32885
  /**
32880
32886
  * Internal used only
32881
32887
  *
32882
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
32888
+ * Fired when an {@link Amity.ChannelUnread} has been updated.
32883
32889
  *
32884
32890
  * @param callback The function to call when the event was fired
32885
32891
  * @returns an {@link Amity.Unsubscriber} function to stop listening
32886
32892
  *
32887
- * @category MessageMarker Events
32893
+ * @category Channel Events
32888
32894
  */
32889
32895
  const onChannelUnreadUpdatedLocal = (callback) => {
32890
32896
  const client = getActiveClient();
@@ -33676,6 +33682,120 @@ const getChannels = (params, callback, config) => {
33676
33682
  };
33677
33683
  /* end_public_function */
33678
33684
 
33685
+ /**
33686
+ *
33687
+ * Calculate user unread from {@link Amity.ChannelUnread} objects
33688
+ *
33689
+ * @returns the {@link Amity.UserUnread} objects
33690
+ *
33691
+ * @category Channel API
33692
+ * @async
33693
+ */
33694
+ const getTotalChannelsUnread$1 = () => {
33695
+ var _a;
33696
+ const client = getActiveClient();
33697
+ client.log('channel/getTotalChannelsUnread.locally');
33698
+ const cachedChannelsUnread = ((_a = queryCache(['channelUnread', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
33699
+ return !data.isDeleted;
33700
+ })) || [];
33701
+ const totalChannelsUnread = (cachedChannelsUnread === null || cachedChannelsUnread === void 0 ? void 0 : cachedChannelsUnread.reduce((acc, { data }) => {
33702
+ acc.unreadCount += data.unreadCount;
33703
+ acc.isMentioned = acc.isMentioned || data.isMentioned;
33704
+ return acc;
33705
+ }, { unreadCount: 0, isMentioned: false })) || { unreadCount: 0, isMentioned: false };
33706
+ const cachedAt = client.cache && Date.now();
33707
+ return {
33708
+ data: totalChannelsUnread,
33709
+ cachedAt,
33710
+ };
33711
+ };
33712
+
33713
+ /* begin_public_function
33714
+ id: totalChannelsUnread.get
33715
+ */
33716
+ /**
33717
+ * ```js
33718
+ * import { ChannelRepository } from '@amityco/ts-sdk';
33719
+ *
33720
+ * let totalChannelsUnread;
33721
+ *
33722
+ * const unsubscribe = ChannelRepository.getTotalChannelsUnread(response => {
33723
+ * unread = response.data;
33724
+ * });
33725
+ * ```
33726
+ *
33727
+ * Observe all mutation on a given {@link Amity.UserUnread}
33728
+ *
33729
+ * @returns An {@link Amity.UserUnread} function to run when willing to stop observing the message
33730
+ *
33731
+ * @category User Unread Live Object
33732
+ *
33733
+ */
33734
+ const getTotalChannelsUnread = (callback) => {
33735
+ const { _id: userId } = getActiveUser();
33736
+ if (!userId)
33737
+ throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
33738
+ const { log, cache } = getActiveClient();
33739
+ if (!cache) {
33740
+ console.log('For using Live Object feature you need to enable Cache!');
33741
+ }
33742
+ const timestamp = Date.now();
33743
+ log(`liveTotalChannelsUnread(tmpid: ${timestamp}) > listen`);
33744
+ const disposers = [];
33745
+ let isUnsyncedModel = false; // for messages
33746
+ let model;
33747
+ const dispatcher = (data) => {
33748
+ const { data: userUnread } = data;
33749
+ const callbackModel = userUnread
33750
+ ? {
33751
+ unreadCount: userUnread.unreadCount,
33752
+ isMentioned: userUnread.isMentioned,
33753
+ }
33754
+ : undefined;
33755
+ model = callbackModel ? convertGetterPropsToStatic(callbackModel) : callbackModel;
33756
+ callback({
33757
+ data: callbackModel
33758
+ ? Object.assign(Object.assign({}, callbackModel), { isMentioned: callbackModel.isMentioned }) : callbackModel,
33759
+ loading: data.loading,
33760
+ error: data.error,
33761
+ });
33762
+ };
33763
+ const realtimeRouter = (userUnread) => {
33764
+ if (isEqual(model, userUnread))
33765
+ return;
33766
+ dispatcher({
33767
+ loading: false,
33768
+ data: userUnread,
33769
+ });
33770
+ };
33771
+ const onFetch = () => {
33772
+ const query = createQuery(async () => getTotalChannelsUnread$1());
33773
+ runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
33774
+ if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
33775
+ dispatcher({
33776
+ data,
33777
+ origin,
33778
+ loading: false,
33779
+ error: new ASCApiError(UNSYNCED_OBJECT_CACHED_AT_MESSAGE, 800800 /* Amity.ClientError.DISALOOW_UNSYNCED_OBJECT */, "error" /* Amity.ErrorLevel.ERROR */),
33780
+ });
33781
+ isUnsyncedModel = true;
33782
+ disposers.forEach(fn => fn());
33783
+ }
33784
+ else if (!isUnsyncedModel) {
33785
+ dispatcher({ loading, data, origin, error });
33786
+ }
33787
+ if (error) {
33788
+ disposers.forEach(fn => fn());
33789
+ }
33790
+ });
33791
+ };
33792
+ disposers.push(onChannelUnreadUpdatedLocal(realtimeRouter));
33793
+ onFetch();
33794
+ return () => {
33795
+ disposers.forEach(fn => fn());
33796
+ };
33797
+ };
33798
+
33679
33799
  /* begin_public_function
33680
33800
  id: channel.member.add
33681
33801
  */
@@ -34279,6 +34399,7 @@ var index$c = /*#__PURE__*/Object.freeze({
34279
34399
  onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
34280
34400
  getChannel: getChannel,
34281
34401
  getChannels: getChannels,
34402
+ getTotalChannelsUnread: getTotalChannelsUnread,
34282
34403
  MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
34283
34404
  isUnreadCountSupport: isUnreadCountSupport,
34284
34405
  convertFromRaw: convertFromRaw,