File tree Expand file tree Collapse file tree
packages/sdk-multichain/src/domain/platform Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,30 +13,38 @@ export enum PlatformType {
1313 ReactNative = 'react-native' ,
1414}
1515
16-
1716function isNotBrowser ( ) {
18- return (
19- typeof window === 'undefined' ||
20- ! window ?. navigator ||
21- ( typeof global !== 'undefined' &&
22- global ?. navigator ?. product === 'ReactNative' ) ||
23- navigator ?. product === 'ReactNative'
24- ) ;
17+ if ( typeof window === 'undefined' ) {
18+ return true ;
19+ }
20+ if ( ! window ?. navigator ) {
21+ return true
22+ }
23+ if ( typeof global !== 'undefined' &&
24+ global ?. navigator ?. product === 'ReactNative' ) {
25+ return true ;
26+ }
27+ return navigator ?. product === 'ReactNative'
2528}
2629
2730function isReactNative ( ) {
28- return (
29- typeof window !== 'undefined' &&
30- window ?. navigator &&
31- window . navigator ?. product === 'ReactNative'
32- ) ?? false ;
31+ const hasWindowNavigator = typeof window !== 'undefined' && window . navigator !== undefined ;
32+ const navigator = hasWindowNavigator ?
33+ window . navigator :
34+ undefined ;
35+
36+ if ( ! navigator ) {
37+ return false ;
38+ }
39+
40+ return hasWindowNavigator && window . navigator ?. product === 'ReactNative'
3341}
3442
3543function isMetaMaskMobileWebView ( ) {
3644 return (
3745 typeof window !== 'undefined' &&
3846 Boolean ( window . ReactNativeWebView ) &&
39- Boolean ( navigator . userAgent . endsWith ( 'MetaMaskMobile' ) )
47+ Boolean ( window . navigator . userAgent . endsWith ( 'MetaMaskMobile' ) )
4048 ) ;
4149}
4250
You can’t perform that action at this time.
0 commit comments