stream-chat 8.40.6 → 8.40.8

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.
@@ -69,7 +69,7 @@ export declare class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
69
69
  private subscribeMarkThreadStale;
70
70
  private subscribeNewReplies;
71
71
  private subscribeRepliesRead;
72
- private subscribeReplyDeleted;
72
+ private subscribeMessageDeleted;
73
73
  private subscribeMessageUpdated;
74
74
  unregisterSubscriptions: () => void;
75
75
  deleteReplyLocally: ({ message }: {
@@ -79,7 +79,9 @@ export declare class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
79
79
  message: MessageResponse<SCG>;
80
80
  timestampChanged?: boolean | undefined;
81
81
  }) => void;
82
- updateParentMessageLocally: (message: MessageResponse<SCG>) => void;
82
+ updateParentMessageLocally: ({ message }: {
83
+ message: MessageResponse<SCG>;
84
+ }) => void;
83
85
  updateParentMessageOrReplyLocally: (message: MessageResponse<SCG>) => void;
84
86
  markAsRead: ({ force }?: {
85
87
  force?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/thread.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAEf,cAAc,EACd,YAAY,EACb,MAAM,SAAS,CAAC;AAGjB,aAAK,mBAAmB,CAAC,GAAG,SAAS,kBAAkB,IAAI;IACzD,IAAI,CAAC,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAClC,GAAG,wBAAwB,GAAG;IAAE,IAAI,CAAC,EAAE,YAAY,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mCxC;IAEK,qBAAqB,aAa1B;IAEF,OAAO,CAAC,6BAA6B,CAQnC;IAEF,OAAO,CAAC,gCAAgC,CAQpC;IAEJ,OAAO,CAAC,wBAAwB,CASf;IAEjB,OAAO,CAAC,mBAAmB,CAoDV;IAEjB,OAAO,CAAC,oBAAoB,CAqBX;IAEjB,OAAO,CAAC,uBAAuB,CAkBd;IAEjB,OAAO,CAAC,uBAAuB,CAa7B;IAEK,uBAAuB,aAG5B;IAEK,kBAAkB;iBAA4B,gBAAgB,GAAG,CAAC;eAuBvE;IAEK,kBAAkB;iBAId,gBAAgB,GAAG,CAAC;;eAoB7B;IAEK,0BAA0B;iBAA4B,gBAAgB,GAAG,CAAC;eAe/E;IAEK,iCAAiC,YAAa,gBAAgB,GAAG,CAAC,UAQvE;IAEK,UAAU;;kEAMf;IAEF,OAAO,CAAC,mBAAmB,CAAwF;IAE5G,YAAY,sCAIhB,oBAAoB,GAAG,CAAC,2DAEzB;IAEK,YAAY;;wBAEjB;IAEK,YAAY;;wBAEjB;IAEF,OAAO,CAAC,QAAQ,CAgDd;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "8.40.6",
3
+ "version": "8.40.8",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "author": "GetStream",
6
6
  "homepage": "https://getstream.io/chat/",
package/src/client.ts CHANGED
@@ -1971,8 +1971,8 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
1971
1971
  if (cid in this.activeChannels && !this.activeChannels[cid].disconnected) {
1972
1972
  const channel = this.activeChannels[cid];
1973
1973
  if (Object.keys(custom).length > 0) {
1974
- channel.data = custom;
1975
- channel._data = custom;
1974
+ channel.data = { ...channel.data, ...custom };
1975
+ channel._data = { ...channel._data, ...custom };
1976
1976
  }
1977
1977
  return channel;
1978
1978
  }
package/src/thread.ts CHANGED
@@ -4,6 +4,7 @@ import { StateStore } from './store';
4
4
  import type {
5
5
  AscDesc,
6
6
  DefaultGenerics,
7
+ EventTypes,
7
8
  ExtendableGenerics,
8
9
  FormatMessageResponse,
9
10
  MessagePaginationOptions,
@@ -79,6 +80,12 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
79
80
  });
80
81
  channel._hydrateMembers(threadData.channel.members ?? []);
81
82
 
83
+ // For when read object is undefined and due to that unreadMessageCount for
84
+ // the current user isn't being incremented on message.new
85
+ const placeholderReadResponse: ReadResponse[] = client.userID
86
+ ? [{ user: { id: client.userID }, unread_messages: 0, last_read: new Date().toISOString() }]
87
+ : [];
88
+
82
89
  this.state = new StateStore<ThreadState<SCG>>({
83
90
  active: false,
84
91
  channel,
@@ -89,7 +96,9 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
89
96
  pagination: repliesPaginationFromInitialThread(threadData),
90
97
  parentMessage: formatMessage(threadData.parent_message),
91
98
  participants: threadData.thread_participants,
92
- read: formatReadState(threadData.read ?? []),
99
+ read: formatReadState(
100
+ !threadData.read || threadData.read.length === 0 ? placeholderReadResponse : threadData.read,
101
+ ),
93
102
  replies: threadData.latest_replies.map(formatMessage),
94
103
  replyCount: threadData.reply_count ?? 0,
95
104
  updatedAt: threadData.updated_at ? new Date(threadData.updated_at) : null,
@@ -182,7 +191,7 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
182
191
  this.unsubscribeFunctions.add(this.subscribeMarkThreadStale());
183
192
  this.unsubscribeFunctions.add(this.subscribeNewReplies());
184
193
  this.unsubscribeFunctions.add(this.subscribeRepliesRead());
185
- this.unsubscribeFunctions.add(this.subscribeReplyDeleted());
194
+ this.unsubscribeFunctions.add(this.subscribeMessageDeleted());
186
195
  this.unsubscribeFunctions.add(this.subscribeMessageUpdated());
187
196
  };
188
197
 
@@ -294,20 +303,30 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
294
303
  }));
295
304
  }).unsubscribe;
296
305
 
297
- private subscribeReplyDeleted = () =>
306
+ private subscribeMessageDeleted = () =>
298
307
  this.client.on('message.deleted', (event) => {
299
- if (event.message?.parent_id !== this.id) return;
308
+ if (!event.message) return;
309
+
310
+ // Deleted message is a reply of this thread
311
+ if (event.message.parent_id === this.id) {
312
+ if (event.hard_delete) {
313
+ this.deleteReplyLocally({ message: event.message });
314
+ } else {
315
+ // Handle soft delete (updates deleted_at timestamp)
316
+ this.upsertReplyLocally({ message: event.message });
317
+ }
318
+ }
300
319
 
301
- if (event.hard_delete) {
302
- this.deleteReplyLocally({ message: event.message });
303
- } else {
304
- // Handle soft delete (updates deleted_at timestamp)
305
- this.upsertReplyLocally({ message: event.message });
320
+ // Deleted message is parent message of this thread
321
+ if (event.message.id === this.id) {
322
+ this.updateParentMessageLocally({ message: event.message });
306
323
  }
307
324
  }).unsubscribe;
308
325
 
309
326
  private subscribeMessageUpdated = () => {
310
- const unsubscribeFunctions = ['message.updated', 'reaction.new', 'reaction.deleted'].map(
327
+ const eventTypes: EventTypes[] = ['message.updated', 'reaction.new', 'reaction.deleted', 'reaction.updated'];
328
+
329
+ const unsubscribeFunctions = eventTypes.map(
311
330
  (eventType) =>
312
331
  this.client.on(eventType, (event) => {
313
332
  if (event.message) {
@@ -375,7 +394,7 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
375
394
  }));
376
395
  };
377
396
 
378
- public updateParentMessageLocally = (message: MessageResponse<SCG>) => {
397
+ public updateParentMessageLocally = ({ message }: { message: MessageResponse<SCG> }) => {
379
398
  if (message.id !== this.id) {
380
399
  throw new Error('Message does not belong to this thread');
381
400
  }
@@ -383,19 +402,12 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
383
402
  this.state.next((current) => {
384
403
  const formattedMessage = formatMessage(message);
385
404
 
386
- const newData: typeof current = {
405
+ return {
387
406
  ...current,
388
407
  deletedAt: formattedMessage.deleted_at,
389
408
  parentMessage: formattedMessage,
390
409
  replyCount: message.reply_count ?? current.replyCount,
391
410
  };
392
-
393
- // update channel on channelData change (unlikely but handled anyway)
394
- if (message.channel) {
395
- newData['channel'] = this.client.channel(message.channel.type, message.channel.id, message.channel);
396
- }
397
-
398
- return newData;
399
411
  });
400
412
  };
401
413
 
@@ -405,7 +417,7 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
405
417
  }
406
418
 
407
419
  if (!message.parent_id && message.id === this.id) {
408
- this.updateParentMessageLocally(message);
420
+ this.updateParentMessageLocally({ message });
409
421
  }
410
422
  };
411
423