Skip to content

Commit 1294595

Browse files
committed
fix: custom events
1 parent be4f05a commit 1294595

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

package/src/components/AITypingIndicatorView/hooks/useAIState.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ export const useAIState = <
2828
const [aiState, setAiState] = useState<AIStatesEnum>(AIStatesEnum.Idle);
2929

3030
useEffect(() => {
31-
const indicatorChangedListener = channel.on('ai_indicator_changed', (event) => {
32-
const { cid } = event;
33-
const state = event.state as AIStatesEnum;
34-
if (channel.cid === cid) {
35-
setAiState(state);
36-
}
37-
});
31+
const indicatorChangedListener = channel.on(
32+
'ai_indicator_changed',
33+
(event: Event<StreamChatGenerics>) => {
34+
const { cid } = event;
35+
const state = event.state as AIStatesEnum;
36+
if (channel.cid === cid) {
37+
setAiState(state);
38+
}
39+
},
40+
);
3841

3942
const indicatorClearedListener = channel.on('ai_indicator_clear', (event) => {
4043
const { cid } = event;

package/src/types/types.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExtendableGenerics, LiteralStringForUnion } from 'stream-chat';
1+
import type { EventTypes, ExtendableGenerics, LiteralStringForUnion } from 'stream-chat';
22

33
import type { FileStateValue } from '../utils/utils';
44

@@ -84,11 +84,17 @@ interface DefaultChannelType extends UnknownType {
8484
image?: string;
8585
}
8686

87+
interface DefaultEventType extends UnknownType {
88+
[key: string]: unknown;
89+
90+
type: EventTypes | 'ai_indicator_changed' | 'ai_indicator_clear';
91+
}
92+
8793
export interface DefaultStreamChatGenerics extends ExtendableGenerics {
8894
attachmentType: DefaultAttachmentType;
8995
channelType: DefaultChannelType;
9096
commandType: LiteralStringForUnion;
91-
eventType: UnknownType;
97+
eventType: DefaultEventType;
9298
memberType: UnknownType;
9399
messageType: UnknownType;
94100
reactionType: UnknownType;

0 commit comments

Comments
 (0)