stream-chat 9.14.0 → 9.15.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/dist/cjs/index.browser.cjs +16 -8
- package/dist/cjs/index.browser.cjs.map +2 -2
- package/dist/cjs/index.node.cjs +16 -8
- package/dist/cjs/index.node.cjs.map +2 -2
- package/dist/esm/index.js +16 -8
- package/dist/esm/index.js.map +2 -2
- package/dist/types/middleware.d.ts +1 -0
- package/dist/types/poll.d.ts +1 -1
- package/package.json +1 -1
- package/src/middleware.ts +9 -0
- package/src/poll.ts +11 -14
|
@@ -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
|
}
|
package/dist/types/poll.d.ts
CHANGED
|
@@ -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
|
}>;
|
package/package.json
CHANGED
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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,
|