mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-22 07:48:30 +00:00
Re-set address state when wallet changes (#1107)
This commit is contained in:
parent
31912c0f83
commit
c5f32a9ce2
@ -13,19 +13,24 @@ interface ReduxProps {
|
||||
wallet: AppState['wallet']['inst'];
|
||||
}
|
||||
|
||||
type Props = ReduxProps;
|
||||
|
||||
interface State {
|
||||
walletAddress: string | null;
|
||||
}
|
||||
|
||||
class CurrentCustomMessageClass extends PureComponent<ReduxProps, State> {
|
||||
class CurrentCustomMessageClass extends PureComponent<Props, State> {
|
||||
public state: State = {
|
||||
walletAddress: null
|
||||
};
|
||||
|
||||
public async componentDidMount() {
|
||||
if (this.props.wallet) {
|
||||
const walletAddress = await this.props.wallet.getAddressString();
|
||||
this.setState({ walletAddress });
|
||||
this.setAddressState(this.props);
|
||||
}
|
||||
|
||||
public componentWillReceiveProps(nextProps: Props) {
|
||||
if (this.props.wallet !== nextProps.wallet) {
|
||||
this.setAddressState(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +47,15 @@ class CurrentCustomMessageClass extends PureComponent<ReduxProps, State> {
|
||||
}
|
||||
}
|
||||
|
||||
private async setAddressState(props: Props) {
|
||||
if (props.wallet) {
|
||||
const walletAddress = await props.wallet.getAddressString();
|
||||
this.setState({ walletAddress });
|
||||
} else {
|
||||
this.setState({ walletAddress: '' });
|
||||
}
|
||||
}
|
||||
|
||||
private getMessage() {
|
||||
const { currentTo, tokens } = this.props;
|
||||
const { walletAddress } = this.state;
|
||||
|
Loading…
x
Reference in New Issue
Block a user