Skip to content

Commit 8935cf4

Browse files
committed
fix: use type from LLC
1 parent 4891976 commit 8935cf4

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
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 { useChatContext } from '../../../contexts';
66
import type { DefaultStreamChatGenerics } from '../../../types/types';
77
import { useIsOnline } from '../../Chat/hooks/useIsOnline';
88

9-
export type AIStateType =
10-
| 'AI_STATE_ERROR'
11-
| 'AI_STATE_EXTERNAL_SOURCES'
12-
| 'AI_STATE_GENERATING'
13-
| 'AI_STATE_IDLE'
14-
| 'AI_STATE_THINKING'
15-
| string;
16-
179
export const AIStates = {
1810
Error: 'AI_STATE_ERROR',
1911
ExternalSources: 'AI_STATE_EXTERNAL_SOURCES',
@@ -28,7 +20,7 @@ export const useAIState = <
2820
channel?: Channel<StreamChatGenerics>,
2921
) => {
3022
const { client } = useChatContext();
31-
const [aiState, setAiState] = useState<AIStateType>(AIStates.Idle);
23+
const [aiState, setAiState] = useState<AIState>(AIStates.Idle);
3224
const { isOnline } = useIsOnline(client);
3325

3426
useEffect(() => {
@@ -46,7 +38,7 @@ export const useAIState = <
4638
'ai_indicator.update',
4739
(event: Event<StreamChatGenerics>) => {
4840
const { cid } = event;
49-
const state = event.ai_state as AIStateType;
41+
const state = event.ai_state as AIState;
5042
if (channel.cid === cid) {
5143
setAiState(state);
5244
}

0 commit comments

Comments
 (0)