Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/App.js
import React, { useState } from 'react'; | import React, { useState, useEffect } from 'react'; | ||||
import 'antd/dist/antd.less'; | import 'antd/dist/antd.less'; | ||||
import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||
import { Spin } from 'antd'; | import { Spin } from 'antd'; | ||||
import { | import { | ||||
CashLoadingIcon, | CashLoadingIcon, | ||||
HomeIcon, | HomeIcon, | ||||
SendIcon, | SendIcon, | ||||
ReceiveIcon, | ReceiveIcon, | ||||
▲ Show 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | const App = () => { | ||||
// If wallet is unmigrated, do not show page until it has migrated | // If wallet is unmigrated, do not show page until it has migrated | ||||
// An invalid wallet will be validated/populated after the next API call, ETA 10s | // An invalid wallet will be validated/populated after the next API call, ETA 10s | ||||
const validWallet = isValidStoredWallet(wallet); | const validWallet = isValidStoredWallet(wallet); | ||||
const location = useLocation(); | const location = useLocation(); | ||||
const history = useHistory(); | const history = useHistory(); | ||||
const selectedKey = | const selectedKey = | ||||
location && location.pathname ? location.pathname.substr(1) : ''; | location && location.pathname ? location.pathname.substr(1) : ''; | ||||
const checkForPersistentStorage = async () => { | |||||
// Request persistent storage for site | |||||
if (navigator.storage && navigator.storage.persist) { | |||||
// Check if storage is persistent | |||||
const isPersisted = await navigator.storage.persisted(); | |||||
console.log(`Persisted storage status: ${isPersisted}`); | |||||
// If not, request persistent storage | |||||
if (!isPersisted) { | |||||
console.log(`Requesting persistent storage`); | |||||
const persistanceRequestResult = | |||||
await navigator.storage.persist(); | |||||
console.log( | |||||
`Persistent storage granted: ${persistanceRequestResult}`, | |||||
); | |||||
} | |||||
} | |||||
}; | |||||
// Easter egg boolean not used in extension/src/components/App.js | // Easter egg boolean not used in extension/src/components/App.js | ||||
const hasTab = validWallet | const hasTab = validWallet | ||||
? checkForTokenById( | ? checkForTokenById( | ||||
wallet.state.tokens, | wallet.state.tokens, | ||||
'50d8292c6255cda7afc6c8566fed3cf42a2794e9619740fe8f4c95431271410e', | '50d8292c6255cda7afc6c8566fed3cf42a2794e9619740fe8f4c95431271410e', | ||||
) | ) | ||||
: false; | : false; | ||||
useEffect(() => { | |||||
checkForPersistentStorage(); | |||||
}, []); | |||||
return ( | return ( | ||||
<ThemeProvider theme={theme}> | <ThemeProvider theme={theme}> | ||||
<GlobalStyle /> | <GlobalStyle /> | ||||
<ServiceWorkerWrapper /> | <ServiceWorkerWrapper /> | ||||
<Spin | <Spin | ||||
spinning={ | spinning={ | ||||
loading || loadingUtxosAfterSend || (wallet && !validWallet) | loading || loadingUtxosAfterSend || (wallet && !validWallet) | ||||
} | } | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |