Skip to content

Commit 7fb1a27

Browse files
committed
fix: properly rename indicator fix hook type
1 parent 1f6df55 commit 7fb1a27

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

examples/vite/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChannelFilters, ChannelOptions, ChannelSort } from 'stream-chat';
22
import {
3-
AITypingIndicator,
3+
AIGenerationIndicator,
44
Channel,
55
ChannelAvatar,
66
ChannelHeader,
@@ -90,7 +90,7 @@ const App = () => {
9090
<Window>
9191
<ChannelHeader Avatar={ChannelAvatar} />
9292
<MessageList returnAllReadData />
93-
<AITypingIndicator />
93+
<AIGenerationIndicator />
9494
<MessageInput focus />
9595
</Window>
9696
<Thread virtualized />

src/components/AITypingIndicatorView/AITypingIndicator.tsx renamed to src/components/AITypingIndicatorView/AIGenerationIndicator.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ import { AIStates, useAIState } from './hooks/useAIState';
77
import { useChannelStateContext, useTranslationContext } from '../../context';
88
import type { DefaultStreamChatGenerics } from '../../types/types';
99

10-
export type AITypingIndicatorProps<
10+
export type AIGenerationIndicatorProps<
1111
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
1212
> = {
1313
channel?: Channel<StreamChatGenerics>;
1414
};
1515

16-
export const AITypingIndicator = <
16+
export const AIGenerationIndicator = <
1717
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
1818
>({
1919
channel: channelFromProps,
20-
}: AITypingIndicatorProps<StreamChatGenerics>) => {
20+
}: AIGenerationIndicatorProps<StreamChatGenerics>) => {
2121
const { t } = useTranslationContext();
2222
const { channel: channelFromContext } = useChannelStateContext<StreamChatGenerics>(
23-
'AITypingIndicator',
23+
'AIGenerationIndicator',
2424
);
2525
const channel = channelFromProps || channelFromContext;
2626
const { aiState } = useAIState(channel);

src/components/AITypingIndicatorView/hooks/useAIState.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { useEffect, useState } from 'react';
22

3-
import { Channel, Event } from 'stream-chat';
3+
import { AIState, Channel, Event } from 'stream-chat';
44

55
import type { DefaultStreamChatGenerics } from '../../../types/types';
66

7-
export type AIStateType =
8-
| 'AI_STATE_ERROR'
9-
| 'AI_STATE_EXTERNAL_SOURCES'
10-
| 'AI_STATE_GENERATING'
11-
| 'AI_STATE_IDLE'
12-
| 'AI_STATE_THINKING'
13-
| string;
14-
157
export const AIStates = {
168
Error: 'AI_STATE_ERROR',
179
ExternalSources: 'AI_STATE_EXTERNAL_SOURCES',
@@ -25,7 +17,7 @@ export const useAIState = <
2517
>(
2618
channel?: Channel<StreamChatGenerics>,
2719
) => {
28-
const [aiState, setAiState] = useState<AIStateType>(AIStates.Idle);
20+
const [aiState, setAiState] = useState<AIState>(AIStates.Idle);
2921

3022
useEffect(() => {
3123
if (!channel) {
@@ -36,7 +28,7 @@ export const useAIState = <
3628
'ai_indicator.update',
3729
(event: Event<StreamChatGenerics>) => {
3830
const { cid } = event;
39-
const state = event.ai_state as AIStateType;
31+
const state = event.ai_state as AIState;
4032
if (channel.cid === cid) {
4133
setAiState(state);
4234
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './AITypingIndicator';
1+
export * from './AIGenerationIndicator';
22
export * from './hooks/useAIState';

0 commit comments

Comments
 (0)