Skip to content

Commit

Permalink
refactor: move isMessageAIGenerated to global scope in vite App
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Feb 4, 2025
1 parent 30746c0 commit ed3f7da
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions examples/vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useCallback } from 'react';
import { ChannelFilters, ChannelOptions, ChannelSort } from 'stream-chat';
import {
AIStateIndicator,
Expand All @@ -9,11 +8,11 @@ import {
Chat,
ChatView,
MessageInput,
VirtualizedMessageList as MessageList,
StreamMessage,
Thread,
ThreadList,
useCreateChatClient,
VirtualizedMessageList as MessageList,
Window,
} from 'stream-chat-react';

Expand Down Expand Up @@ -65,18 +64,16 @@ type StreamChatGenerics = {
userType: LocalUserType;
};

const isMessageAIGenerated = (message: StreamMessage<StreamChatGenerics>) =>
!!message?.ai_generated;

const App = () => {
const chatClient = useCreateChatClient<StreamChatGenerics>({
apiKey,
tokenOrProvider: userToken,
userData: { id: userId },
});

const isMessageAIGenerated = useCallback(
(message: StreamMessage<StreamChatGenerics>) => !!message?.ai_generated,
[],
);

if (!chatClient) return <>Loading...</>;

return (
Expand Down

0 comments on commit ed3f7da

Please sign in to comment.