fix checkbox displaying in manage tokens modal
This commit is contained in:
parent
81e05c132d
commit
0b6be00632
|
@ -65,8 +65,7 @@ class Tokens extends React.Component<Props, State> {
|
||||||
this.setState(() => ({ filter: value }))
|
this.setState(() => ({ filter: value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
onSwitch = (token: Token) => (e: SyntheticInputEvent<HTMLInputElement>) => {
|
onSwitch = (token: Token) => () => {
|
||||||
const { checked } = e.target
|
|
||||||
const { safeAddress, updateActiveTokens } = this.props
|
const { safeAddress, updateActiveTokens } = this.props
|
||||||
|
|
||||||
updateActiveTokens(safeAddress, token.address)
|
updateActiveTokens(safeAddress, token.address)
|
||||||
|
@ -78,7 +77,9 @@ class Tokens extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { onClose, classes, tokens } = this.props
|
const {
|
||||||
|
onClose, classes, tokens, activeTokens,
|
||||||
|
} = this.props
|
||||||
const { filter } = this.state
|
const { filter } = this.state
|
||||||
const searchClasses = {
|
const searchClasses = {
|
||||||
input: classes.searchInput,
|
input: classes.searchInput,
|
||||||
|
@ -120,7 +121,10 @@ class Tokens extends React.Component<Props, State> {
|
||||||
<Hairline />
|
<Hairline />
|
||||||
</Block>
|
</Block>
|
||||||
<MuiList className={classes.list}>
|
<MuiList className={classes.list}>
|
||||||
{filteredTokens.map((token: Token) => (
|
{filteredTokens.map((token: Token) => {
|
||||||
|
const isActive = activeTokens.findIndex(({ address }) => address === token.address) !== -1
|
||||||
|
|
||||||
|
return (
|
||||||
<ListItem key={token.address} className={classes.token}>
|
<ListItem key={token.address} className={classes.token}>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<Img src={token.logoUri} height={28} alt={token.name} onError={this.setImageToPlaceholder} />
|
<Img src={token.logoUri} height={28} alt={token.name} onError={this.setImageToPlaceholder} />
|
||||||
|
@ -128,11 +132,12 @@ class Tokens extends React.Component<Props, State> {
|
||||||
<ListItemText primary={token.symbol} secondary={token.name} />
|
<ListItemText primary={token.symbol} secondary={token.name} />
|
||||||
{token.address !== ETH_ADDRESS && (
|
{token.address !== ETH_ADDRESS && (
|
||||||
<ListItemSecondaryAction>
|
<ListItemSecondaryAction>
|
||||||
<Switch onChange={this.onSwitch(token)} checked={token.status} />
|
<Switch onChange={this.onSwitch(token)} checked={isActive} />
|
||||||
</ListItemSecondaryAction>
|
</ListItemSecondaryAction>
|
||||||
)}
|
)}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
))}
|
)
|
||||||
|
})}
|
||||||
</MuiList>
|
</MuiList>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
|
|
|
@ -102,7 +102,12 @@ class Balances extends React.Component<Props, State> {
|
||||||
handleClose={this.onHide('Token')}
|
handleClose={this.onHide('Token')}
|
||||||
open={showToken}
|
open={showToken}
|
||||||
>
|
>
|
||||||
<Tokens tokens={tokens} onClose={this.onHide('Token')} safeAddress={safeAddress} />
|
<Tokens
|
||||||
|
tokens={tokens}
|
||||||
|
onClose={this.onHide('Token')}
|
||||||
|
safeAddress={safeAddress}
|
||||||
|
activeTokens={activeTokens}
|
||||||
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const buildSafe = (storedSafe: SafeProps) => {
|
||||||
owners,
|
owners,
|
||||||
}
|
}
|
||||||
|
|
||||||
return SafeRecord(safe)
|
return safe
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildSafesFrom = (loadedSafes: Object): Map<string, Safe> => {
|
const buildSafesFrom = (loadedSafes: Object): Map<string, Safe> => {
|
||||||
|
@ -36,7 +36,7 @@ const buildSafesFrom = (loadedSafes: Object): Map<string, Safe> => {
|
||||||
const safeRecords = keys.map((address: string) => buildSafe(loadedSafes[address]))
|
const safeRecords = keys.map((address: string) => buildSafe(loadedSafes[address]))
|
||||||
|
|
||||||
return safes.withMutations(async (map) => {
|
return safes.withMutations(async (map) => {
|
||||||
safeRecords.forEach((safe: Safe) => map.set(safe.get('address'), safe))
|
safeRecords.forEach((safe: SafeProps) => map.set(safe.address, safe))
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
|
Loading…
Reference in New Issue