Skip to content

Commit b1807ac

Browse files
committed
fix: show loading indicator instead of returning null from the Chat component when DB not initialized
1 parent d995ecd commit b1807ac

File tree

9 files changed

+51
-72
lines changed

9 files changed

+51
-72
lines changed

examples/ExpoMessaging/yarn.lock

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7310,10 +7310,10 @@ [email protected], stream-buffers@~2.2.0:
73107310
version "0.0.0"
73117311
uid ""
73127312

7313-
stream-chat-react-native-core@5.42.2:
7314-
version "5.42.2"
7315-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c"
7316-
integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw==
7313+
stream-chat-react-native-core@5.43.1:
7314+
version "5.43.1"
7315+
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f"
7316+
integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw==
73177317
dependencies:
73187318
"@gorhom/bottom-sheet" "^4.6.4"
73197319
dayjs "1.10.5"
@@ -7326,27 +7326,12 @@ [email protected]:
73267326
path "0.12.7"
73277327
react-native-markdown-package "1.8.2"
73287328
react-native-url-polyfill "^1.3.0"
7329-
stream-chat "8.44.0"
7329+
stream-chat "8.45.1"
73307330

73317331
"stream-chat-react-native-core@link:../../package":
73327332
version "0.0.0"
73337333
uid ""
73347334

7335-
7336-
version "8.44.0"
7337-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0"
7338-
integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA==
7339-
dependencies:
7340-
"@babel/runtime" "^7.16.3"
7341-
"@types/jsonwebtoken" "~9.0.0"
7342-
"@types/ws" "^7.4.0"
7343-
axios "^1.6.0"
7344-
base64-js "^1.5.1"
7345-
form-data "^4.0.0"
7346-
isomorphic-ws "^4.0.1"
7347-
jsonwebtoken "~9.0.0"
7348-
ws "^7.5.10"
7349-
73507335
73517336
version "8.45.1"
73527337
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5"

examples/SampleApp/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ SPEC CHECKSUMS:
15561556
FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d
15571557
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
15581558
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
1559-
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
1559+
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
15601560
GoogleAppMeasurement: f3abf08495ef2cba7829f15318c373b8d9226491
15611561
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
15621562
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15

examples/SampleApp/yarn.lock

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6837,10 +6837,10 @@ statuses@~1.5.0:
68376837
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
68386838
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
68396839

6840-
stream-chat-react-native-core@5.42.2:
6841-
version "5.42.2"
6842-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c"
6843-
integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw==
6840+
stream-chat-react-native-core@5.43.1:
6841+
version "5.43.1"
6842+
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f"
6843+
integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw==
68446844
dependencies:
68456845
"@gorhom/bottom-sheet" "^4.6.4"
68466846
dayjs "1.10.5"
@@ -6853,7 +6853,7 @@ [email protected]:
68536853
path "0.12.7"
68546854
react-native-markdown-package "1.8.2"
68556855
react-native-url-polyfill "^1.3.0"
6856-
stream-chat "8.44.0"
6856+
stream-chat "8.45.1"
68576857

68586858
"stream-chat-react-native-core@link:../../package":
68596859
version "0.0.0"
@@ -6863,21 +6863,6 @@ [email protected]:
68636863
version "0.0.0"
68646864
uid ""
68656865

6866-
6867-
version "8.44.0"
6868-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0"
6869-
integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA==
6870-
dependencies:
6871-
"@babel/runtime" "^7.16.3"
6872-
"@types/jsonwebtoken" "~9.0.0"
6873-
"@types/ws" "^7.4.0"
6874-
axios "^1.6.0"
6875-
base64-js "^1.5.1"
6876-
form-data "^4.0.0"
6877-
isomorphic-ws "^4.0.1"
6878-
jsonwebtoken "~9.0.0"
6879-
ws "^7.5.10"
6880-
68816866
68826867
version "8.45.1"
68836868
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5"

examples/TypeScriptMessaging/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ EXTERNAL SOURCES:
14291429
SPEC CHECKSUMS:
14301430
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
14311431
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
1432-
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
1432+
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
14331433
FBLazyVector: f64d1e2ea739b4d8f7e4740cde18089cd97fe864
14341434
FBReactNativeSpec: 9f2b8b243131565335437dba74923a8d3015e780
14351435
Flipper: c7a0093234c4bdd456e363f2f19b2e4b27652d44
@@ -1441,7 +1441,7 @@ SPEC CHECKSUMS:
14411441
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
14421442
FlipperKit: 37525a5d056ef9b93d1578e04bc3ea1de940094f
14431443
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
1444-
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
1444+
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
14451445
hermes-engine: 9cecf9953a681df7556b8cc9c74905de8f3293c0
14461446
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
14471447
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c

examples/TypeScriptMessaging/yarn.lock

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6899,10 +6899,10 @@ statuses@~1.5.0:
68996899
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
69006900
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
69016901

6902-
stream-chat-react-native-core@5.42.2:
6903-
version "5.42.2"
6904-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c"
6905-
integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw==
6902+
stream-chat-react-native-core@5.43.1:
6903+
version "5.43.1"
6904+
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f"
6905+
integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw==
69066906
dependencies:
69076907
"@gorhom/bottom-sheet" "^4.6.4"
69086908
dayjs "1.10.5"
@@ -6915,7 +6915,7 @@ [email protected]:
69156915
path "0.12.7"
69166916
react-native-markdown-package "1.8.2"
69176917
react-native-url-polyfill "^1.3.0"
6918-
stream-chat "8.44.0"
6918+
stream-chat "8.45.1"
69196919

69206920
"stream-chat-react-native-core@link:../../package":
69216921
version "0.0.0"
@@ -6930,21 +6930,6 @@ stream-chat-react-native-devtools@^1.1.0:
69306930
version "0.0.0"
69316931
uid ""
69326932

6933-
6934-
version "8.44.0"
6935-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0"
6936-
integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA==
6937-
dependencies:
6938-
"@babel/runtime" "^7.16.3"
6939-
"@types/jsonwebtoken" "~9.0.0"
6940-
"@types/ws" "^7.4.0"
6941-
axios "^1.6.0"
6942-
base64-js "^1.5.1"
6943-
form-data "^4.0.0"
6944-
isomorphic-ws "^4.0.1"
6945-
jsonwebtoken "~9.0.0"
6946-
ws "^7.5.10"
6947-
69486933
69496934
version "8.45.1"
69506935
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5"

package/expo-package/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,10 +2929,10 @@ [email protected]:
29292929
resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4"
29302930
integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==
29312931

2932-
2933-
version "5.43.0"
2934-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.0.tgz#d6f4eaeedc6fc35e5902f06cf895e47e95c2255e"
2935-
integrity sha512-Cfgt4ZtP/5yXh6eNzhRVyVtMjzhFdJKFu6injDM4TXClHThdjqv5v9G/s/znpm0QDq2x8vktPEB0evrtyezsNg==
2932+
2933+
version "5.43.1"
2934+
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f"
2935+
integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw==
29362936
dependencies:
29372937
"@gorhom/bottom-sheet" "^4.6.4"
29382938
dayjs "1.10.5"

package/native-package/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4244,10 +4244,10 @@ statuses@~1.5.0:
42444244
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
42454245
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
42464246

4247-
4248-
version "5.43.0"
4249-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.0.tgz#d6f4eaeedc6fc35e5902f06cf895e47e95c2255e"
4250-
integrity sha512-Cfgt4ZtP/5yXh6eNzhRVyVtMjzhFdJKFu6injDM4TXClHThdjqv5v9G/s/znpm0QDq2x8vktPEB0evrtyezsNg==
4247+
4248+
version "5.43.1"
4249+
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f"
4250+
integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw==
42514251
dependencies:
42524252
"@gorhom/bottom-sheet" "^4.6.4"
42534253
dayjs "1.10.5"

package/src/components/Chat/Chat.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Image, Platform } from 'react-native';
33

44
import type { Channel, StreamChat } from 'stream-chat';
55

6+
import { LoadingIndicator as LoadingIndicatorDefault } from './components/LoadingIndicator';
67
import { useAppSettings } from './hooks/useAppSettings';
78
import { useCreateChatContext } from './hooks/useCreateChatContext';
89
import { useIsOnline } from './hooks/useIsOnline';
@@ -100,6 +101,12 @@ export type ChatProps<
100101
* ```
101102
*/
102103
i18nInstance?: Streami18n;
104+
/**
105+
* Custom loading indicator component to be used to represent the loading state of the chat.
106+
*
107+
* This can be used during the phase when db is not initialised.
108+
*/
109+
LoadingIndicator?: React.ComponentType;
103110
/**
104111
* You can pass the theme object to customize the styles of Chat components. You can check the default theme in [theme.ts](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/contexts/themeContext/utils/theme.ts)
105112
*
@@ -143,6 +150,7 @@ const ChatWithContext = <
143150
enableOfflineSupport = false,
144151
i18nInstance,
145152
ImageComponent = Image,
153+
LoadingIndicator = LoadingIndicatorDefault,
146154
resizableCDNHosts = ['.stream-io-cdn.com'],
147155
style,
148156
} = props;
@@ -257,7 +265,7 @@ const ChatWithContext = <
257265

258266
if (userID && enableOfflineSupport && !initialisedDatabase) {
259267
// if user id has been set and offline support is enabled, we need to wait for database to be initialised
260-
return null;
268+
return LoadingIndicator ? <LoadingIndicator /> : null;
261269
}
262270

263271
return (
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import { ActivityIndicator, StyleSheet, View } from 'react-native';
3+
4+
export const LoadingIndicator = () => (
5+
<View style={styles.container}>
6+
<ActivityIndicator size='large' />
7+
</View>
8+
);
9+
10+
const styles = StyleSheet.create({
11+
container: {
12+
alignItems: 'center',
13+
flex: 1,
14+
justifyContent: 'center',
15+
},
16+
});

0 commit comments

Comments
 (0)