-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27534 from software-mansion-labs/ts-migration/kow…
…czarz/get-os-and-name [No QA][TS migration] Migrate 'getOSAndName' lib to TypeScript
- Loading branch information
Showing
4 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
11 changes: 9 additions & 2 deletions
11
...etDeviceInfo/getOSAndName/index.native.js → ...etDeviceInfo/getOSAndName/index.native.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import Str from 'expensify-common/lib/str'; | ||
import RNDeviceInfo from 'react-native-device-info'; | ||
import GetOSAndName from './types'; | ||
|
||
export default function getOSAndName() { | ||
const getOSAndName: GetOSAndName = () => { | ||
const deviceName = RNDeviceInfo.getDeviceNameSync(); | ||
const prettyName = `${Str.UCFirst(RNDeviceInfo.getManufacturerSync() || '')} ${deviceName}`; | ||
return { | ||
// Parameter names are predefined and we don't choose it here | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
device_name: RNDeviceInfo.isEmulatorSync() ? `Emulator - ${prettyName}` : prettyName, | ||
// Parameter names are predefined and we don't choose it here | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
os_version: RNDeviceInfo.getSystemVersion(), | ||
}; | ||
} | ||
}; | ||
|
||
export default getOSAndName; |
12 changes: 12 additions & 0 deletions
12
src/libs/actions/Device/getDeviceInfo/getOSAndName/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {getOSAndName as libGetOSAndName} from 'expensify-common/lib/Device'; | ||
import GetOSAndName from './types'; | ||
|
||
const getOSAndName: GetOSAndName = () => { | ||
// Parameter names are predefined and we don't choose it here | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const {device_name, os_version} = libGetOSAndName(); | ||
// Parameter names are predefined and we don't choose it here | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
return {device_name, os_version}; | ||
}; | ||
export default getOSAndName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Parameter names are predefined and we don't choose it here | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
type GetOSAndName = () => {device_name: string | undefined; os_version: string | undefined}; | ||
export default GetOSAndName; |