stream-chat 9.18.1 → 9.19.1

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.
@@ -1038,6 +1038,7 @@ export declare class StreamChat {
1038
1038
  language: import("./types").TranslationLanguages;
1039
1039
  };
1040
1040
  latest_reactions?: ReactionResponse[];
1041
+ member?: import("./types").ChannelMemberResponse;
1041
1042
  mentioned_users?: UserResponse[];
1042
1043
  message_text_updated_at?: string;
1043
1044
  moderation?: import("./types").ModerationResponse;
@@ -1703,6 +1704,7 @@ export declare class StreamChat {
1703
1704
  language: import("./types").TranslationLanguages;
1704
1705
  };
1705
1706
  latest_reactions?: ReactionResponse[];
1707
+ member?: import("./types").ChannelMemberResponse;
1706
1708
  mentioned_users?: UserResponse[];
1707
1709
  message_text_updated_at?: string;
1708
1710
  moderation?: import("./types").ModerationResponse;
@@ -59,8 +59,8 @@ export declare class MessageComposer extends WithSubscriptions {
59
59
  constructor({ composition, config, compositionContext, client, }: MessageComposerOptions);
60
60
  static evaluateContextType(compositionContext: CompositionContext): "message" | "channel" | "thread" | "legacy_thread";
61
61
  static constructTag(compositionContext: CompositionContext): `${ReturnType<typeof MessageComposer.evaluateContextType>}_${string}`;
62
+ static generateId: typeof generateUUIDv4;
62
63
  get config(): MessageComposerConfig;
63
- updateConfig(config: DeepPartial<MessageComposerConfig>): void;
64
64
  get contextType(): "message" | "channel" | "thread" | "legacy_thread";
65
65
  get tag(): `message_${string}` | `channel_${string}` | `thread_${string}` | `legacy_thread_${string}`;
66
66
  get threadId(): string | null;
@@ -74,7 +74,7 @@ export declare class MessageComposer extends WithSubscriptions {
74
74
  get hasSendableData(): boolean;
75
75
  get compositionIsEmpty(): boolean;
76
76
  get lastChangeOriginIsLocal(): boolean;
77
- static generateId: typeof generateUUIDv4;
77
+ updateConfig(config: DeepPartial<MessageComposerConfig>): void;
78
78
  refreshId: () => void;
79
79
  initState: ({ composition, }?: {
80
80
  composition?: DraftResponse | MessageResponse | LocalMessage;
@@ -579,6 +579,7 @@ export type MessageResponseBase = MessageBase & {
579
579
  language: TranslationLanguages;
580
580
  };
581
581
  latest_reactions?: ReactionResponse[];
582
+ member?: ChannelMemberResponse;
582
583
  mentioned_users?: UserResponse[];
583
584
  message_text_updated_at?: string;
584
585
  moderation?: ModerationResponse;
@@ -114,6 +114,7 @@ export declare const toDeletedMessage: ({ message, deletedAt, hardDelete, }: {
114
114
  language: import("./types").TranslationLanguages;
115
115
  }) | undefined;
116
116
  latest_reactions?: import("./types").ReactionResponse[] | undefined;
117
+ member?: import("./types").ChannelMemberResponse | undefined;
117
118
  mentioned_users?: UserResponse[] | undefined;
118
119
  message_text_updated_at?: string | undefined;
119
120
  moderation?: import("./types").ModerationResponse | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.18.1",
3
+ "version": "9.19.1",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
package/src/channel.ts CHANGED
@@ -1492,6 +1492,13 @@ export class Channel {
1492
1492
 
1493
1493
  this.getClient()._addChannelConfig(state.channel);
1494
1494
 
1495
+ // the only config param that is necessary to be updated based on server config soon as the config is delivered
1496
+ if (typeof state.channel.config?.shared_locations !== 'undefined') {
1497
+ this.messageComposer.updateConfig({
1498
+ location: { enabled: state.channel.config.shared_locations },
1499
+ });
1500
+ }
1501
+
1495
1502
  // add any messages to our channel state
1496
1503
  const { messageSet } = this._initializeState(state, messageSetToAddToIfDoesNotExist);
1497
1504
  messageSet.pagination = {
@@ -2106,13 +2113,21 @@ export class Channel {
2106
2113
  }
2107
2114
  break;
2108
2115
  case 'channel.hidden':
2109
- channel.data = { ...channel.data, hidden: true };
2116
+ channel.data = {
2117
+ ...channel.data,
2118
+ blocked: !!event.channel?.blocked,
2119
+ hidden: true,
2120
+ };
2110
2121
  if (event.clear_history) {
2111
2122
  channelState.clearMessages();
2112
2123
  }
2113
2124
  break;
2114
2125
  case 'channel.visible':
2115
- channel.data = { ...channel.data, hidden: false };
2126
+ channel.data = {
2127
+ ...channel.data,
2128
+ blocked: !!event.channel?.blocked,
2129
+ hidden: false,
2130
+ };
2116
2131
  this.getClient().offlineDb?.handleChannelVisibilityEvent({ event });
2117
2132
  break;
2118
2133
  case 'user.banned':
@@ -235,14 +235,12 @@ export class MessageComposer extends WithSubscriptions {
235
235
  return `${this.evaluateContextType(compositionContext)}_${compositionContext.id}`;
236
236
  }
237
237
 
238
+ static generateId = generateUUIDv4;
239
+
238
240
  get config(): MessageComposerConfig {
239
241
  return this.configState.getLatestValue();
240
242
  }
241
243
 
242
- updateConfig(config: DeepPartial<MessageComposerConfig>) {
243
- this.configState.partialNext(mergeWith(this.config, config));
244
- }
245
-
246
244
  get contextType() {
247
245
  return MessageComposer.evaluateContextType(this.compositionContext);
248
246
  }
@@ -346,7 +344,9 @@ export class MessageComposer extends WithSubscriptions {
346
344
  return editedMessageWasUpdated || draftWasChanged || composingMessageFromScratch;
347
345
  }
348
346
 
349
- static generateId = generateUUIDv4;
347
+ updateConfig(config: DeepPartial<MessageComposerConfig>) {
348
+ this.configState.partialNext(mergeWith(this.config, config));
349
+ }
350
350
 
351
351
  refreshId = () => {
352
352
  this.state.partialNext({ id: MessageComposer.generateId() });
@@ -212,16 +212,13 @@ export class TextComposer {
212
212
  text,
213
213
  currentText.slice(finalSelection.end),
214
214
  ].join('');
215
+
215
216
  const finalText = textBeforeTrim.slice(
216
217
  0,
217
218
  typeof maxLengthOnEdit === 'number' ? maxLengthOnEdit : textBeforeTrim.length,
218
219
  );
219
- const expectedCursorPosition =
220
- currentText.slice(0, finalSelection.start).length + text.length;
221
- const cursorPosition =
222
- expectedCursorPosition >= finalText.length
223
- ? finalText.length
224
- : currentText.slice(0, expectedCursorPosition).length;
220
+ const expectedCursorPosition = finalSelection.start + text.length;
221
+ const cursorPosition = Math.min(expectedCursorPosition, finalText.length);
225
222
 
226
223
  await this.handleChange({
227
224
  text: finalText,
@@ -180,7 +180,7 @@ abstract class BaseSearchSourceBase<T> implements ISearchSource<T> {
180
180
  const { items, next } = result;
181
181
 
182
182
  const stateUpdate: Partial<SearchSourceState<T>> = {};
183
- if (next || next === null) {
183
+ if (Object.prototype.hasOwnProperty.call(result, 'next')) {
184
184
  stateUpdate.next = next;
185
185
  stateUpdate.hasNext = !!next;
186
186
  } else {
package/src/types.ts CHANGED
@@ -693,6 +693,7 @@ export type MessageResponseBase = MessageBase & {
693
693
  language: TranslationLanguages;
694
694
  };
695
695
  latest_reactions?: ReactionResponse[];
696
+ member?: ChannelMemberResponse;
696
697
  mentioned_users?: UserResponse[];
697
698
  message_text_updated_at?: string;
698
699
  moderation?: ModerationResponse; // present only with Moderation v2