stream-chat 9.14.0 → 9.16.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.
@@ -42,6 +42,7 @@ export declare class MiddlewareExecutor<TValue, THandlers extends string> {
42
42
  unique?: boolean;
43
43
  }): this;
44
44
  setOrder(order: string[]): void;
45
+ remove(middlewareIds: string | string[]): void;
45
46
  protected executeMiddlewareChain({ eventName, initialValue, mode, }: ExecuteParams<TValue>): Promise<MiddlewareExecutionResult<TValue>>;
46
47
  execute({ eventName, initialValue: initialState, mode, }: ExecuteParams<TValue>): Promise<MiddlewareExecutionResult<TValue>>;
47
48
  }
@@ -47,7 +47,7 @@ export declare class Poll {
47
47
  createOption: (option: PollOptionData) => Promise<import("./types").APIResponse & import("./types").CreatePollOptionAPIResponse>;
48
48
  updateOption: (option: PollOptionData) => Promise<import("./types").APIResponse & import("./types").CreatePollOptionAPIResponse>;
49
49
  deleteOption: (optionId: string) => Promise<import("./types").APIResponse>;
50
- castVote: (optionId: string, messageId: string) => Promise<import("./types").APIResponse & import("./types").CastVoteAPIResponse>;
50
+ castVote: (optionId: string, messageId: string) => Promise<(import("./types").APIResponse & import("./types").CastVoteAPIResponse) | undefined>;
51
51
  removeVote: (voteId: string, messageId: string) => Promise<import("./types").APIResponse & {
52
52
  vote: PollVote;
53
53
  }>;
@@ -236,6 +236,7 @@ export type ChannelResponse = CustomChannelData & {
236
236
  last_message_at?: string;
237
237
  member_count?: number;
238
238
  members?: ChannelMemberResponse[];
239
+ message_count?: number;
239
240
  muted?: boolean;
240
241
  mute_expires_at?: string;
241
242
  own_capabilities?: string[];
@@ -1837,6 +1838,7 @@ export type ChannelConfigFields = {
1837
1838
  replies?: boolean;
1838
1839
  search?: boolean;
1839
1840
  shared_locations?: boolean;
1841
+ count_messages?: boolean;
1840
1842
  typing_events?: boolean;
1841
1843
  uploads?: boolean;
1842
1844
  url_enrichment?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.14.0",
3
+ "version": "9.16.0",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
package/src/middleware.ts CHANGED
@@ -110,6 +110,15 @@ export class MiddlewareExecutor<TValue, THandlers extends string> {
110
110
  .filter(Boolean) as Middleware<TValue, THandlers>[];
111
111
  }
112
112
 
113
+ remove(middlewareIds: string | string[]) {
114
+ if (!middlewareIds && !middlewareIds.length) return;
115
+ this.middleware = this.middleware.filter((md) =>
116
+ typeof middlewareIds === 'string'
117
+ ? middlewareIds !== md.id
118
+ : !middlewareIds.includes(md.id),
119
+ );
120
+ }
121
+
113
122
  protected async executeMiddlewareChain({
114
123
  eventName,
115
124
  initialValue,
package/src/poll.ts CHANGED
@@ -324,20 +324,17 @@ export class Poll {
324
324
  max_votes_allowed && max_votes_allowed === Object.keys(ownVotesByOptionId).length;
325
325
 
326
326
  if (reachedVoteLimit) {
327
- let oldestVote = Object.values(ownVotesByOptionId)[0];
328
- Object.values(ownVotesByOptionId)
329
- .slice(1)
330
- .forEach((vote) => {
331
- if (
332
- !oldestVote?.created_at ||
333
- new Date(vote.created_at) < new Date(oldestVote.created_at)
334
- ) {
335
- oldestVote = vote;
336
- }
337
- });
338
- if (oldestVote?.id) {
339
- await this.removeVote(oldestVote.id, messageId);
340
- }
327
+ this.client.notifications.addInfo({
328
+ message: 'Reached the vote limit. Remove an existing vote first.',
329
+ origin: {
330
+ emitter: 'Poll',
331
+ context: { messageId, optionId },
332
+ },
333
+ options: {
334
+ type: 'validation:poll:castVote:limit',
335
+ },
336
+ });
337
+ return;
341
338
  }
342
339
  return await this.client.castPollVote(messageId, this.id as string, {
343
340
  option_id: optionId,
package/src/types.ts CHANGED
@@ -287,6 +287,7 @@ export type ChannelResponse = CustomChannelData & {
287
287
  last_message_at?: string;
288
288
  member_count?: number;
289
289
  members?: ChannelMemberResponse[];
290
+ message_count?: number;
290
291
  muted?: boolean;
291
292
  mute_expires_at?: string;
292
293
  own_capabilities?: string[];
@@ -2365,6 +2366,7 @@ export type ChannelConfigFields = {
2365
2366
  replies?: boolean;
2366
2367
  search?: boolean;
2367
2368
  shared_locations?: boolean;
2369
+ count_messages?: boolean; // Feature flag for message count
2368
2370
  typing_events?: boolean;
2369
2371
  uploads?: boolean;
2370
2372
  url_enrichment?: boolean;