+This new Singleton pattern allows you to instantiate a unique StreamChat client, i.e create a StreamChat instance and
+retrieve it wherever you need it on your app to perform API calls. After calling it once, any following
getInstance
-
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple StreamChat
-instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
+
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple
+StreamChat instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
+This new Singleton pattern allows you to instantiate a unique StreamChat client, i.e create a StreamChat instance and
+retrieve it wherever you need it on your app to perform API calls. After calling it once, any following
getInstance
-
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple StreamChat
-instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
+
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple
+StreamChat instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
+This new Singleton pattern allows you to instantiate a unique StreamChat client, i.e create a StreamChat instance and
+retrieve it wherever you need it on your app to perform API calls. After calling it once, any following
getInstance
-
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple StreamChat
-instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
+
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple
+StreamChat instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
createNativeStackNavigator
uses the native APIs UINavigationController
on iOS and
Fragment
-
on Android. The OverlayProvider
needs to exist in a view that can render content in front of the chat
-screen. Therefore using a fullScreenModal
with createNativeStackNavigator
, which uses
+
on Android. The OverlayProvider
needs to exist in a view that can render content in front of the
+chat screen. Therefore using a fullScreenModal
with createNativeStackNavigator
, which uses
UIModalPresentationFullScreen
-
on iOS and modal
on Android, to render your chat screen will leave the
- OverlayProvider
-
rendered behind the chat. If you are having issues we suggest you get in touch with support and we can find a
-solution to your specific navigation arrangement.
+ on iOS and modal
on Android, to render your chat screen will leave the OverlayProvider
rendered
+behind the chat. If you are having issues we suggest you get in touch with support and we can find a solution to your
+specific navigation arrangement.
:::
diff --git a/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/client.mdx b/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/client.mdx
index 6fe2d090d5..94c28a434e 100644
--- a/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/client.mdx
+++ b/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/client.mdx
@@ -31,11 +31,11 @@ const client = StreamChat.getInstance('api_key');
**Usage of `StreamChat.getInstance()` available since stream-chat@2.12.0.**
+This new Singleton pattern allows you to instantiate a unique StreamChat client, i.e create a StreamChat instance and
+retrieve it wherever you need it on your app to perform API calls. After calling it once, any following
getInstance
-
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple StreamChat
-instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
+
call will return the initial StreamChat instance. This will prevent you from accidentally creating multiple
+StreamChat instances, opening multiple WebSockets, and driving up your concurrent connections unnecessarily.
createNativeStackNavigator
uses the native APIs UINavigationController
on iOS and
Fragment
-
on Android. The OverlayProvider
needs to exist in a view that can render content in front of the chat
-screen. Therefore using a fullScreenModal
with createNativeStackNavigator
, which uses
+
on Android. The OverlayProvider
needs to exist in a view that can render content in front of the
+chat screen. Therefore using a fullScreenModal
with createNativeStackNavigator
, which uses
UIModalPresentationFullScreen
-
on iOS and modal
on Android, to render your chat screen will leave the
- OverlayProvider
-
rendered behind the chat. If you are having issues we suggest you get in touch with support and we can find a
-solution to your specific navigation arrangement.
+ on iOS and modal
on Android, to render your chat screen will leave the OverlayProvider
rendered
+behind the chat. If you are having issues we suggest you get in touch with support and we can find a solution to your
+specific navigation arrangement.
:::
diff --git a/examples/ExpoMessaging/yarn.lock b/examples/ExpoMessaging/yarn.lock
index 381673668a..75c6c3fc56 100644
--- a/examples/ExpoMessaging/yarn.lock
+++ b/examples/ExpoMessaging/yarn.lock
@@ -7327,10 +7327,10 @@ stream-buffers@2.2.x:
version "0.0.0"
uid ""
-stream-chat-react-native-core@5.29.0:
- version "5.29.0"
- resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.29.0.tgz#b89d5f954c2063316ab6dc254e0b98188f01524d"
- integrity sha512-cm8CQUIHPE+hHxM1hVQ6V3ogUJLpGPRZBvMYbJW7+MBdhUTn4+40EqEbqHTEtHdkLgPUmxaDJsh/gFCtVEGgog==
+stream-chat-react-native-core@5.31.1:
+ version "5.31.1"
+ resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.31.1.tgz#4367276c8316d325e6b062e4efb95d464d4e2eef"
+ integrity sha512-EKHMQ0bWRoyubTxk1IKEbkIzcIY5hxHDpyGU7ObGXLLnhoVBEDranZBQ7dNDdbuM88uKh9mGK5WH4NQSTioKxQ==
dependencies:
"@gorhom/bottom-sheet" "4.4.8"
dayjs "1.10.5"
@@ -7342,27 +7342,12 @@ stream-chat-react-native-core@5.29.0:
path "0.12.7"
react-native-markdown-package "1.8.2"
react-native-url-polyfill "^1.3.0"
- stream-chat "8.17.0"
+ stream-chat "8.31.0"
"stream-chat-react-native-core@link:../../package":
version "0.0.0"
uid ""
-stream-chat@8.17.0:
- version "8.17.0"
- resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.17.0.tgz#01c4aacbcdb5dd734b088e70f40cd42a0bcd0fb7"
- integrity sha512-0cYKSroKGiLilElk8Ol6AKAowWIIpXz3wsY97o+cAqixOwwHdnbuPZ00L2CzAjNB2c94Vl5L48n1K+9iOEpv3w==
- dependencies:
- "@babel/runtime" "^7.16.3"
- "@types/jsonwebtoken" "~9.0.0"
- "@types/ws" "^7.4.0"
- axios "^1.6.0"
- base64-js "^1.5.1"
- form-data "^4.0.0"
- isomorphic-ws "^4.0.1"
- jsonwebtoken "~9.0.0"
- ws "^7.4.4"
-
stream-chat@8.31.0:
version "8.31.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.31.0.tgz#387ed3109ac930e222bf260d98afc37dd1fcb1ac"
diff --git a/examples/SampleApp/yarn.lock b/examples/SampleApp/yarn.lock
index 3bd6a0b2e8..fe74be2c58 100644
--- a/examples/SampleApp/yarn.lock
+++ b/examples/SampleApp/yarn.lock
@@ -6825,10 +6825,10 @@ statuses@~1.5.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
-stream-chat-react-native-core@5.29.0:
- version "5.29.0"
- resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.29.0.tgz#b89d5f954c2063316ab6dc254e0b98188f01524d"
- integrity sha512-cm8CQUIHPE+hHxM1hVQ6V3ogUJLpGPRZBvMYbJW7+MBdhUTn4+40EqEbqHTEtHdkLgPUmxaDJsh/gFCtVEGgog==
+stream-chat-react-native-core@5.31.1:
+ version "5.31.1"
+ resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.31.1.tgz#4367276c8316d325e6b062e4efb95d464d4e2eef"
+ integrity sha512-EKHMQ0bWRoyubTxk1IKEbkIzcIY5hxHDpyGU7ObGXLLnhoVBEDranZBQ7dNDdbuM88uKh9mGK5WH4NQSTioKxQ==
dependencies:
"@gorhom/bottom-sheet" "4.4.8"
dayjs "1.10.5"
@@ -6840,7 +6840,7 @@ stream-chat-react-native-core@5.29.0:
path "0.12.7"
react-native-markdown-package "1.8.2"
react-native-url-polyfill "^1.3.0"
- stream-chat "8.17.0"
+ stream-chat "8.31.0"
"stream-chat-react-native-core@link:../../package":
version "0.0.0"
@@ -6850,21 +6850,6 @@ stream-chat-react-native-core@5.29.0:
version "0.0.0"
uid ""
-stream-chat@8.17.0:
- version "8.17.0"
- resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.17.0.tgz#01c4aacbcdb5dd734b088e70f40cd42a0bcd0fb7"
- integrity sha512-0cYKSroKGiLilElk8Ol6AKAowWIIpXz3wsY97o+cAqixOwwHdnbuPZ00L2CzAjNB2c94Vl5L48n1K+9iOEpv3w==
- dependencies:
- "@babel/runtime" "^7.16.3"
- "@types/jsonwebtoken" "~9.0.0"
- "@types/ws" "^7.4.0"
- axios "^1.6.0"
- base64-js "^1.5.1"
- form-data "^4.0.0"
- isomorphic-ws "^4.0.1"
- jsonwebtoken "~9.0.0"
- ws "^7.4.4"
-
stream-chat@8.31.0:
version "8.31.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.31.0.tgz#387ed3109ac930e222bf260d98afc37dd1fcb1ac"
diff --git a/examples/TypeScriptMessaging/ios/Podfile.lock b/examples/TypeScriptMessaging/ios/Podfile.lock
index b4dbb50a44..0832de1860 100644
--- a/examples/TypeScriptMessaging/ios/Podfile.lock
+++ b/examples/TypeScriptMessaging/ios/Podfile.lock
@@ -955,7 +955,7 @@ PODS:
- React-Core
- react-native-image-resizer (1.4.5):
- React-Core
- - react-native-netinfo (11.3.0):
+ - react-native-netinfo (11.3.2):
- React-Core
- react-native-quick-sqlite (8.0.2):
- React
@@ -1476,7 +1476,7 @@ SPEC CHECKSUMS:
react-native-document-picker: 2b8f18667caee73a96708a82b284a4f40b30a156
react-native-flipper: 9c1957af24b76493ba74f46d000a5c1d485e7731
react-native-image-resizer: d9fb629a867335bdc13230ac2a58702bb8c8828f
- react-native-netinfo: 299dad906cdbf3b67bcc6f693c807f98bdd127cc
+ react-native-netinfo: 076df4f9b07f6670acf4ce9a75aac8d34c2e2ccc
react-native-quick-sqlite: 2b225dadc63b670f027111e58f6f169773f6d755
react-native-safe-area-context: b97eb6f9e3b7f437806c2ce5983f479f8eb5de4b
react-native-video: d440605e68cf173e70f0b25112455e3d86890663
@@ -1517,4 +1517,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 90406e1e85c82b37484f5d746afa45c0637bb4b3
-COCOAPODS: 1.15.2
+COCOAPODS: 1.14.3
diff --git a/examples/TypeScriptMessaging/package.json b/examples/TypeScriptMessaging/package.json
index 20646e82c9..b0491d46cd 100644
--- a/examples/TypeScriptMessaging/package.json
+++ b/examples/TypeScriptMessaging/package.json
@@ -15,13 +15,13 @@
"@react-native-camera-roll/camera-roll": "^5.3.1",
"@react-native-clipboard/clipboard": "^1.10.0",
"@react-native-community/masked-view": "0.1.11",
- "@react-native-community/netinfo": "^11.0.1",
+ "@react-native-community/netinfo": "^11.3.2",
"@react-navigation/native": "^6.0.8",
"@react-navigation/stack": "^6.2.0",
"@stream-io/flat-list-mvcp": "0.10.3",
"react": "18.2.0",
- "react-native-audio-recorder-player": "3.6.6",
"react-native": "^0.73.6",
+ "react-native-audio-recorder-player": "3.6.6",
"react-native-document-picker": "^9.0.1",
"react-native-fs": "^2.18.0",
"react-native-gesture-handler": "^2.14.0",
diff --git a/examples/TypeScriptMessaging/yarn.lock b/examples/TypeScriptMessaging/yarn.lock
index 870402704a..09426993a1 100644
--- a/examples/TypeScriptMessaging/yarn.lock
+++ b/examples/TypeScriptMessaging/yarn.lock
@@ -2057,10 +2057,10 @@
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.11.tgz#2f4c6e10bee0786abff4604e39a37ded6f3980ce"
integrity sha512-rQfMIGSR/1r/SyN87+VD8xHHzDYeHaJq6elOSCAD+0iLagXkSI2pfA0LmSXP21uw5i3em7GkkRjfJ8wpqWXZNw==
-"@react-native-community/netinfo@^11.0.1":
- version "11.3.0"
- resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-11.3.0.tgz#9d99ba00138b38350a794eab5eca436f6e209114"
- integrity sha512-mR9iqUi0GzuC8ut+goI/lLkgG+a2OViI1mjSdXHKZnkfdJVjHblyWX3xoA8GE4GH8X4r0X/PNM3Vvyf2FH9mVg==
+"@react-native-community/netinfo@^11.3.2":
+ version "11.3.2"
+ resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-11.3.2.tgz#e63201d0b87ad42d086d1003be48ae7b327f0594"
+ integrity sha512-YsaS3Dutnzqd1BEoeC+DEcuNJedYRkN6Ef3kftT5Sm8ExnCF94C/nl4laNxuvFli3+Jz8Df3jO25Jn8A9S0h4w==
"@react-native/assets-registry@0.73.1":
version "0.73.1"
@@ -6882,10 +6882,10 @@ statuses@~1.5.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
-stream-chat-react-native-core@5.29.0:
- version "5.29.0"
- resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.29.0.tgz#b89d5f954c2063316ab6dc254e0b98188f01524d"
- integrity sha512-cm8CQUIHPE+hHxM1hVQ6V3ogUJLpGPRZBvMYbJW7+MBdhUTn4+40EqEbqHTEtHdkLgPUmxaDJsh/gFCtVEGgog==
+stream-chat-react-native-core@5.31.1:
+ version "5.31.1"
+ resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.31.1.tgz#4367276c8316d325e6b062e4efb95d464d4e2eef"
+ integrity sha512-EKHMQ0bWRoyubTxk1IKEbkIzcIY5hxHDpyGU7ObGXLLnhoVBEDranZBQ7dNDdbuM88uKh9mGK5WH4NQSTioKxQ==
dependencies:
"@gorhom/bottom-sheet" "4.4.8"
dayjs "1.10.5"
@@ -6897,7 +6897,7 @@ stream-chat-react-native-core@5.29.0:
path "0.12.7"
react-native-markdown-package "1.8.2"
react-native-url-polyfill "^1.3.0"
- stream-chat "8.17.0"
+ stream-chat "8.31.0"
"stream-chat-react-native-core@link:../../package":
version "0.0.0"
@@ -6912,21 +6912,6 @@ stream-chat-react-native-devtools@^1.1.0:
version "0.0.0"
uid ""
-stream-chat@8.17.0:
- version "8.17.0"
- resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.17.0.tgz#01c4aacbcdb5dd734b088e70f40cd42a0bcd0fb7"
- integrity sha512-0cYKSroKGiLilElk8Ol6AKAowWIIpXz3wsY97o+cAqixOwwHdnbuPZ00L2CzAjNB2c94Vl5L48n1K+9iOEpv3w==
- dependencies:
- "@babel/runtime" "^7.16.3"
- "@types/jsonwebtoken" "~9.0.0"
- "@types/ws" "^7.4.0"
- axios "^1.6.0"
- base64-js "^1.5.1"
- form-data "^4.0.0"
- isomorphic-ws "^4.0.1"
- jsonwebtoken "~9.0.0"
- ws "^7.4.4"
-
stream-chat@8.31.0:
version "8.31.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.31.0.tgz#387ed3109ac930e222bf260d98afc37dd1fcb1ac"
diff --git a/package/expo-package/package.json b/package/expo-package/package.json
index f5fab442ab..022fee1522 100644
--- a/package/expo-package/package.json
+++ b/package/expo-package/package.json
@@ -13,16 +13,16 @@
"stream-chat-react-native-core": "5.31.1"
},
"peerDependencies": {
- "@react-native-community/netinfo": ">=6.0.0",
"expo": ">=44.0.0",
+ "expo-av": "*",
+ "expo-clipboard": "*",
"expo-document-picker": "*",
"expo-file-system": "*",
"expo-haptics": "*",
"expo-image-manipulator": "*",
"expo-image-picker": ">=14.1.0",
"expo-media-library": "*",
- "expo-sharing": "*",
- "expo-av": "*"
+ "expo-sharing": "*"
},
"peerDependenciesMeta": {
"expo-av": {
@@ -42,7 +42,6 @@
}
},
"devDependencies": {
- "@react-native-community/netinfo": "^6.0.0",
"expo": "^44.0.0",
"expo-file-system": "^11.0.2",
"expo-image-manipulator": "^9.1.0",
diff --git a/package/expo-package/src/handlers/NetInfo.ts b/package/expo-package/src/handlers/NetInfo.ts
deleted file mode 100644
index b53cd68484..0000000000
--- a/package/expo-package/src/handlers/NetInfo.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { NetInfoState, default as OriginalNetInfo } from '@react-native-community/netinfo';
-
-export const NetInfo = {
- addEventListener(listener) {
- let unsubscribe;
- // For NetInfo >= 3.x.x
- if (OriginalNetInfo.fetch && typeof OriginalNetInfo.fetch === 'function') {
- unsubscribe = OriginalNetInfo.addEventListener(({ isConnected, isInternetReachable }) => {
- // Initialize with truthy value when internetReachable is still loading
- // if it resolves to false, listener is triggered with false value and network
- // status is updated
- listener(isInternetReachable === null ? isConnected : isConnected && isInternetReachable);
- });
- return unsubscribe;
- } else {
- // For NetInfo < 3.x.x
- unsubscribe = OriginalNetInfo.addEventListener('connectionChange', () => {
- // @ts-ignore
- OriginalNetInfo.isConnected.fetch().then((isConnected: NetInfoState) => {
- listener(isConnected);
- });
- });
-
- return unsubscribe.remove;
- }
- },
- fetch() {
- return new Promise((resolve, reject) => {
- // For NetInfo >= 3.x.x
- if (OriginalNetInfo.fetch && typeof OriginalNetInfo.fetch === 'function') {
- OriginalNetInfo.fetch().then(({ isConnected }) => {
- resolve(isConnected);
- }, reject);
- } else {
- // For NetInfo < 3.x.x
- // @ts-ignore
- OriginalNetInfo.isConnected.fetch().then((isConnected: NetInfoState) => {
- resolve(isConnected);
- }, reject);
- }
- });
- },
-};
diff --git a/package/expo-package/src/handlers/index.ts b/package/expo-package/src/handlers/index.ts
index 2518c330db..4627bff5b1 100644
--- a/package/expo-package/src/handlers/index.ts
+++ b/package/expo-package/src/handlers/index.ts
@@ -4,7 +4,6 @@ export * from './deleteFile';
export * from './getLocalAssetUri';
export * from './getPhotos';
export * from './iOS14RefreshGallerySelection';
-export * from './NetInfo';
export * from './oniOS14GalleryLibrarySelectionChange';
export * from './saveFile';
export * from './Sound';
diff --git a/package/expo-package/src/index.js b/package/expo-package/src/index.js
index 818c0a53a6..e2b430f2fa 100644
--- a/package/expo-package/src/index.js
+++ b/package/expo-package/src/index.js
@@ -9,7 +9,6 @@ import {
getLocalAssetUri,
getPhotos,
iOS14RefreshGallerySelection,
- NetInfo,
oniOS14GalleryLibrarySelectionChange,
saveFile,
Sound,
@@ -32,7 +31,6 @@ registerNativeHandlers({
getLocalAssetUri,
getPhotos,
iOS14RefreshGallerySelection,
- NetInfo,
oniOS14GalleryLibrarySelectionChange,
pickDocument,
saveFile,
diff --git a/package/expo-package/yarn.lock b/package/expo-package/yarn.lock
index c97a2c0be3..df4a8940f7 100644
--- a/package/expo-package/yarn.lock
+++ b/package/expo-package/yarn.lock
@@ -2929,10 +2929,10 @@ stream-buffers@2.2.x:
resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4"
integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==
-stream-chat-react-native-core@5.31.0:
- version "5.31.0"
- resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.31.0.tgz#8bbcd7310891bf70fc8c0ff345224be9d29cd59e"
- integrity sha512-gPhY5Ly+n8tfa/awu1hV9+Aj+1c35lUpo+UZLgcmgPey2F7kC8YZr1pvon6m7IWTh/MoU5IEnqtswqF+NWQdBQ==
+stream-chat-react-native-core@5.31.1:
+ version "5.31.1"
+ resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.31.1.tgz#4367276c8316d325e6b062e4efb95d464d4e2eef"
+ integrity sha512-EKHMQ0bWRoyubTxk1IKEbkIzcIY5hxHDpyGU7ObGXLLnhoVBEDranZBQ7dNDdbuM88uKh9mGK5WH4NQSTioKxQ==
dependencies:
"@gorhom/bottom-sheet" "4.4.8"
dayjs "1.10.5"
diff --git a/package/jest-setup.js b/package/jest-setup.js
index 2bf6b4c61e..24f953492a 100644
--- a/package/jest-setup.js
+++ b/package/jest-setup.js
@@ -9,11 +9,6 @@ import { registerNativeHandlers } from './src/native';
console.warn = () => {};
-export let netInfoFetch = jest.fn();
-
-export const setNetInfoFetchMock = (fn) => {
- netInfoFetch = fn;
-};
registerNativeHandlers({
Audio: {
startPlayer: jest.fn(),
@@ -24,14 +19,6 @@ registerNativeHandlers({
FlatList,
getLocalAssetUri: () => null,
getPhotos: () => null,
- NetInfo: {
- addEventListener: () => () => null,
- fetch: () =>
- new Promise((resolve) => {
- resolve(true);
- netInfoFetch();
- }),
- },
oniOS14GalleryLibrarySelectionChange: () => ({
unsubscribe: () => {},
}),
diff --git a/package/native-package/package.json b/package/native-package/package.json
index aaef683eec..e1405d28c8 100644
--- a/package/native-package/package.json
+++ b/package/native-package/package.json
@@ -15,7 +15,6 @@
},
"peerDependencies": {
"@react-native-camera-roll/camera-roll": ">=5.0.0",
- "@react-native-community/netinfo": ">=2.0.7",
"@react-native-clipboard/clipboard": "^1.11.1",
"@stream-io/flat-list-mvcp": "^0.10.3",
"react-native": ">=0.60.0",
@@ -54,7 +53,6 @@
},
"devDependencies": {
"@react-native-camera-roll/camera-roll": "^5.0.2",
- "@react-native-community/netinfo": ">=2.0.7",
"@stream-io/flat-list-mvcp": "0.10.3",
"react-native": ">=0.60.0",
"react-native-fs": ">=2.16.6",
diff --git a/package/native-package/src/handlers/NetInfo.ts b/package/native-package/src/handlers/NetInfo.ts
deleted file mode 100644
index b53cd68484..0000000000
--- a/package/native-package/src/handlers/NetInfo.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { NetInfoState, default as OriginalNetInfo } from '@react-native-community/netinfo';
-
-export const NetInfo = {
- addEventListener(listener) {
- let unsubscribe;
- // For NetInfo >= 3.x.x
- if (OriginalNetInfo.fetch && typeof OriginalNetInfo.fetch === 'function') {
- unsubscribe = OriginalNetInfo.addEventListener(({ isConnected, isInternetReachable }) => {
- // Initialize with truthy value when internetReachable is still loading
- // if it resolves to false, listener is triggered with false value and network
- // status is updated
- listener(isInternetReachable === null ? isConnected : isConnected && isInternetReachable);
- });
- return unsubscribe;
- } else {
- // For NetInfo < 3.x.x
- unsubscribe = OriginalNetInfo.addEventListener('connectionChange', () => {
- // @ts-ignore
- OriginalNetInfo.isConnected.fetch().then((isConnected: NetInfoState) => {
- listener(isConnected);
- });
- });
-
- return unsubscribe.remove;
- }
- },
- fetch() {
- return new Promise((resolve, reject) => {
- // For NetInfo >= 3.x.x
- if (OriginalNetInfo.fetch && typeof OriginalNetInfo.fetch === 'function') {
- OriginalNetInfo.fetch().then(({ isConnected }) => {
- resolve(isConnected);
- }, reject);
- } else {
- // For NetInfo < 3.x.x
- // @ts-ignore
- OriginalNetInfo.isConnected.fetch().then((isConnected: NetInfoState) => {
- resolve(isConnected);
- }, reject);
- }
- });
- },
-};
diff --git a/package/native-package/src/handlers/index.ts b/package/native-package/src/handlers/index.ts
index 9c0e249db7..ed6bb32e07 100644
--- a/package/native-package/src/handlers/index.ts
+++ b/package/native-package/src/handlers/index.ts
@@ -2,7 +2,6 @@ export * from './deleteFile';
export * from './compressImage';
export * from './getLocalAssetUri';
export * from './getPhotos';
-export * from './NetInfo';
export * from './saveFile';
export * from './takePhoto';
export * from './Sound';
diff --git a/package/native-package/src/index.js b/package/native-package/src/index.js
index 1c10124c3e..1125401a8e 100644
--- a/package/native-package/src/index.js
+++ b/package/native-package/src/index.js
@@ -9,7 +9,6 @@ import {
getLocalAssetUri,
getPhotos,
iOS14RefreshGallerySelection,
- NetInfo,
oniOS14GalleryLibrarySelectionChange,
saveFile,
Sound,
@@ -33,7 +32,6 @@ registerNativeHandlers({
getLocalAssetUri,
getPhotos,
iOS14RefreshGallerySelection,
- NetInfo,
oniOS14GalleryLibrarySelectionChange,
pickDocument,
saveFile,
diff --git a/package/native-package/yarn.lock b/package/native-package/yarn.lock
index fe5042e0c8..44c186a628 100644
--- a/package/native-package/yarn.lock
+++ b/package/native-package/yarn.lock
@@ -4237,10 +4237,10 @@ statuses@~1.5.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
-stream-chat-react-native-core@5.31.0:
- version "5.31.0"
- resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.31.0.tgz#8bbcd7310891bf70fc8c0ff345224be9d29cd59e"
- integrity sha512-gPhY5Ly+n8tfa/awu1hV9+Aj+1c35lUpo+UZLgcmgPey2F7kC8YZr1pvon6m7IWTh/MoU5IEnqtswqF+NWQdBQ==
+stream-chat-react-native-core@5.31.1:
+ version "5.31.1"
+ resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.31.1.tgz#4367276c8316d325e6b062e4efb95d464d4e2eef"
+ integrity sha512-EKHMQ0bWRoyubTxk1IKEbkIzcIY5hxHDpyGU7ObGXLLnhoVBEDranZBQ7dNDdbuM88uKh9mGK5WH4NQSTioKxQ==
dependencies:
"@gorhom/bottom-sheet" "4.4.8"
dayjs "1.10.5"
diff --git a/package/package.json b/package/package.json
index be811213a9..3df11414e7 100644
--- a/package/package.json
+++ b/package/package.json
@@ -81,6 +81,7 @@
"stream-chat": "8.31.0"
},
"peerDependencies": {
+ "@react-native-community/netinfo": ">=11.3.1",
"react-native-quick-sqlite": ">=5.1.0",
"react-native-svg": ">=15.1.0"
},
@@ -102,7 +103,7 @@
"@babel/runtime": "^7.20.0",
"@react-native-community/eslint-config": "2.0.0",
"@react-native-community/eslint-plugin": "1.1.0",
- "@react-native-community/netinfo": "6.0.0",
+ "@react-native-community/netinfo": "^11.3.2",
"@react-native/babel-preset": "0.73.21",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "12.4.5",
diff --git a/package/src/components/Chat/__tests__/Chat.test.js b/package/src/components/Chat/__tests__/Chat.test.js
index 2df56e57f4..a251974c10 100644
--- a/package/src/components/Chat/__tests__/Chat.test.js
+++ b/package/src/components/Chat/__tests__/Chat.test.js
@@ -1,9 +1,10 @@
import React from 'react';
import { View } from 'react-native';
+import NetInfo from '@react-native-community/netinfo';
+
import { act, cleanup, render, waitFor } from '@testing-library/react-native';
-import { setNetInfoFetchMock } from '../../../../jest-setup';
import { useChatContext } from '../../../contexts/chatContext/ChatContext';
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
@@ -24,6 +25,9 @@ const TranslationContextConsumer = ({ fn }) => {
};
describe('Chat', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
afterEach(cleanup);
const chatClient = getTestClient();
@@ -39,8 +43,6 @@ describe('Chat', () => {
it('listens and updates state on a connection changed event', async () => {
let context;
- const netInfoFetch = jest.fn();
- setNetInfoFetchMock(netInfoFetch);
render(
https://unsplash.com/photos/lxuB4abGzXc
\n', + html: 'https://unsplash.com/photos/lxuB4abGzXc
\n', id: 'thierry-e298f569-8745-407f-a02b-f75c0206612f', own_reactions: [ { @@ -120,8 +118,7 @@ export const message = { user: { created_at: '2019-01-22T16:35:18.417456Z', id: 'thierry', - image: - 'https://cdn.pixabay.com/photo/2014/03/25/16/54/user-297566__340.png', + image: 'https://cdn.pixabay.com/photo/2014/03/25/16/54/user-297566__340.png', last_active: '2019-01-25T09:23:47.108127-07:00', online: true, role: 'user', @@ -148,17 +145,13 @@ export const messageWithImages = { type: 'image', }, { - image_url: - 'https://www.fujixpassion.com/wp-content/uploads/2016/01/Image-1-Title.jpg', - thumb_url: - 'https://www.fujixpassion.com/wp-content/uploads/2016/01/Image-1-Title.jpg', + image_url: 'https://www.fujixpassion.com/wp-content/uploads/2016/01/Image-1-Title.jpg', + thumb_url: 'https://www.fujixpassion.com/wp-content/uploads/2016/01/Image-1-Title.jpg', type: 'image', }, { - image_url: - 'https://i-cdn.phonearena.com/images/articles/47012-image/photo2.jpg', - thumb_url: - 'https://i-cdn.phonearena.com/images/articles/47012-image/photo2.jpg', + image_url: 'https://i-cdn.phonearena.com/images/articles/47012-image/photo2.jpg', + thumb_url: 'https://i-cdn.phonearena.com/images/articles/47012-image/photo2.jpg', type: 'image', }, ], @@ -238,14 +231,12 @@ export const messageWithImages = { user: { created_at: '2019-01-22T16:35:18.417456Z', id: 'thierry', - image: - 'https://cdn.pixabay.com/photo/2014/03/25/16/54/user-297566__340.png', + image: 'https://cdn.pixabay.com/photo/2014/03/25/16/54/user-297566__340.png', last_active: '2019-01-25T09:23:47.108127-07:00', online: true, role: 'user', updated_at: '2019-01-25T16:23:47.052538Z', }, - }; export const messageWithUrlPreview = { @@ -256,8 +247,7 @@ export const messageWithUrlPreview = { image_url: 'https://images.unsplash.com/photo-1548256434-c7d2374b1077?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9', og_scrape_url: 'https://unsplash.com/photos/lxuB4abGzXc', - text: - 'Download this photo in Addu City, Maldives by Ibrahim Shabil (@shabilphotos)', + text: 'Download this photo in Addu City, Maldives by Ibrahim Shabil (@shabilphotos)', thumb_url: 'https://images.unsplash.com/photo-1548256434-c7d2374b1077?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9', title: 'Cosmic Home photo by Ibrahim Shabil (@shabilphotos) on Unsplash', @@ -267,8 +257,7 @@ export const messageWithUrlPreview = { ], command: '', created_at: '2019-01-25T00:18:59.675Z', - html: - 'https://unsplash.com/photos/lxuB4abGzXc
\n', + html: 'https://unsplash.com/photos/lxuB4abGzXc
\n', id: 'thierry-e298f569-8745-407f-a02b-f75c0206612f', own_reactions: [ { @@ -342,8 +331,7 @@ export const messageWithUrlPreview = { user: { created_at: '2019-01-22T16:35:18.417456Z', id: 'thierry', - image: - 'https://cdn.pixabay.com/photo/2014/03/25/16/54/user-297566__340.png', + image: 'https://cdn.pixabay.com/photo/2014/03/25/16/54/user-297566__340.png', last_active: '2019-01-25T09:23:47.108127-07:00', online: true, role: 'user', @@ -370,8 +358,7 @@ export const thread = { ], command: '', created_at: '2019-01-25T21:25:45.306Z', - html: - 'this place looks amazing: https://unsplash.com/photos/f3hDGOHptrM
\n', + html: 'this place looks amazing: https://unsplash.com/photos/f3hDGOHptrM
\n', id: 'thierry-ec4eac2b-1278-4f49-8b20-2ebcd76dace5', own_reactions: [], reaction_counts: null, @@ -388,7 +375,6 @@ export const thread = { role: 'user', updated_at: '2019-01-25T21:27:39.606466Z', }, - }; export const threadMessages = [ @@ -527,7 +513,7 @@ export const MessageMock = { // Based on: https://javascript.info/promise-basics#example-loadscript function dynamicallyLoadScript(url) { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { const script = document.createElement('script'); script.src = url; script.onload = resolve; diff --git a/package/src/index.ts b/package/src/index.ts index 2a302bc343..5f202e0d09 100644 --- a/package/src/index.ts +++ b/package/src/index.ts @@ -1,6 +1,6 @@ export * from './components'; export * from './hooks'; -export { registerNativeHandlers, NetInfo, iOS14RefreshGallerySelection } from './native'; +export { registerNativeHandlers, iOS14RefreshGallerySelection } from './native'; export * from './contexts'; export * from './emoji-data'; diff --git a/package/src/native.ts b/package/src/native.ts index 44ee874048..75af715eee 100644 --- a/package/src/native.ts +++ b/package/src/native.ts @@ -1,8 +1,6 @@ import type React from 'react'; import { FlatList as DefaultFlatList, StyleProp, ViewStyle } from 'react-native'; -import type { NetInfoSubscription } from '@react-native-community/netinfo'; - import type { Asset, File } from './types/types'; const fail = () => { @@ -46,18 +44,8 @@ type GetPhotos = ({ after, first }: { first: number; after?: string }) => | never; export let getPhotos: GetPhotos = fail; -type NetInfo = { - addEventListener: (listener: (isConnected: boolean) => void) => NetInfoSubscription | never; - fetch: (requestedInterface?: string | undefined) => Promise