From 13c6da4e33d7b39a322af21ffc768ec58ef2a3dd Mon Sep 17 00:00:00 2001 From: Khushal Agarwal Date: Thu, 31 Aug 2023 17:33:33 +0530 Subject: [PATCH] refactor(react-native): remove react-native-device-info as optional dependency (#1035) Co-authored-by: Vishal Narkhede --- .../src/utils/device-info/libs.ts | 17 ----------------- .../src/utils/setClientDetails.ts | 4 ++-- 2 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 packages/react-native-sdk/src/utils/device-info/libs.ts diff --git a/packages/react-native-sdk/src/utils/device-info/libs.ts b/packages/react-native-sdk/src/utils/device-info/libs.ts deleted file mode 100644 index d0af4eb1c8..0000000000 --- a/packages/react-native-sdk/src/utils/device-info/libs.ts +++ /dev/null @@ -1,17 +0,0 @@ -export type RNDeviceInfoType = - typeof import('react-native-device-info').default; - -let deviceInfo: RNDeviceInfoType | undefined; - -try { - deviceInfo = require('react-native-device-info').default; -} catch (e) {} - -export function getDeviceInfoLib() { - if (!deviceInfo) { - throw Error( - 'react-native-device-info library is not installed. Please see https://github.com/react-native-device-info/react-native-device-info#installation for installation instructions', - ); - } - return deviceInfo; -} diff --git a/packages/react-native-sdk/src/utils/setClientDetails.ts b/packages/react-native-sdk/src/utils/setClientDetails.ts index 1dbe1e72a4..eb4d756263 100644 --- a/packages/react-native-sdk/src/utils/setClientDetails.ts +++ b/packages/react-native-sdk/src/utils/setClientDetails.ts @@ -4,9 +4,9 @@ import { setOSInfo, SfuModels, } from '@stream-io/video-client'; -import { getDeviceInfoLib } from './device-info/libs'; import { Platform } from 'react-native'; import { version } from '../../version'; +import RNDeviceInfo from 'react-native-device-info'; const [major, minor, patch] = version.split('.'); @@ -18,7 +18,7 @@ export const setClientDetails = () => { patch, }); - const deviceInfo = getDeviceInfoLib(); + const deviceInfo = RNDeviceInfo; setOSInfo({ name: Platform.OS,