-
Notifications
You must be signed in to change notification settings - Fork 5
Add device info #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add device info #9
Conversation
shreyastelkar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFTM
| { title: 'Total Memory (Bytes)', identifier: 'totalMemory' }, | ||
| { title: 'Uptime', identifier: 'uptime' }, | ||
| { title: 'Jail Broken', identifier: 'isJailBroken' }, | ||
| ]; No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing empty line at the end of the file
features/expo/deviceInfo/enums.ts
Outdated
| TABLET = 2, | ||
| DESKTOP = 3, | ||
| TV = 4, | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing empty line at the end of the file
features/expo/deviceInfo/hooks.ts
Outdated
| Promise.all([ | ||
| Device.getDeviceTypeAsync(), | ||
| Device.getUptimeAsync(), | ||
| Device.isRootedExperimentalAsync(), | ||
| ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use separate promises. This will fail on all, even if only one promise fails.
features/expo/deviceInfo/index.tsx
Outdated
|
|
||
| import { Card, Text, View } from 'react-native-ui-lib'; | ||
|
|
||
| import { useDeviceInfo } from 'htk/features/expo/deviceInfo/hooks'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use relative imports since this is a repo that is being used as submodule.
This is forcing us to use htk path alias. We still did not discuss about the standard path alias.
features/expo/deviceInfo/hooks.ts
Outdated
| @@ -0,0 +1,66 @@ | |||
| import { useEffect, useState } from 'react'; | |||
|
|
|||
| import { enumToStr } from 'htk/utils/enum'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Let's use relative imports.
features/expo/deviceInfo/hooks.ts
Outdated
| }); | ||
|
|
||
| useEffect(() => { | ||
| const fetchDeviceInfo = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect. Please use .then() structure.
Device.getDeviceTypeAsync().then(deviceType => {
setDeviceInfo(prev => ({...prev, deviceType: enumToStr(DeviceType, deviceType})
})).catch(error => {
console.error('Failed to fetch device type:', error);
});Please apply to the other async functions as well.
gwainor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please fix you IDE to apply prettier on save or something.
Your prettier is not formatting the code.
features/expo/deviceInfo/hooks.ts
Outdated
| Device.getDeviceTypeAsync().then(deviceType => { | ||
| setDeviceInfo(prev => ({...prev, deviceType: deviceType ? enumToStr(DeviceType, deviceType) : null})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a null possibility of the deviceType variable, there is no need to update the state.
| Device.getDeviceTypeAsync().then(deviceType => { | |
| setDeviceInfo(prev => ({...prev, deviceType: deviceType ? enumToStr(DeviceType, deviceType) : null})); | |
| Device.getDeviceTypeAsync().then(deviceType => { | |
| if (deviceType) { | |
| setDeviceInfo(prev => ({...prev, deviceType: enumToStr(DeviceType, deviceType)})); | |
| } |
gwainor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFTM
gwainor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFTM
Added device info menu for the expo project