1
1
import { WALLET_CONNECTORS , type WalletRegistryItem } from "@web3auth/no-modal" ;
2
- import Bowser from "bowser" ;
3
2
import { JSX , useCallback , useContext , useMemo , useState } from "react" ;
4
3
import { useTranslation } from "react-i18next" ;
5
4
6
5
import { CONNECT_WALLET_PAGES , DEFAULT_METAMASK_WALLET_REGISTRY_ITEM , PAGES } from "../../constants" ;
7
6
import { BodyState , RootContext } from "../../context/RootContext" ;
8
7
import { ThemedContext } from "../../context/ThemeContext" ;
9
- import { browser , ExternalButton , mobileOs , MODAL_STATUS , os , platform , TOAST_TYPE , ToastType } from "../../interfaces" ;
8
+ import { ExternalButton , mobileOs , MODAL_STATUS , TOAST_TYPE , ToastType } from "../../interfaces" ;
10
9
import i18n from "../../localeImport" ;
11
10
import { cn , getBrowserExtensionUrl , getBrowserName , getIcons , getMobileInstallLink , getOsName } from "../../utils" ;
12
11
import BottomSheet from "../BottomSheet" ;
@@ -42,6 +41,7 @@ function Root(props: RootProps) {
42
41
isSmsPasswordLessLoginVisible,
43
42
preHandleExternalWalletClick,
44
43
uiConfig,
44
+ deviceDetails,
45
45
} = props ;
46
46
47
47
const {
@@ -99,16 +99,6 @@ function Root(props: RootProps) {
99
99
} ;
100
100
101
101
// Wallet Details
102
- const deviceDetails = useMemo < { platform : platform ; browser : browser ; os : mobileOs } > ( ( ) => {
103
- if ( typeof window === "undefined" ) return { platform : "mobile" , browser : "chrome" , os : "ios" } ;
104
- const browserData = Bowser . getParser ( window . navigator . userAgent ) ;
105
- return {
106
- platform : browserData . getPlatformType ( ) as platform ,
107
- browser : browserData . getBrowserName ( ) . toLowerCase ( ) as browser ,
108
- os : browserData . getOSName ( ) as mobileOs ,
109
- } ;
110
- } , [ ] ) ;
111
-
112
102
const mobileInstallLinks = useMemo < JSX . Element [ ] > ( ( ) => {
113
103
if ( deviceDetails . platform === "desktop" ) return [ ] ;
114
104
const installConfig = bodyState . installLinks ?. wallet ?. walletRegistryItem ?. app || { } ;
@@ -424,12 +414,8 @@ function Root(props: RootProps) {
424
414
) ;
425
415
426
416
const isShowLoader = useMemo ( ( ) => {
427
- // don't show loader if metamask is connecting and there is a connect uri
428
- if ( modalState . detailedLoaderConnector === WALLET_CONNECTORS . METAMASK && modalState . metamaskConnectUri ) {
429
- return false ;
430
- }
431
417
return modalState . status !== MODAL_STATUS . INITIALIZED ;
432
- } , [ modalState . detailedLoaderConnector , modalState . metamaskConnectUri , modalState . status ] ) ;
418
+ } , [ modalState . status ] ) ;
433
419
434
420
return (
435
421
< RootContext . Provider value = { contextValue } >
@@ -494,6 +480,7 @@ function Root(props: RootProps) {
494
480
totalExternalWallets = { totalExternalWallets }
495
481
logoAlignment = { logoAlignment }
496
482
buttonRadius = { buttonRadiusType }
483
+ deviceDetails = { deviceDetails }
497
484
handleSocialLoginClick = { handleSocialLoginClick }
498
485
handleExternalWalletBtnClick = { onExternalWalletBtnClick }
499
486
handleSocialLoginHeight = { handleSocialLoginHeight }
@@ -511,11 +498,7 @@ function Root(props: RootProps) {
511
498
allExternalButtons = { allButtons }
512
499
connectorVisibilityMap = { connectorVisibilityMap }
513
500
customConnectorButtons = { customConnectorButtons }
514
- deviceDetails = { {
515
- platform : deviceDetails . platform ,
516
- browser : deviceDetails . browser ,
517
- os : deviceDetails . os as os ,
518
- } }
501
+ deviceDetails = { deviceDetails }
519
502
chainNamespace = { chainNamespaces }
520
503
buttonRadius = { buttonRadiusType }
521
504
handleWalletDetailsHeight = { handleWalletDetailsHeight }
0 commit comments