Skip to content

Commit

Permalink
use local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed Jan 16, 2022
1 parent 91015f8 commit 697b3b8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 89 deletions.
17 changes: 0 additions & 17 deletions packages/web/src/components/organisms/ControlChain/destination.tsx

This file was deleted.

58 changes: 0 additions & 58 deletions packages/web/src/components/organisms/ControlChain/index.tsx

This file was deleted.

12 changes: 6 additions & 6 deletions packages/web/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const client = new ApolloClient({
})

class NextApp extends App<AppInitialProps & WithApolloProps<{}>> {
state = { isCurrencyDEV: true, web3: undefined, ethersProvider: undefined, selectedChain: 'ethereum' }
state = { isCurrencyDEV: true, web3: undefined, ethersProvider: undefined, selectedChain: 'ethereum' as ChainName }

componentDidMount = () => {
message.config({
Expand All @@ -28,8 +28,8 @@ class NextApp extends App<AppInitialProps & WithApolloProps<{}>> {

const settings = localStorage.getItem('settings')
if (settings) {
const { currency } = JSON.parse(settings)
this.setState({ isCurrencyDEV: currency === 'DEV' })
const { currency, selectedChain } = JSON.parse(settings)
this.setState({ isCurrencyDEV: currency === 'DEV', selectedChain })
}

// Google Analytics
Expand Down Expand Up @@ -60,9 +60,9 @@ class NextApp extends App<AppInitialProps & WithApolloProps<{}>> {
setChain = (chain: ChainName) => {
localStorage.setItem(
'settings',
JSON.stringify({ currency: !this.state.isCurrencyDEV ? 'DEV' : 'USD', selectedChain: chain })
JSON.stringify({ currency: this.state.isCurrencyDEV ? 'DEV' : 'USD', selectedChain: chain })
)
this.setState({ isCurrencyDEV: !this.state.isCurrencyDEV, selectedChain: chain })
this.setState({ isCurrencyDEV: this.state.isCurrencyDEV, selectedChain: chain })
}

render() {
Expand All @@ -81,7 +81,7 @@ class NextApp extends App<AppInitialProps & WithApolloProps<{}>> {
value={{
isCurrencyDEV: this.state.isCurrencyDEV,
toggleCurrency: this.toggleCurrency,
selectedChain: 'ethereum',
selectedChain: this.state.selectedChain,
setChain: this.setChain
}}
>
Expand Down
8 changes: 0 additions & 8 deletions packages/web/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { DevChart } from 'src/components/organisms/DevChart'
import { Container } from 'src/components/atoms/Container'
import styled from 'styled-components'
import { useDetectChain, useProvider } from 'src/fixtures/wallet/hooks'
import Text from 'antd/lib/typography/Text'
import { ControlChain } from 'src/components/organisms/ControlChain'

type Props = {}

Expand All @@ -22,16 +20,11 @@ const StyledHeadline = styled(Headline)`
const DevProtocolStats = (_: Props) => {
const { nonConnectedEthersProvider } = useProvider()
const { name: chain } = useDetectChain(nonConnectedEthersProvider)
const isL1 = chain === 'ethereum'

return chain === undefined ? (
<div style={{ display: 'flex', minHeight: '100vh', justifyContent: 'center', alignItems: 'center' }}>
<Spin />
</div>
) : !isL1 ? (
<div style={{ display: 'flex', minHeight: '100vh', justifyContent: 'center', alignItems: 'center' }}>
<Text type="secondary">(Not provide this feature yet on L2)</Text>
</div>
) : (
<div style={{ display: 'flex', flexDirection: 'column', minHeight: '100vh' }}>
<Header />
Expand All @@ -47,7 +40,6 @@ const DevProtocolStats = (_: Props) => {
<Container>
<DevChart />
</Container>
<ControlChain />
<Footer />
</div>
)
Expand Down

0 comments on commit 697b3b8

Please sign in to comment.