Skip to content

Commit

Permalink
Do not remove active network (#11234)
Browse files Browse the repository at this point in the history
  • Loading branch information
spylogsster committed Nov 24, 2021
1 parent b554622 commit 2d79b3c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@
<template>
<div on-dblclick=onItemDoubleClick>
<div class="settings-box">
<div class="flex cr-padded-text hovered">
<div class$=[[getNetworkItemClass(item.chainId)]]>
<div><span hidden="[[hideNativeCurrencyInfo]]">({{item.nativeCurrency.name}}) </span>{{item.chainName}}</div>
<div class="secondary">[[getItemDescritionText(item)]]</div>
</div>
<cr-icon-button class="icon-more-vert"
on-click="onNetworkMenuTapped_"
itemName=[[item.name]]
hidden=[[isDefaultNetwork(item.chainId)]]
focus-type="menu">
</cr-icon-button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase {
this.updateNetworks()
}

getNetworkItemClass(chainId) {
if (!this.isDefaultNetwork(chainId)) {
return "flex cr-padded-text hovered"
}
return "flex cr-padded-text"
}

isDefaultNetwork(chainId) {
return (chainId ===
this.getPref('brave.wallet.wallet_current_chain_id').value)
Expand All @@ -79,14 +86,20 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase {
}

onDeleteActionTapped_(event) {
const chainId = this.selectedNetwork.chainId
const chainName = this.selectedNetwork.chainName
this.selectedNetwork = {}
this.$$('cr-action-menu').close();
if (this.isDefaultNetwork(chainId)) {
this.updateNetworks()
return
}
var message = this.i18n('walletDeleteNetworkConfirmation',
event.model.item.chainName)
chainName)
if (!window.confirm(message))
return

this.browserProxy_.removeEthereumChain(event.model.item.chainId).
this.browserProxy_.removeEthereumChain(chainId).
then(success => { this.updateNetworks() })
}

Expand All @@ -95,6 +108,10 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase {
}

onItemDoubleClick(event) {
if (this.isDefaultNetwork(event.model.item.chainId)) {
this.updateNetworks()
return
}
this.selectedNetwork = event.model.item
this.showAddWalletNetworkDialog_ = true
}
Expand Down

0 comments on commit 2d79b3c

Please sign in to comment.