aboutsummaryrefslogtreecommitdiff
path: root/src/App.tsx
blob: d0276dd2cc24170eb5f06214462c61696e617573 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {NavigationContainer} from '@react-navigation/native';
import React, {useState} from 'react';
import {Provider} from 'react-redux';
import {Channel as ChannelType, StreamChat} from 'stream-chat';
import {OverlayProvider} from 'stream-chat-react-native';
import {navigationRef} from './RootNavigation';
import Routes from './routes';
import store from './store/configureStore';
import {
  ChatContextType,
  LocalAttachmentType,
  LocalChannelType,
  LocalCommandType,
  LocalEventType,
  LocalMessageType,
  LocalResponseType,
  LocalUserType,
} from './types';

export const ChatContext = React.createContext({} as ChatContextType);

const App = () => {
  const [channel, setChannel] = useState<
    ChannelType<
      LocalAttachmentType,
      LocalChannelType,
      LocalCommandType,
      LocalEventType,
      LocalMessageType,
      LocalResponseType,
      LocalUserType
    >
  >();
  // TODO: (CHAT) change me
  const chatClient = StreamChat.getInstance<
    LocalAttachmentType,
    LocalChannelType,
    LocalCommandType,
    LocalEventType,
    LocalMessageType,
    LocalResponseType,
    LocalUserType
  >('t823wwqn2wuk');
  return (
    /**
     * This is the provider from the redux store, it acts as the root provider for our application
     */
    <Provider store={store}>
      <NavigationContainer ref={navigationRef}>
        <ChatContext.Provider value={{channel, setChannel, chatClient}}>
          <OverlayProvider>
            <Routes />
          </OverlayProvider>
        </ChatContext.Provider>
      </NavigationContainer>
    </Provider>
  );
};

export default App;