Skip to content

Commit

Permalink
fix: isAppleSilicon using withClientHints (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
braianj authored Oct 15, 2024
1 parent 94cd9ce commit 3b41a52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| :------------------------------------------------------------------------------------ | :--------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------- |
| [src/variables.ts](src/variables.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6, move to ./dom/types.ts |
| [src/components/HTML.tsx](src/components/HTML.tsx#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/hooks/useAdvancedUserAgentData.ts](src/hooks/useAdvancedUserAgentData.ts#L1) | [@2fd](https://github.com/2fd) | add Docs, set as good practice |
| [src/hooks/useEditor.ts](src/hooks/useEditor.ts#L1) | [@2fd](https://github.com/2fd) | replace for Formik and Yup on v6 |
| [src/hooks/useEntityStore.ts](src/hooks/useEntityStore.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/hooks/useEntityStoreSelector.ts](src/hooks/useEntityStoreSelector.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
Expand All @@ -20,7 +21,6 @@
| [src/hooks/useStore.ts](src/hooks/useStore.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/hooks/useTransaction.ts](src/hooks/useTransaction.ts#L1) | [@2fd](https://github.com/2fd) | looks to big, refactor? |
| [src/hooks/useURLSearchParams.ts](src/hooks/useURLSearchParams.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/hooks/useUserAgentData.ts](src/hooks/useUserAgentData.ts#L1) | [@2fd](https://github.com/2fd) | add Docs, set as good practice |
| [src/hooks/useWindowScroll.ts](src/hooks/useWindowScroll.ts#L1) | [@2fd](https://github.com/2fd) | check for a better options, may cause a lot of unnecessary re renders |
| [src/utils/EntityStore.ts](src/utils/EntityStore.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/utils/isMobile.ts](src/utils/isMobile.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6, use hook useUserAgentData |
Expand All @@ -31,6 +31,7 @@
| [src/components/Layout/Layout.tsx](src/components/Layout/Layout.tsx#L316) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 use bem notation |
| [src/context/Auth/AuthProvider.tsx](src/context/Auth/AuthProvider.tsx#L44) | | Remove after all dApps get the user identity from localhost |
| [src/entities/Blockchain/keys.ts](src/entities/Blockchain/keys.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/entities/Slack/utils.ts](src/entities/Slack/utils.ts#L12) | | should we use @slack/web-api? |
| [src/utils/api/Catalyst.ts](src/utils/api/Catalyst.ts#L67) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/utils/api/Catalyst.ts](src/utils/api/Catalyst.ts#L79) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
| [src/utils/api/Catalyst.ts](src/utils/api/Catalyst.ts#L122) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 |
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useAdvancedUserAgentData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function useAdvancedUserAgentData(): [
setLoading(true)
const ua = new UAParser(navigator.userAgent)
const uaData = ua.getResult()
const uaDataWithClientHints = await uaData.withClientHints()
const browser = {
name: uaData.browser.name ?? DEFAULT_VALUE,
version: uaData.browser.version ?? DEFAULT_VALUE,
Expand All @@ -64,7 +65,9 @@ export default function useAdvancedUserAgentData(): [
let architecture: string
if (!cpuData.architecture) {
architecture =
os.name === 'macOS' && isAppleSilicon(ua) ? 'arm64' : 'Unknown'
os.name === 'macOS' && isAppleSilicon(uaDataWithClientHints)
? 'arm64'
: 'Unknown'
} else {
architecture = cpuData.architecture
}
Expand Down

0 comments on commit 3b41a52

Please sign in to comment.