Skip to content

Commit ccdee78

Browse files
attempt to use arm as default for mac (#8328)
* attempt to use arm as default for mac * fix: there's no such architecture arm64 * chore: removed console.log * fix: test --------- Co-authored-by: Claudio Wunder <cwunder@hubspot.com>
1 parent 01821a2 commit ccdee78

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

apps/site/hooks/react-client/__tests__/useDetectOS.test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ describe('useDetectOS', () => {
7171
await waitFor(() => {
7272
assert.deepEqual(result.current, {
7373
os: 'MAC',
74-
bitness: '32',
75-
architecture: 'x86',
74+
bitness: '64',
75+
architecture: 'arm',
7676
});
7777
});
7878
});

apps/site/hooks/react-client/useDetectOS.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Bitness,
88
OperatingSystem,
99
} from '#site/types/userAgent';
10-
import { getHighEntropyValues, detectOS } from '#site/util/userAgent';
10+
import { detectOS, getHighEntropyValues } from '#site/util/userAgent';
1111

1212
type UserOSState = {
1313
os: OperatingSystem | 'LOADING';
@@ -28,10 +28,12 @@ const useDetectOS = () => {
2828
navigator.userAgent
2929
);
3030

31+
const os = detectOS();
32+
3133
// We immediately set the OS to LOADING, and then we update it with the detected OS.
3234
// This is due to that initial render set within the state will indicate a mismatch from
3335
// the server-side rendering versus what the initial state is from the client-side
34-
setUserOSState(current => ({ ...current, os: detectOS() }));
36+
setUserOSState(current => ({ ...current, os }));
3537

3638
// We attempt to get the high entropy values from the Browser and set the User OS State
3739
// based from the values we get from the Browser, if it fails we fallback to the User Agent
@@ -40,8 +42,9 @@ const useDetectOS = () => {
4042
({
4143
// If there is no getHighEntropyValues API on the Browser or it failed to resolve
4244
// we attempt to fallback to what the User Agent indicates
43-
bitness = uaIndicates64 ? '64' : '32',
44-
architecture = 'x86',
45+
bitness = os === 'MAC' || uaIndicates64 ? '64' : '32',
46+
// we assume that MacOS has moved to arm64 by default now
47+
architecture = os === 'MAC' ? 'arm' : 'x86',
4548
}) => {
4649
setUserOSState(current => ({
4750
...current,

0 commit comments

Comments
 (0)