diff --git a/examples/SampleApp/useChatClient.ts b/examples/SampleApp/useChatClient.ts deleted file mode 100644 index 6e6fce501e..0000000000 --- a/examples/SampleApp/useChatClient.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { useEffect, useState } from 'react'; -import { StreamChat } from 'stream-chat'; - -import { USER_TOKENS, USERS } from '../ChatUsers'; -import AsyncStore from '../utils/AsyncStore'; - -import type { LoginConfig, StreamChatGenerics } from '../types'; - -export const useChatClient = () => { - const [chatClient, setChatClient] = useState | null>(null); - const [isConnecting, setIsConnecting] = useState(true); - - const loginUser = async (config: LoginConfig) => { - const client = StreamChat.getInstance(config.apiKey, { - timeout: 6000, - }); - - const user = { - id: config.userId, - image: config.userImage, - name: config.userName, - }; - - await client.connectUser(user, config.userToken); - await AsyncStore.setItem('@stream-rn-sampleapp-login-config', config); - - setChatClient(client); - }; - - const switchUser = async (userId?: string) => { - setIsConnecting(true); - - try { - if (userId) { - await loginUser({ - apiKey: 'yjrt5yxw77ev', - userId: USERS[userId].id, - userImage: USERS[userId].image, - userName: USERS[userId].name, - userToken: USER_TOKENS[userId], - }); - } else { - const config = await AsyncStore.getItem( - '@stream-rn-sampleapp-login-config', - null, - ); - - if (config) { - await loginUser(config); - } - } - } catch (e) { - console.warn(e); - } - setIsConnecting(false); - }; - - const logout = async () => { - setChatClient(null); - chatClient?.disconnectUser(); - await AsyncStore.removeItem('@stream-rn-sampleapp-login-config'); - }; - - useEffect(() => { - switchUser(); - }, []); - - return { - chatClient, - isConnecting, - loginUser, - logout, - switchUser, - }; -};