@@ -8,46 +8,47 @@ React Native Chat SDK provides OOTB support for offline mode, which means user w
88with chat even when the network is off. This is an opt-in feature that needs to be explicitely enabled on application
99level.
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).
12+
1213
1314## Features
15+ The offline storage implementation currently offers the following features:
16+ - Access to chat when Internet connection is disabled or low.
17+ - Faster startup times and loading, since initial data is loaded from offline storage before performing any network requests.
18+ - Syncing of the offline database using WebSocket events and Sync API.
19+
20+ The following features are currently ** NOT** implemented. They will be implemented gradually as part of minor releases in v5.
1421
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
22+ - Optimistically update offline database during chat interactions, such as send message, add reaction, etc.
23+ - Access to threads in offline mode.
24+ - Offline caching of attachment images and profile images.
2025
2126## How To Enable Offline Support
27+ First and foremost make sure to follow all steps from [ Migrating to v5] ( ./upgrade_helper.mdx ) guide.
28+ To enable offline support, please follow the given steps:
2229
23- - ** Upgrade stream-chat dependency (optional)**
30+ 1 . ** Upgrade stream-chat dependency (optional)**
2431
25- If you have installed ` stream-chat ` dependency explicitely on your application, then upgrade it to v7
32+ If you have installed ` stream-chat ` dependency explicitly on your application, then upgrade it to v7:
2633
2734 ``` bash
28352936 ```
3037
31- - ** Add ` react-native-quick-sqlite ` dependency**
38+ 2 . ** Add ` react-native-quick-sqlite ` dependency**
3239
3340 ``` bash
34- yarn add react-native-quick-sqlite
35- npx pod-install
41+ yarn add react-native-quick-sqlite
42+ npx pod-install
3643 ```
3744
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+ 3 . ** Do not wait for ` connectUser ` call to succeed**
4346
44- - ** Do not wait for ` connectUser ` call to succeed**
47+ It is important that you call the ` connectUser ` method on the chat client, before you render Chat components.
48+ But you don't need to wait for ` connectUser ` to succeed before rendering Chat components. This is to ensure:
4549
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:
48-
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.
50+ - Chat components have access to current user information, which is important to store/access offline data.
51+ - In case of slow or no network access, Chat components will still load the chat data without waiting for ` connectUser ` to succeed.
5152
5253 ``` tsx {7,8,16}
5354 const chatClient = StreamChat .getInstance (' API_KEY' );
@@ -75,23 +76,23 @@ level.
7576 };
7677 ```
7778
78- - ** Add ` enableOfflineSupport ` prop on Chat component**
79+ 4 . ** Add ` enableOfflineSupport ` prop on Chat component**
7980
8081 ``` tsx
81- import { Chat } from ' stream-chat-react-native' ;
82+ import { Chat } from ' stream-chat-react-native' ;
8283
83- <Chat client = { chatClient } enableOfflineSupport >
84- ...
85- </Chat >;
84+ <Chat client = { chatClient } enableOfflineSupport >
85+ ...
86+ </Chat >;
8687 ```
8788
88- - ** Reset the database when signing out the user**
89+ -5. ** Reset the database when signing out the user**
8990
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() `
91+ Since the SDK doesn't handle app- level authentication logic, it's the application's responsibility
92+ to ensure the database is reset when a user gets logged out. This should generally be done before you
93+ call ` client.disconnectUser() ` .
9394
94- ``` jsx
95+ ``` tsx
9596 import { QuickSqliteClient } from ' stream-chat-react-native' ;
9697
9798 // Sign out logic
0 commit comments