diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-02-02 08:28:42 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-02-02 11:52:22 +0100 |
| commit | 29d936190a7969bd829db34cd1126e568b054329 (patch) | |
| tree | dd10d9a0dcb6b819cc4415e499a991a7007e7b59 /gui/src | |
| parent | e3ec8bc85aa1cea4711a3549bcae04bc74e5965b (diff) | |
| download | mullvadvpn-29d936190a7969bd829db34cd1126e568b054329.tar.xz mullvadvpn-29d936190a7969bd829db34cd1126e568b054329.zip | |
Enable custom DNS when first IP is added instead of when toggled
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/components/AdvancedSettings.tsx | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/gui/src/renderer/components/AdvancedSettings.tsx b/gui/src/renderer/components/AdvancedSettings.tsx index 7c97f0d844..90b1de370e 100644 --- a/gui/src/renderer/components/AdvancedSettings.tsx +++ b/gui/src/renderer/components/AdvancedSettings.tsx @@ -449,13 +449,13 @@ export default class AdvancedSettings extends React.Component<IProps, IState> { <AriaInput> <Cell.Switch ref={this.customDnsSwitchRef} - isOn={this.props.dns.custom} + isOn={this.props.dns.custom || this.state.showAddCustomDns} onChange={this.setCustomDnsEnabled} /> </AriaInput> </AriaInputGroup> </StyledCustomDnsSwitchContainer> - <Accordion expanded={this.props.dns.custom}> + <Accordion expanded={this.props.dns.custom || this.state.showAddCustomDns}> <CellList items={this.customDnsItems()} onRemove={this.removeDnsAddress} /> {this.state.showAddCustomDns && ( @@ -511,10 +511,12 @@ export default class AdvancedSettings extends React.Component<IProps, IState> { } private setCustomDnsEnabled = async (enabled: boolean) => { - await this.props.setDnsOptions({ - custom: enabled, - addresses: this.props.dns.addresses, - }); + if (this.props.dns.addresses.length > 0) { + await this.props.setDnsOptions({ + custom: enabled, + addresses: this.props.dns.addresses, + }); + } if (enabled && this.props.dns.addresses.length === 0) { this.showAddCustomDnsRow(); @@ -548,16 +550,13 @@ export default class AdvancedSettings extends React.Component<IProps, IState> { ) { event?.target.focus(); } else { - this.hideAddCustomDnsRow(false); + this.hideAddCustomDnsRow(); } }; - private hideAddCustomDnsRow(justAdded: boolean) { + private hideAddCustomDnsRow() { if (!this.state.publicDnsIpToConfirm) { this.setState({ showAddCustomDns: false }); - if (!justAdded && this.props.dns.addresses.length === 0) { - consumePromise(this.setCustomDnsEnabled(false)); - } } } @@ -581,10 +580,10 @@ export default class AdvancedSettings extends React.Component<IProps, IState> { } else { try { await this.props.setDnsOptions({ - custom: this.props.dns.custom, + custom: this.props.dns.custom || this.state.showAddCustomDns, addresses: [...this.props.dns.addresses, address], }); - this.hideAddCustomDnsRow(true); + this.hideAddCustomDnsRow(); } catch (_e) { this.setState({ invalidDnsIp: true }); } |
