Skip to content

Commit 528afe5

Browse files
committed
docs: eliminates duplication regarding how to enable offline support
1 parent fc69634 commit 528afe5

File tree

3 files changed

+78
-162
lines changed

3 files changed

+78
-162
lines changed

docusaurus/docs/reactnative/basics/offline_support.mdx

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,49 @@ React Native Chat SDK provides OOTB support for offline mode, which means user w
88
with chat even when the network is off. This is an opt-in feature that needs to be explicitely enabled on application
99
level.
1010

11-
> Offline support is currently not supported for Expo package (stream-chat-expo).
11+
> Offline support is currently not implemented for Expo package (stream-chat-expo).
1212
1313
## Features
1414

15-
- ✅ Access to channel list and message list without network
16-
- ✅ Faster loading of chat since chat gets loaded from offline storage first before loading data from network
17-
- ✅ Syncing the local database using websocket events and sync api (once network is recovered)
18-
- ❌ Caching of image attachments
19-
- ❌ Optimistic updates to database on user action in offline mode e.g., send message, add reaction etc
15+
The offline storage implementation currently offers the following features:
16+
17+
- Access to chat when Internet connection is disabled or low.
18+
- Faster startup times and loading, since initial data is loaded from offline storage before performing any network requests.
19+
- Syncing of the offline database using WebSocket events and Sync API.
20+
21+
The following features are currently **NOT** implemented. They will be implemented gradually as part of minor releases in v5.
22+
23+
- Optimistically update offline database during chat interactions, such as send message, add reaction, etc.
24+
- Access to threads in offline mode.
25+
- Offline caching of attachment images and profile images.
2026

2127
## How To Enable Offline Support
2228

23-
- **Upgrade stream-chat dependency (optional)**
29+
First and foremost make sure to follow all steps from [Migrating to v5](./upgrade_helper.mdx) guide.
30+
To enable offline support, please follow the given steps:
2431

25-
If you have installed `stream-chat` dependency explicitely on your application, then upgrade it to v7
32+
1. **Upgrade stream-chat dependency (optional)**
2633

27-
```bash
28-
29-
```
34+
If you have installed `stream-chat` dependency explicitly on your application, then upgrade it to v7:
35+
36+
```bash
37+
38+
```
3039

31-
- **Add `react-native-quick-sqlite` dependency**
40+
2. **Add `react-native-quick-sqlite` dependency**
3241

33-
```bash
42+
```bash
3443
yarn add react-native-quick-sqlite
3544
npx pod-install
36-
```
37-
38-
- **Ensure unique instance of Chat component**
39-
40-
Until v4, you could provide separate `Chat` component for each usage of `Channel` component or `ChannelList` component.
41-
But from v5, it is necessary that you provide only one instance of `Chat` component within your application.
42-
This component needs to be a parent for all the chat related components such as `ChannelList`, `Channel` or `Thread`.
45+
```
4346

44-
- **Do not wait for `connectUser` call to succeed**
47+
3. **Do not wait for `connectUser` call to succeed**
4548

46-
It is important that you call `connectUser` method on chat client, before you render Chat components.
47-
But you don't need to wait for `connectUser` to succeed before rendering Chat components. This is to ensure:
49+
It is important that you call the `connectUser` method on the chat client, before you render Chat components.
50+
But you don't need to wait for `connectUser` to succeed before rendering Chat components. This is to ensure:
4851

49-
- Chat components have access to current user information, which is important to store/access offline data.
50-
- In case or slow or no network, Chat components will still load the chat data without waiting for connectUser to succeed.
52+
- Chat components have access to current user information, which is important to store/access offline data.
53+
- In case of slow or no network access, Chat components will still load the chat data without waiting for `connectUser` to succeed.
5154

5255
```tsx {7,8,16}
5356
const chatClient = StreamChat.getInstance('API_KEY');
@@ -75,26 +78,26 @@ level.
7578
};
7679
```
7780

78-
- **Add `enableOfflineSupport` prop on Chat component**
81+
4. **Add `enableOfflineSupport` prop on Chat component**
7982

80-
```tsx
81-
import { Chat } from 'stream-chat-react-native';
83+
```tsx
84+
import { Chat } from 'stream-chat-react-native';
8285

83-
<Chat client={chatClient} enableOfflineSupport>
84-
...
85-
</Chat>;
86-
```
86+
<Chat client={chatClient} enableOfflineSupport>
87+
...
88+
</Chat>;
89+
```
8790

88-
- **Reset the database when signing out the user**
91+
-5. **Reset the database when signing out the user**
8992

90-
Since SDK doesn't handle the app level authentication logic, its application's responsibility
91-
to ensure resetting database when user gets logged out. This should be generally done before you
92-
call `client.disconnectUser()`
93+
Since the SDK doesn't handle app-level authentication logic, it's the application's responsibility
94+
to ensure the database is reset when a user gets logged out. This should generally be done before you
95+
call `client.disconnectUser()`.
9396

94-
```jsx
95-
import { QuickSqliteClient } from 'stream-chat-react-native';
97+
```tsx
98+
import { QuickSqliteClient } from 'stream-chat-react-native';
9699

97-
// Sign out logic
98-
QuickSqliteClient.resetDB();
99-
chatClient.disconnectUser();
100-
```
100+
// Sign out logic
101+
QuickSqliteClient.resetDB();
102+
chatClient.disconnectUser();
103+
```

docusaurus/docs/reactnative/basics/upgrade_helper.mdx

Lines changed: 3 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -34,100 +34,10 @@ The following values in [`ImageGalleryContext`](https://getstream.io/chat/docs/s
3434

3535
## Unique Chat Component Instance
3636

37-
Until v4, you could provide a separate `Chat` component for each usage of `Channel` component or `ChannelList` component.
38-
But from v5, you must provide only one instance of the `Chat` component within your application.
39-
This component needs to be a parent for all the chat-related components such as `ChannelList`, `Channel` or `Thread`.
37+
Until v4, you could provide a separate `Chat` component for each usage of `Channel` component or `ChannelList` component.
38+
But from v5, you must provide only one instance of the `Chat` component within your application.
39+
This component needs to be a parent for all the chat-related components such as `ChannelList`, `Channel` or `Thread`.
4040

4141
## Enable Offline Support
4242

43-
Offline support is a major opt-in feature introduced in v5 of the Stream Chat React Native SDK.
44-
45-
> Offline support is currently not implemented for Expo package (stream-chat-expo).
46-
47-
The offline storage implementation currently offers the following features:
48-
49-
- Access to chat when Internet connection is disabled or low.
50-
- Faster startup times and loading, since initial data is loaded from offline storage before performing any network requests.
51-
- Syncing of the offline database using WebSocket events and Sync API.
52-
53-
The following features are currently **NOT** implemented. They will be implemented gradually as part of minor releases in v5.
54-
55-
- Optimistically update offline database during chat interactions, such as send message, add reaction, etc.
56-
- Access to threads in offline mode.
57-
- Offline caching of attachment images and profile images.
58-
59-
To enable offline support, please follow the given steps:
60-
61-
1. **Upgrade stream-chat dependency (optional)**
62-
63-
If you have installed `stream-chat` dependency explicitly on your application, then upgrade it to v7:
64-
65-
```bash
66-
67-
```
68-
69-
2. **Add `react-native-quick-sqlite` dependency**
70-
71-
```bash
72-
yarn add react-native-quick-sqlite
73-
npx pod-install
74-
```
75-
76-
3. **Do not wait for `connectUser` call to succeed**
77-
78-
It is important that you call the `connectUser` method on the chat client, before you render Chat components.
79-
But you don't need to wait for `connectUser` to succeed before rendering Chat components. This is to ensure:
80-
81-
- Chat components have access to current user information, which is important to store/access offline data.
82-
- In case of slow or no network access, Chat components will still load the chat data without waiting for `connectUser` to succeed.
83-
84-
```tsx {7,8,16}
85-
const chatClient = StreamChat.getInstance('API_KEY');
86-
const App = () => {
87-
const [isClientReady, setIsClientReady] = useState(false);
88-
89-
useEffect(() => {
90-
const startChat = async () => {
91-
const connectPromise = chatClient.connectUser(user, tokenOrTokenProvider);
92-
setIsClientReady(true); // this allows components to render
93-
await connectPromise();
94-
// Any other post-connectUser logic you may have goes here.
95-
};
96-
97-
startChat();
98-
}, []);
99-
100-
if (!isClientReady) return null; // or some loading indicator;
101-
102-
return (
103-
<Chat client={chatClient} enableOfflineSupport>
104-
...
105-
</Chat>
106-
);
107-
};
108-
```
109-
110-
4. **Add `enableOfflineSupport` prop on Chat component**
111-
112-
```tsx
113-
import { Chat } from 'stream-chat-react-native';
114-
115-
<Chat client={chatClient} enableOfflineSupport>
116-
...
117-
</Chat>;
118-
```
119-
120-
5. **Reset the database when signing out the user**
121-
122-
Since the SDK doesn't handle app-level authentication logic, it's the application's responsibility
123-
to ensure the database is reset when a user gets logged out. This should generally be done before you
124-
call `client.disconnectUser()`.
125-
126-
```jsx
127-
import { QuickSqliteClient } from 'stream-chat-react-native';
128-
129-
// Sign out logic
130-
QuickSqliteClient.resetDB();
131-
chatClient.disconnectUser();
132-
```
13343
To enable offline support please check the [Offline Support](./offline_support.mdx) guide.

docusaurus/docs/reactnative/guides/debug_mode_using_flipper_plugin.mdx

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Flipper is a platform for debugging iOS, Android, and React Native apps. You can
1414
<img src={FlipperBanner} />
1515

1616
## Features
17+
1718
The plugin supports the following features:
19+
1820
- Viewing the authenticated client in the Chat.
1921
- Viewing the Channels, Message, and Thread list data as you navigate the app.
2022
- Copying and visualizing all the data.
@@ -25,47 +27,48 @@ These features are part of the 1st version of this plugin; more features will be
2527

2628
1. First, install the Flipper plugin within your Desktop client. To do so, follow these steps:
2729

28-
- Download the Flipper Desktop app from [here](https://fbflipper.com/).
29-
- After downloading the desktop app, move to the **Plugin Manager** section of the app and select the **Install Plugins** tab.
30-
- Search for **stream-chat-react-native**, and you will find the plugin.
31-
- Click on **Install** to install it.
30+
- Download the Flipper Desktop app from [here](https://fbflipper.com/).
31+
- After downloading the desktop app, move to the **Plugin Manager** section of the app and select the **Install Plugins** tab.
32+
- Search for **stream-chat-react-native**, and you will find the plugin.
33+
- Click on **Install** to install it.
3234

33-
<img src={FlipperDesktopGuide} />
35+
{' '}
36+
<img src={FlipperDesktopGuide} />
3437

3538
2. Next, install `stream-chat-react-native-devtools` to your application as a dev dependency. This dependency will make communication possible between the RN Stream Chat SDK and the Flipper plugin.
3639

37-
```
38-
yarn add --dev stream-chat-react-native-devtools
39-
```
40+
```
41+
yarn add --dev stream-chat-react-native-devtools
42+
```
4043

41-
or
44+
or
4245

43-
```
44-
npm install --save-dev stream-chat-react-native-devtools
45-
```
46+
```
47+
npm install --save-dev stream-chat-react-native-devtools
48+
```
4649

4750
3. To interact with the Flipper Plugin you need an additional dependency `react-native-flipper`. You can install it as a dev dependency, as:
4851

49-
```
50-
yarn add --dev react-native-flipper
51-
```
52+
```
53+
yarn add --dev react-native-flipper
54+
```
5255

53-
or
56+
or
5457

55-
```
56-
npm install --save-dev react-native-flipper
57-
```
58+
```
59+
npm install --save-dev react-native-flipper
60+
```
5861

5962
4. Wrap the root of the component tree with `DebugContextProvider` and pass the `useFlipper` function.
6063

61-
```tsx
62-
import { DebugContextProvider } from 'stream-chat-react-native';
63-
import { useFlipper } from 'stream-chat-react-native-devtools';
64-
...
64+
```tsx
65+
import { DebugContextProvider } from 'stream-chat-react-native';
66+
import { useFlipper } from 'stream-chat-react-native-devtools';
67+
...
6568

66-
<DebugContextProvider useFlipper={useFlipper}>
67-
{/* All other elements of the App component comes here */}
68-
</DebugContextProvider>
69-
```
69+
<DebugContextProvider useFlipper={useFlipper}>
70+
{/* All other elements of the App component comes here */}
71+
</DebugContextProvider>
72+
```
7073

7174
Kudos 🎉, everything else is handled by our SDK, the package [stream-chat-react-native-devtools](https://www.npmjs.com/package/stream-chat-react-native-devtools), and the [Flipper Plugin](https://www.npmjs.com/package/flipper-plugin-stream-chat-react-native).

0 commit comments

Comments
 (0)