Skip to content

Commit 6d5a51b

Browse files
authored
fix: show loading indicator instead of returning null from the Chat component when DB not initialized (#2820)
* fix: show loading indicator instead of returning null from the Chat component when DB not initialized * fix: db initialization logic * Revert "fix: db initialization logic" This reverts commit a0a98c6. * fix: replace default loading indicator to null
1 parent 5765b6a commit 6d5a51b

File tree

6 files changed

+26
-64
lines changed

6 files changed

+26
-64
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/src/components/Chat/Chat.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ export type ChatProps<
100100
* ```
101101
*/
102102
i18nInstance?: Streami18n;
103+
/**
104+
* Custom loading indicator component to be used to represent the loading state of the chat.
105+
*
106+
* This can be used during the phase when db is not initialised.
107+
*/
108+
LoadingIndicator?: React.ComponentType | null;
103109
/**
104110
* 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)
105111
*
@@ -143,6 +149,7 @@ const ChatWithContext = <
143149
enableOfflineSupport = false,
144150
i18nInstance,
145151
ImageComponent = Image,
152+
LoadingIndicator = null,
146153
resizableCDNHosts = ['.stream-io-cdn.com'],
147154
style,
148155
} = props;
@@ -257,7 +264,7 @@ const ChatWithContext = <
257264

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

263270
return (

0 commit comments

Comments
 (0)