Skip to content

Commit a6f097e

Browse files
authored
ui: fix tx popup explorer links (#3573)
If multiple popups were being opened in succession, the subsequent popups would show the initial popup's explorer link.
1 parent 2370081 commit a6f097e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

client/webserver/site/src/js/wallets.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,7 @@ export default class WalletsPage extends BasePage {
19561956
txHistoryRow (tx: WalletTransaction, assetID: number): PageElement {
19571957
const row = this.page.txHistoryRowTmpl.cloneNode(true) as PageElement
19581958
row.dataset.txid = tx.id
1959-
Doc.bind(row, 'click', () => this.showTxDetailsPopup(tx))
1959+
Doc.bind(row, 'click', () => this.showTxDetailsPopup(tx, assetID))
19601960
this.updateTxHistoryRow(row, tx, assetID)
19611961
return row
19621962
}
@@ -1968,19 +1968,21 @@ export default class WalletsPage extends BasePage {
19681968
return row
19691969
}
19701970

1971-
setTxDetailsPopupElements (tx: WalletTransaction) {
1971+
setTxDetailsPopupElements (tx: WalletTransaction, assetID: number) {
19721972
const page = this.page
19731973

19741974
// Block explorer
1975-
const assetExplorer = CoinExplorers[this.selectedWalletID]
1975+
page.txViewBlockExplorer.removeAttribute('href')
1976+
const explorerAssetID = app().assets[assetID]?.token?.parentID ?? assetID
1977+
const assetExplorer = CoinExplorers[explorerAssetID]
19761978
if (assetExplorer && assetExplorer[net]) {
19771979
const explorerID = (tx.isRelay && tx.relayTxID) ? tx.relayTxID : tx.id
19781980
page.txViewBlockExplorer.href = assetExplorer[net](explorerID)
19791981
}
19801982

19811983
// Tx type
19821984
let txType = txTypeString(tx.type)
1983-
if (tx.tokenID && tx.tokenID !== this.selectedWalletID) {
1985+
if (tx.tokenID && tx.tokenID !== assetID) {
19841986
const tokenSymbol = app().assets[tx.tokenID].symbol.split('.')[0].toUpperCase()
19851987
txType = `${tokenSymbol} ${txType}`
19861988
}
@@ -1992,18 +1994,18 @@ export default class WalletsPage extends BasePage {
19921994
if (noAmtTxTypes.includes(tx.type)) {
19931995
Doc.hide(page.txDetailsAmtSection)
19941996
} else {
1995-
let assetID = this.selectedWalletID
1996-
if (tx.tokenID) assetID = tx.tokenID
1997+
let amountAssetID = assetID
1998+
if (tx.tokenID) amountAssetID = tx.tokenID
19971999
Doc.show(page.txDetailsAmtSection)
1998-
const ui = app().unitInfo(assetID)
2000+
const ui = app().unitInfo(amountAssetID)
19992001
const amt = Doc.formatCoinValue(tx.amount, ui)
20002002
const [s, c] = txTypeSignAndClass(tx.type)
20012003
page.txDetailsAmount.textContent = `${s}${amt} ${ui.conventional.unit}`
20022004
if (c !== '') page.txDetailsAmount.classList.add(c)
20032005
}
20042006

20052007
// Fee
2006-
let feeAsset = this.selectedWalletID
2008+
let feeAsset = assetID
20072009
if (tx.tokenID !== undefined) {
20082010
const asset = app().assets[tx.tokenID]
20092011
if (asset.token) {
@@ -2072,9 +2074,9 @@ export default class WalletsPage extends BasePage {
20722074
}
20732075
}
20742076

2075-
showTxDetailsPopup (tx: WalletTransaction) {
2077+
showTxDetailsPopup (tx: WalletTransaction, assetID = this.txHistory.assetID) {
20762078
this.currTx = tx
2077-
this.setTxDetailsPopupElements(tx)
2079+
this.setTxDetailsPopupElements(tx, assetID)
20782080
this.forms.show(this.page.txDetails)
20792081
}
20802082

0 commit comments

Comments
 (0)