-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎭 Add more descriptive mobile device name to the trustchain (#7651)
* Add `react-native-device-info` * Add more descriptive mobile device name to the trustchain * Update the changelog * Ensure `getDeviceNameSync` is called only once * Fix failing tests --------- Co-authored-by: Theophile Sandoz <Theophile Sandoz>
- Loading branch information
Showing
7 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
Add more descriptive mobile device name to the trustchain |
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
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
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
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
9 changes: 7 additions & 2 deletions
9
apps/ledger-live-mobile/src/newArch/features/WalletSync/hooks/useInstanceName.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,12 +1,17 @@ | ||
import { getDeviceNameSync } from "react-native-device-info"; | ||
import { getEnv } from "@ledgerhq/live-env"; | ||
import { Platform } from "react-native"; | ||
|
||
const platformMap: Record<string, string | undefined> = { | ||
ios: "iOS", | ||
ios: "iPhone iOS", | ||
android: "Android", | ||
}; | ||
|
||
let deviceName: string; | ||
|
||
export function useInstanceName(): string { | ||
const hash = getEnv("USER_ID").slice(0, 5); | ||
return `${platformMap[Platform.OS] ?? Platform.OS} ${Platform.Version} ${hash ? " " + hash : ""}`; | ||
const os = platformMap[Platform.OS] ?? Platform.OS; | ||
if (!deviceName) deviceName = getDeviceNameSync() ?? `${os} ${Platform.Version}`; | ||
return `${deviceName} ${hash ? " " + hash : ""}`; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.