diff --git a/docusaurus/docs/reactnative/basics/client.mdx b/docusaurus/docs/reactnative/basics/client.mdx index 3270c7d674..68bc6254f7 100644 --- a/docusaurus/docs/reactnative/basics/client.mdx +++ b/docusaurus/docs/reactnative/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 +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.

diff --git a/docusaurus/docs/reactnative/customization/native-handlers.mdx b/docusaurus/docs/reactnative/customization/native-handlers.mdx index cb14b253c4..f21a1770dd 100644 --- a/docusaurus/docs/reactnative/customization/native-handlers.mdx +++ b/docusaurus/docs/reactnative/customization/native-handlers.mdx @@ -86,14 +86,6 @@ A function that returns photos from the camera roll given an offset of `after` a | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | | [`@react-native-camera-roll/camera-roll`](https://github.com/react-native-cameraroll/react-native-cameraroll) | [`expo-media-library`](https://docs.expo.io/versions/latest/sdk/media-library/) | -### `NetInfo` - -A object containing two keys, `addEventListener` and `fetch`, which are functions that allow a developer to add listeners to `NetInfo` or fetch information from `NetInfo`. - -| React Native CLI | Expo | -| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) | [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) | - ### `pickDocument` A function to open the document picker and return documents picked from it. diff --git a/docusaurus/docs/reactnative/state-and-offline-support/state-overview.mdx b/docusaurus/docs/reactnative/state-and-offline-support/state-overview.mdx index 0a23f6e12f..f9e49d34c6 100644 --- a/docusaurus/docs/reactnative/state-and-offline-support/state-overview.mdx +++ b/docusaurus/docs/reactnative/state-and-offline-support/state-overview.mdx @@ -30,11 +30,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 +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.

diff --git a/docusaurus/reactnative_versioned_docs/version-3.x.x/basics/client.mdx b/docusaurus/reactnative_versioned_docs/version-3.x.x/basics/client.mdx index 6fe2d090d5..94c28a434e 100644 --- a/docusaurus/reactnative_versioned_docs/version-3.x.x/basics/client.mdx +++ b/docusaurus/reactnative_versioned_docs/version-3.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 +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.

diff --git a/docusaurus/reactnative_versioned_docs/version-3.x.x/basics/stream_chat_with_navigation.mdx b/docusaurus/reactnative_versioned_docs/version-3.x.x/basics/stream_chat_with_navigation.mdx index be395026aa..1ab8a787ae 100644 --- a/docusaurus/reactnative_versioned_docs/version-3.x.x/basics/stream_chat_with_navigation.mdx +++ b/docusaurus/reactnative_versioned_docs/version-3.x.x/basics/stream_chat_with_navigation.mdx @@ -21,13 +21,12 @@ The guidance provided makes the assumption you are using [React Navigation](http 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 +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.

diff --git a/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/stream_chat_with_navigation.mdx b/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/stream_chat_with_navigation.mdx index 5f3c5bf659..0f78f099aa 100644 --- a/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/stream_chat_with_navigation.mdx +++ b/docusaurus/reactnative_versioned_docs/version-4.x.x/basics/stream_chat_with_navigation.mdx @@ -21,13 +21,12 @@ The guidance provided makes the assumption you are using [React Navigation](http 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( @@ -52,7 +54,7 @@ describe('Chat', () => { , ); - await waitFor(() => expect(netInfoFetch).toHaveBeenCalledTimes(1)); + await waitFor(() => expect(NetInfo.fetch).toHaveBeenCalledTimes(1)); const { connectionRecovering } = context; act(() => dispatchConnectionChangedEvent(chatClient, false)); @@ -79,141 +81,145 @@ describe('Chat', () => { await waitFor(() => expect(context.connectionRecovering).toStrictEqual(false)); }); +}); + +describe('ChatContext', () => { + afterEach(cleanup); + const chatClient = getTestClient(); + it('exposes the chat context', async () => { + let context; - describe('ChatContext', () => { - it('exposes the chat context', async () => { - let context; - - render( - - { - context = ctx; - }} - > - , - ); - - await waitFor(() => { - expect(context).toBeInstanceOf(Object); - expect(context.channel).toBeUndefined(); - expect(context.client).toBe(chatClient); - expect(context.connectionRecovering).toBeFalsy(); - expect(context.setActiveChannel).toBeInstanceOf(Function); - }); + render( + + { + context = ctx; + }} + > + , + ); + + await waitFor(() => { + expect(context).toBeInstanceOf(Object); + expect(context.channel).toBeUndefined(); + expect(context.client).toBe(chatClient); + expect(context.connectionRecovering).toBeFalsy(); + expect(context.setActiveChannel).toBeInstanceOf(Function); }); + }); - it('calls setActiveChannel to set a new channel in context', async () => { - let context; + it('calls setActiveChannel to set a new channel in context', async () => { + let context; - render( - - { - context = ctx; - }} - > - , - ); + render( + + { + context = ctx; + }} + > + , + ); - const channel = { cid: 'cid', id: 'cid', query: jest.fn() }; + const channel = { cid: 'cid', id: 'cid', query: jest.fn() }; - await waitFor(() => expect(context.channel).toBeUndefined()); - act(() => context.setActiveChannel(channel)); + await waitFor(() => expect(context.channel).toBeUndefined()); + act(() => context.setActiveChannel(channel)); - await waitFor(() => expect(context.channel).toStrictEqual(channel)); + await waitFor(() => expect(context.channel).toStrictEqual(channel)); + }); +}); + +describe('TranslationContext', () => { + afterEach(cleanup); + const chatClient = getTestClient(); + it('exposes the translation context', async () => { + let context; + + render( + + { + context = ctx; + }} + > + , + ); + + await waitFor(() => { + expect(context).toBeInstanceOf(Object); + expect(context.t).toBeInstanceOf(Function); + expect(context.tDateTimeParser).toBeInstanceOf(Function); }); }); - describe('TranslationContext', () => { - it('exposes the translation context', async () => { - let context; - - render( - - { - context = ctx; - }} - > - , - ); - - await waitFor(() => { - expect(context).toBeInstanceOf(Object); - expect(context.t).toBeInstanceOf(Function); - expect(context.tDateTimeParser).toBeInstanceOf(Function); - }); + it('uses the i18nInstance provided in props', async () => { + let context; + const i18nInstance = new Streami18n(); + const { t, tDateTimeParser } = await i18nInstance.getTranslators(); + + i18nInstance.t = () => 't'; + i18nInstance.tDateTimeParser = () => 'tDateTimeParser'; + + render( + + { + context = ctx; + }} + > + , + ); + + await waitFor(() => { + expect(context.t).not.toBe(t); + expect(context.t).toBe(i18nInstance.t); + expect(context.tDateTimeParser).not.toBe(tDateTimeParser); + expect(context.tDateTimeParser).toBe(i18nInstance.tDateTimeParser); }); + }); - it('uses the i18nInstance provided in props', async () => { - let context; - const i18nInstance = new Streami18n(); - const { t, tDateTimeParser } = await i18nInstance.getTranslators(); - - i18nInstance.t = () => 't'; - i18nInstance.tDateTimeParser = () => 'tDateTimeParser'; - - render( - - { - context = ctx; - }} - > - , - ); - - await waitFor(() => { - expect(context.t).not.toBe(t); - expect(context.t).toBe(i18nInstance.t); - expect(context.tDateTimeParser).not.toBe(tDateTimeParser); - expect(context.tDateTimeParser).toBe(i18nInstance.tDateTimeParser); - }); + it('updates the context when props change', async () => { + let context; + const i18nInstance = new Streami18n(); + + i18nInstance.t = () => 't'; + i18nInstance.tDateTimeParser = () => 'tDateTimeParser'; + + const { rerender } = render( + + { + context = ctx; + }} + > + , + ); + + await waitFor(() => { + expect(context.t).toBe(i18nInstance.t); + expect(context.tDateTimeParser).toBe(i18nInstance.tDateTimeParser); }); - it('updates the context when props change', async () => { - let context; - const i18nInstance = new Streami18n(); - - i18nInstance.t = () => 't'; - i18nInstance.tDateTimeParser = () => 'tDateTimeParser'; - - const { rerender } = render( - - { - context = ctx; - }} - > - , - ); - - await waitFor(() => { - expect(context.t).toBe(i18nInstance.t); - expect(context.tDateTimeParser).toBe(i18nInstance.tDateTimeParser); - }); - - const newI18nInstance = new Streami18n(); - - newI18nInstance.t = () => 'newT'; - newI18nInstance.tDateTimeParser = () => 'newtDateTimeParser'; - - rerender( - - { - context = ctx; - }} - > - , - ); - await waitFor(() => { - expect(context.t).not.toBe(i18nInstance.t); - expect(context.t).toBe(newI18nInstance.t); - expect(context.tDateTimeParser).not.toBe(i18nInstance.tDateTimeParser); - expect(context.tDateTimeParser).toBe(newI18nInstance.tDateTimeParser); - }); + const newI18nInstance = new Streami18n(); + + newI18nInstance.t = () => 'newT'; + newI18nInstance.tDateTimeParser = () => 'newtDateTimeParser'; + + rerender( + + { + context = ctx; + }} + > + , + ); + await waitFor(() => { + expect(context.t).not.toBe(i18nInstance.t); + expect(context.t).toBe(newI18nInstance.t); + expect(context.tDateTimeParser).not.toBe(i18nInstance.tDateTimeParser); + expect(context.tDateTimeParser).toBe(newI18nInstance.tDateTimeParser); }); }); }); diff --git a/package/src/components/Chat/hooks/useIsOnline.ts b/package/src/components/Chat/hooks/useIsOnline.ts index 73954568ed..022b11b2fd 100644 --- a/package/src/components/Chat/hooks/useIsOnline.ts +++ b/package/src/components/Chat/hooks/useIsOnline.ts @@ -1,12 +1,11 @@ import { useCallback, useEffect, useState } from 'react'; -import type { NetInfoSubscription } from '@react-native-community/netinfo'; +import NetInfo, { NetInfoSubscription } from '@react-native-community/netinfo'; import type { StreamChat, Event as StreamEvent } from 'stream-chat'; import { useAppStateListener } from '../../../hooks/useAppStateListener'; import { useIsMountedRef } from '../../../hooks/useIsMountedRef'; -import { NetInfo } from '../../../native'; import type { DefaultStreamChatGenerics } from '../../../types/types'; @@ -56,9 +55,9 @@ export const useIsOnline = < const handleRecoveredEvent = () => setConnectionRecovering(false); - const notifyChatClient = (netInfoState: boolean) => { - if (client?.wsConnection) { - if (netInfoState) { + const notifyChatClient = (isConnected: boolean | null) => { + if (client?.wsConnection && isConnected) { + if (isConnected) { client.wsConnection.onlineStatusChanged({ type: 'online', } as Event); @@ -73,23 +72,27 @@ export const useIsOnline = < let unsubscribeNetInfo: NetInfoSubscription; const setNetInfoListener = () => { unsubscribeNetInfo = NetInfo.addEventListener((netInfoState) => { - if (netInfoState === false && !client.wsConnection?.isHealthy) { + if (!netInfoState && !client.wsConnection?.isHealthy) { setConnectionRecovering(true); setIsOnline(false); } - notifyChatClient(netInfoState); + const { isConnected, isInternetReachable } = netInfoState; + notifyChatClient( + isInternetReachable !== null ? isInternetReachable && isConnected : isConnected, + ); }); }; const setInitialOnlineState = async () => { - const status = await NetInfo.fetch(); + const { isConnected } = await NetInfo.fetch(); if (isMounted.current) { - setIsOnline(status); - notifyChatClient(status); + setIsOnline(isConnected); + notifyChatClient(isConnected); } }; setInitialOnlineState(); + const chatListeners: Array> = []; if (client) { diff --git a/package/src/components/ImageGallery/__tests__/AnimatedVideoGallery.test.tsx b/package/src/components/ImageGallery/__tests__/AnimatedVideoGallery.test.tsx index b28b763869..015d5f6152 100644 --- a/package/src/components/ImageGallery/__tests__/AnimatedVideoGallery.test.tsx +++ b/package/src/components/ImageGallery/__tests__/AnimatedVideoGallery.test.tsx @@ -14,9 +14,6 @@ jest.mock('../../../native.ts', () => { const View = require('react-native/Libraries/Components/View/View'); return { isVideoPackageAvailable: jest.fn(() => true), - NetInfo: { - addEventListener: jest.fn(), - }, Video: View, }; }); diff --git a/package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx b/package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx index 843ebab59f..a6d919ec82 100644 --- a/package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx +++ b/package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx @@ -25,9 +25,6 @@ jest.mock('../../../native.ts', () => { const View = require('react-native/Libraries/Components/View/View'); return { isVideoPackageAvailable: jest.fn(() => true), - NetInfo: { - addEventListener: jest.fn(), - }, Video: View, }; }); diff --git a/package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx b/package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx index 1f998c8111..7b17012ba5 100644 --- a/package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx +++ b/package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx @@ -29,10 +29,6 @@ jest.mock('../../../native.ts', () => { return { deleteFile: jest.fn(), isVideoPackageAvailable: jest.fn(() => true), - NetInfo: { - addEventListener: jest.fn(), - fetch: jest.fn(), - }, saveFile: jest.fn(), shareImage: jest.fn(), Video: View, diff --git a/package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx b/package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx index 97c115887e..dd30cb5b6b 100644 --- a/package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx +++ b/package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx @@ -31,10 +31,6 @@ jest.mock('../../../native.ts', () => { const View = require('react-native/Libraries/Components/View/View'); return { isVideoPackageAvailable: jest.fn(() => true), - NetInfo: { - addEventListener: jest.fn(), - fetch: jest.fn(), - }, Video: View, }; }); diff --git a/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx b/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx index c68301bd9a..9ed2a8a398 100644 --- a/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +++ b/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx @@ -17,9 +17,6 @@ import { AudioAttachment, AudioAttachmentProps } from '../../Attachment/AudioAtt jest.mock('../../../native.ts', () => ({ isAudioPackageAvailable: jest.fn(() => true), - NetInfo: { - addEventListener: jest.fn(), - }, Sound: { initializeSound: jest.fn(), Player: null, diff --git a/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx b/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx index a65f2d0975..92821bb0d5 100644 --- a/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +++ b/package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx @@ -20,9 +20,6 @@ jest.mock('../../../native.ts', () => { return { isAudioPackageAvailable: jest.fn(() => true), - NetInfo: { - addEventListener: jest.fn(), - }, Sound: { Player: View, }, diff --git a/package/src/components/MessageInput/__tests__/FileUploadPreview.test.js b/package/src/components/MessageInput/__tests__/FileUploadPreview.test.js index 4489fabeb1..a633572d88 100644 --- a/package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +++ b/package/src/components/MessageInput/__tests__/FileUploadPreview.test.js @@ -31,10 +31,6 @@ jest.mock('../../../native.ts', () => { return { isAudioPackageAvailable: jest.fn(() => true), - NetInfo: { - addEventListener: jest.fn(), - fetch: jest.fn(), - }, Sound: { Player: View, }, diff --git a/package/src/components/MessageList/__tests__/MessageList.test.js b/package/src/components/MessageList/__tests__/MessageList.test.js index 2a7cdaacab..4da5c31ea6 100644 --- a/package/src/components/MessageList/__tests__/MessageList.test.js +++ b/package/src/components/MessageList/__tests__/MessageList.test.js @@ -13,7 +13,6 @@ import { generateMember } from '../../../mock-builders/generator/member'; import { generateMessage } from '../../../mock-builders/generator/message'; import { generateUser } from '../../../mock-builders/generator/user'; import { getTestClientWithUser } from '../../../mock-builders/mock'; -import { registerNativeHandlers } from '../../../native'; import { Channel } from '../../Channel/Channel'; import { Chat } from '../../Chat/Chat'; import { MessageList } from '../MessageList'; @@ -314,16 +313,6 @@ describe('MessageList', () => { }); it('should render the is offline error', async () => { - registerNativeHandlers({ - NetInfo: { - addEventListener: () => () => null, - fetch: () => - new Promise((resolve) => { - resolve(false); - }), - }, - }); - const user1 = generateUser(); const mockedChannel = generateChannelResponse({ members: [generateMember({ user: user1 })], @@ -351,15 +340,5 @@ describe('MessageList', () => { expect(getByTestId('error-notification')).toBeTruthy(); expect(getByText('Reconnecting...')).toBeTruthy(); }); - - registerNativeHandlers({ - NetInfo: { - addEventListener: () => () => null, - fetch: () => - new Promise((resolve) => { - resolve(true); - }), - }, - }); }); }); diff --git a/package/src/components/docs/data.js b/package/src/components/docs/data.js index c431e4e709..469fb01b21 100644 --- a/package/src/components/docs/data.js +++ b/package/src/components/docs/data.js @@ -11,8 +11,7 @@ client.connectUser( ); export const channel = client.channel('messaging', 'general', { - image: - 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_01_green.jpg', + image: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_01_green.jpg', name: 'Talk about the documentation', }); @@ -45,8 +44,7 @@ export const message = { attachments: [], 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: [ { @@ -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 | never; -}; - export let FlatList = DefaultFlatList; -export let NetInfo: NetInfo = { - addEventListener: fail, - fetch: fail, -}; - type PickDocument = ({ maxNumberOfFiles }: { maxNumberOfFiles?: number }) => | Promise<{ cancelled: boolean; @@ -291,7 +279,6 @@ type Handlers = { getLocalAssetUri?: GetLocalAssetUri; getPhotos?: GetPhotos; iOS14RefreshGallerySelection?: iOS14RefreshGallerySelection; - NetInfo?: NetInfo; oniOS14GalleryLibrarySelectionChange?: OniOS14LibrarySelectionChange; pickDocument?: PickDocument; saveFile?: SaveFile; @@ -320,9 +307,6 @@ export const registerNativeHandlers = (handlers: Handlers) => { if (handlers.FlatList) { FlatList = handlers.FlatList; } - if (handlers.NetInfo) { - NetInfo = handlers.NetInfo; - } if (handlers.getLocalAssetUri) { getLocalAssetUri = handlers.getLocalAssetUri; diff --git a/package/yarn.lock b/package/yarn.lock index 320f74906e..ee694e403a 100644 --- a/package/yarn.lock +++ b/package/yarn.lock @@ -2454,10 +2454,10 @@ resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.3.0.tgz#9e558170c106bbafaa1ef502bd8e6d4651012bf9" integrity sha512-+zDZ20NUnSWghj7Ku5aFphMzuM9JulqCW+aPXT6IfIXFbb8tzYTTOSeRFOtuekJ99ibW2fUCSsjuKNlwDIbHFg== -"@react-native-community/netinfo@6.0.0": - version "6.0.0" - resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-6.0.0.tgz#2a4d7190b508dd0c2293656c9c1aa068f6f60a71" - integrity sha512-Z9M8VGcF2IZVOo2x+oUStvpCW/8HjIRi4+iQCu5n+PhC7OqCQX58KYAzdBr///alIfRXiu6oMb+lK+rXQH1FvQ== +"@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"