stream-chat 8.28.0 → 8.29.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/src/types.ts CHANGED
@@ -297,6 +297,7 @@ export type QueryReactionsOptions = Pager;
297
297
 
298
298
  export type QueryReactionsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
299
299
  reactions: ReactionResponse<StreamChatGenerics>[];
300
+ next?: string;
300
301
  };
301
302
 
302
303
  export type QueryChannelsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
@@ -627,7 +628,6 @@ export type MessageResponse<
627
628
  export type MessageResponseBase<
628
629
  StreamChatGenerics extends ExtendableGenerics = DefaultGenerics
629
630
  > = MessageBase<StreamChatGenerics> & {
630
- reaction_groups: Record<string, ReactionGroupResponse>;
631
631
  type: MessageLabel;
632
632
  args?: string;
633
633
  before_message_send_failed?: boolean;
@@ -651,6 +651,7 @@ export type MessageResponseBase<
651
651
  pinned_by?: UserResponse<StreamChatGenerics> | null;
652
652
  poll?: PollResponse<StreamChatGenerics>;
653
653
  reaction_counts?: { [key: string]: number } | null;
654
+ reaction_groups?: { [key: string]: ReactionGroupResponse } | null;
654
655
  reaction_scores?: { [key: string]: number } | null;
655
656
  reply_count?: number;
656
657
  shadowed?: boolean;
@@ -1381,11 +1382,7 @@ export type ReactionFilters<StreamChatGenerics extends ExtendableGenerics = Defa
1381
1382
  created_at?:
1382
1383
  | RequireOnlyOne<Pick<QueryFilter<PollResponse['created_at']>, '$eq' | '$gt' | '$lt' | '$gte' | '$lte'>>
1383
1384
  | PrimitiveFilter<PollResponse['created_at']>;
1384
- } & {
1385
- [Key in keyof Omit<ReactionResponse<StreamChatGenerics>, 'user_id' | 'type' | 'created_at'>]: RequireOnlyOne<
1386
- QueryFilter<ReactionResponse<StreamChatGenerics>[Key]>
1387
- >;
1388
- }
1385
+ }
1389
1386
  >;
1390
1387
 
1391
1388
  export type ChannelFilters<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = QueryFilters<
package/src/utils.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  UserResponse,
9
9
  MessageResponse,
10
10
  FormatMessageResponse,
11
+ ReactionGroupResponse,
11
12
  } from './types';
12
13
  import { AxiosRequestConfig } from 'axios';
13
14
 
@@ -295,6 +296,11 @@ export function formatMessage<StreamChatGenerics extends ExtendableGenerics = De
295
296
  created_at: message.created_at ? new Date(message.created_at) : new Date(),
296
297
  updated_at: message.updated_at ? new Date(message.updated_at) : new Date(),
297
298
  status: message.status || 'received',
299
+ reaction_groups: maybeGetReactionGroupsFallback(
300
+ message.reaction_groups,
301
+ message.reaction_counts,
302
+ message.reaction_scores,
303
+ ),
298
304
  };
299
305
  }
300
306
 
@@ -364,3 +370,28 @@ export function addToMessageList<StreamChatGenerics extends ExtendableGenerics =
364
370
  }
365
371
  return [...messageArr];
366
372
  }
373
+
374
+ function maybeGetReactionGroupsFallback(
375
+ groups: { [key: string]: ReactionGroupResponse } | null | undefined,
376
+ counts: { [key: string]: number } | null | undefined,
377
+ scores: { [key: string]: number } | null | undefined,
378
+ ): { [key: string]: ReactionGroupResponse } | null {
379
+ if (groups) {
380
+ return groups;
381
+ }
382
+
383
+ if (counts && scores) {
384
+ const fallback: { [key: string]: ReactionGroupResponse } = {};
385
+
386
+ for (const type of Object.keys(counts)) {
387
+ fallback[type] = {
388
+ count: counts[type],
389
+ sum_scores: scores[type],
390
+ };
391
+ }
392
+
393
+ return fallback;
394
+ }
395
+
396
+ return null;
397
+ }