Skip to content

Commit

Permalink
Register ThreadManager subscriptions within Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Aug 13, 2024
1 parent 56039ae commit 5a3942f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/components/Chat/hooks/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ export const useChat = <
};

useEffect(() => {
if (client) {
const userAgent = client.getUserAgent();
if (!userAgent.includes('stream-chat-react')) {
// result looks like: 'stream-chat-react-2.3.2-stream-chat-javascript-client-browser-2.2.2'
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
}
if (!client) return;

const userAgent = client.getUserAgent();
if (!userAgent.includes('stream-chat-react')) {
// result looks like: 'stream-chat-react-2.3.2-stream-chat-javascript-client-browser-2.2.2'
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
}

client.threads.registerSubscriptions();

return () => {
client.threads.deregisterSubscriptions();
};
}, [client]);

useEffect(() => {
Expand Down

0 comments on commit 5a3942f

Please sign in to comment.