Make it such that users can switch between Ledger accounts without first switching back to an injected provider
This commit is contained in:
@@ -190,8 +190,10 @@ export class Blockchain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache injected provider so that we can switch the user back to it easily
|
// Cache injected provider so that we can switch the user back to it easily
|
||||||
this._cachedProvider = this._web3Wrapper.getProviderObj();
|
if (_.isUndefined(this._cachedProvider)) {
|
||||||
this._cachedProviderNetworkId = this.networkId;
|
this._cachedProvider = this._web3Wrapper.getProviderObj();
|
||||||
|
this._cachedProviderNetworkId = this.networkId;
|
||||||
|
}
|
||||||
|
|
||||||
this._userAddress = '';
|
this._userAddress = '';
|
||||||
this._dispatcher.updateUserAddress(''); // Clear old userAddress
|
this._dispatcher.updateUserAddress(''); // Clear old userAddress
|
||||||
|
|||||||
@@ -265,7 +265,10 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.providerType !== ProviderType.Ledger) {
|
if (
|
||||||
|
this.props.providerType !== ProviderType.Ledger ||
|
||||||
|
(this.props.providerType === ProviderType.Ledger && this.props.networkId !== this.state.preferredNetworkId)
|
||||||
|
) {
|
||||||
await this.props.blockchain.updateProviderToLedgerAsync(this.state.preferredNetworkId);
|
await this.props.blockchain.updateProviderToLedgerAsync(this.state.preferredNetworkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,17 +37,15 @@ export class ProviderPicker extends React.Component<ProviderPickerProps, Provide
|
|||||||
// Show dropdown with two options
|
// Show dropdown with two options
|
||||||
return (
|
return (
|
||||||
<div style={{ width: 225, overflow: 'hidden' }}>
|
<div style={{ width: 225, overflow: 'hidden' }}>
|
||||||
<RadioButtonGroup
|
<RadioButtonGroup name="provider" defaultSelected={this.props.providerType}>
|
||||||
name="provider"
|
|
||||||
defaultSelected={this.props.providerType}
|
|
||||||
onChange={this._onProviderRadioChanged.bind(this)}
|
|
||||||
>
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
|
onClick={this._onProviderRadioChanged.bind(this, ProviderType.Injected)}
|
||||||
style={{ ...menuStyle, backgroundColor: !isLedgerSelected && colors.grey50 }}
|
style={{ ...menuStyle, backgroundColor: !isLedgerSelected && colors.grey50 }}
|
||||||
value={ProviderType.Injected}
|
value={ProviderType.Injected}
|
||||||
label={this._renderLabel(this.props.injectedProviderName, !isLedgerSelected)}
|
label={this._renderLabel(this.props.injectedProviderName, !isLedgerSelected)}
|
||||||
/>
|
/>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
|
onClick={this._onProviderRadioChanged.bind(this, ProviderType.Ledger)}
|
||||||
style={{ ...menuStyle, backgroundColor: isLedgerSelected && colors.grey50 }}
|
style={{ ...menuStyle, backgroundColor: isLedgerSelected && colors.grey50 }}
|
||||||
value={ProviderType.Ledger}
|
value={ProviderType.Ledger}
|
||||||
label={this._renderLabel('Ledger Nano S', isLedgerSelected)}
|
label={this._renderLabel('Ledger Nano S', isLedgerSelected)}
|
||||||
@@ -80,7 +78,7 @@ export class ProviderPicker extends React.Component<ProviderPickerProps, Provide
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
private _onProviderRadioChanged(e: any, value: string) {
|
private _onProviderRadioChanged(value: string) {
|
||||||
if (value === ProviderType.Ledger) {
|
if (value === ProviderType.Ledger) {
|
||||||
this.props.onToggleLedgerDialog();
|
this.props.onToggleLedgerDialog();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user