@amityco/ts-sdk-react-native 7.5.1-f996b3e.0 → 7.5.2-d68b072.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk-react-native",
3
- "version": "7.5.1-f996b3e.0",
3
+ "version": "7.5.2-d68b072.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",
@@ -238,7 +238,7 @@ declare global {
238
238
 
239
239
  'local.subChannelUnread.updated': Amity.SubChannelUnreadInfo;
240
240
  'local.channelUnreadInfo.updated': Amity.ChannelUnreadInfo;
241
- 'local.channelUnread.updated': Amity.ChannelUnread;
241
+ 'local.channelUnread.updated': Amity.ChannelUnread[];
242
242
 
243
243
  'local.story.created': Amity.StoryPayload;
244
244
  'local.story.updated': Amity.StoryPayload;
@@ -297,7 +297,17 @@ export const getChannel = (
297
297
  ),
298
298
  convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
299
299
  convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
300
- convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
300
+ convertEventPayload(
301
+ (callback: Amity.Listener<Amity.ChannelUnread>) => {
302
+ const processPayload = (payloads: Amity.ChannelUnread[]) => {
303
+ payloads.forEach(callback);
304
+ };
305
+
306
+ return onChannelUnreadUpdatedLocal(processPayload);
307
+ },
308
+ 'channelId',
309
+ 'channel',
310
+ ),
301
311
  ],
302
312
  {
303
313
  forceDispatch: true,
@@ -572,7 +572,16 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
572
572
  action: Amity.ChannelActionType.OnUpdate,
573
573
  },
574
574
  {
575
- fn: convertEventPayload(onChannelUnreadUpdatedLocal, 'channelId', 'channel'),
575
+ fn: convertEventPayload(
576
+ (callback: Amity.Listener<Amity.ChannelUnread>) => {
577
+ const processPayload = (payloads: Amity.ChannelUnread[]) => {
578
+ payloads.forEach(callback);
579
+ };
580
+ return onChannelUnreadUpdatedLocal(processPayload);
581
+ },
582
+ 'channelId',
583
+ 'channel',
584
+ ),
576
585
  action: Amity.ChannelActionType.OnUpdate,
577
586
  },
578
587
  ];
@@ -82,7 +82,9 @@ export const getTotalChannelsUnread = (
82
82
  });
83
83
  };
84
84
 
85
- const realtimeRouter = (userUnread: Amity.UserUnread) => {
85
+ const realtimeRouter = (_: Amity.ChannelUnread[]) => {
86
+ const { data: userUnread } = _getTotalChannelsUnread();
87
+
86
88
  if (isEqual(model, userUnread)) return;
87
89
 
88
90
  dispatcher({
@@ -7,6 +7,7 @@ import { getActiveClient } from '~/client/api/activeClient';
7
7
  import { pullFromCache } from '~/cache/api/pullFromCache';
8
8
  import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
9
9
  import { pushToCache } from '~/cache/api';
10
+ import { fireEvent } from '~/core/events';
10
11
 
11
12
  export const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
12
13
  export const isUnreadCountSupport = ({ type }: Pick<Amity.RawChannel, 'type'>) =>
@@ -56,6 +57,8 @@ const updateChannelUnread = ({
56
57
  channels: Amity.RawChannel[];
57
58
  channelUsers: Amity.RawMembership<'channel'>[];
58
59
  }) => {
60
+ const channelsUnread: Amity.ChannelUnread[] = [];
61
+
59
62
  for (let i = 0; i < channels.length; i += 1) {
60
63
  const cacheKey = ['channelUnread', 'get', channels[i].channelId];
61
64
  const channelUser = channelUsers.find(
@@ -84,9 +87,11 @@ const updateChannelUnread = ({
84
87
  isMentioned,
85
88
  isDeleted: channels[i].isDeleted || false,
86
89
  };
87
-
88
90
  pushToCache(cacheKey, cacheChannelUnread);
91
+
92
+ channelsUnread.push(cacheChannelUnread);
89
93
  }
94
+ fireEvent('local.channelUnread.updated', channelsUnread);
90
95
  };
91
96
 
92
97
  export const prepareChannelPayload = async (
@@ -167,7 +167,7 @@ export class MessageReadReceiptSyncEngine {
167
167
  channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
168
168
 
169
169
  pushToCache(cacheKey, channelUnread);
170
- fireEvent('local.channelUnread.updated', channelUnread);
170
+ fireEvent('local.channelUnread.updated', [channelUnread]);
171
171
  }
172
172
 
173
173
  // Step 2: Enqueue the read receipt
@@ -80,7 +80,7 @@ export const onMessageCreatedMqtt = (
80
80
  };
81
81
 
82
82
  pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
83
- fireEvent('local.channelUnread.updated', updatedChannelUnread);
83
+ fireEvent('local.channelUnread.updated', [updatedChannelUnread]);
84
84
  });
85
85
  }
86
86