-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathChatWrapper.tsx
More file actions
40 lines (35 loc) · 1.01 KB
/
ChatWrapper.tsx
File metadata and controls
40 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React, { PropsWithChildren } from 'react';
import {
Chat,
OverlayProvider,
SqliteClient,
Streami18n,
useCreateChatClient,
} from 'stream-chat-expo';
import { AuthProgressLoader } from './AuthProgressLoader';
import { STREAM_API_KEY, user, userToken } from '../constants';
import { useStreamChatTheme } from '../useStreamChatTheme';
const streami18n = new Streami18n({
language: 'en',
});
SqliteClient.logger = (level, message, extraData) => {
// console.log(level, `SqliteClient: ${message}`, extraData);
};
export const ChatWrapper = ({ children }: PropsWithChildren<{}>) => {
const chatClient = useCreateChatClient({
apiKey: STREAM_API_KEY,
userData: user,
tokenOrProvider: userToken,
});
const theme = useStreamChatTheme();
if (!chatClient) {
return <AuthProgressLoader />;
}
return (
<OverlayProvider i18nInstance={streami18n} value={{ style: theme }}>
<Chat client={chatClient} i18nInstance={streami18n}>
{children}
</Chat>
</OverlayProvider>
);
};