Skip to content

Commit 491a509

Browse files
committed
Add ID_VERSION_NOT_SUPPORTED message on loaderMsg when version not supported
lint
1 parent 19b5c3c commit 491a509

2 files changed

Lines changed: 61 additions & 12 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const ID_SHOW_ADDITIONAL_SETTINGS = 'ID_SHOW_ADDITIONAL_SETTINGS'
1414
export const ID_BUY = 'ID_BUY'
1515
export const ID_SELL = 'ID_SELL'
1616
export const ID_NOT_SUPPORTED = 'ID_NOT_SUPPORTED'
17+
export const ID_VERSION_NOT_SUPPORTED = 'ID_VERSION_NOT_SUPPORTED'
1718
export const ID_CONNECTION_FAILED = 'ID_CONNECTION_FAILED'
1819
export const ID_ORDER_PREVIEW = 'ID_ORDER_PREVIEW'
1920
export const ID_CALCULATING = 'ID_CALCULATING'
@@ -111,6 +112,7 @@ export const enUS: Locale = {
111112
[ID_BUY]: 'Buy',
112113
[ID_SELL]: 'Sell',
113114
[ID_NOT_SUPPORTED]: '{{ asset }} is not supported',
115+
[ID_VERSION_NOT_SUPPORTED]: 'version: {{ version }} of {{ asset }} is not supported',
114116
[ID_CONNECTION_FAILED]: 'Connection to dex server failed. You can close dexc and try again later or wait for it to reconnect.',
115117
[ID_ORDER_PREVIEW]: 'Total: {{ total }} {{ asset }}',
116118
[ID_CALCULATING]: 'calculating...',

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

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -604,27 +604,74 @@ export default class MarketsPage extends BasePage {
604604
/* assetsAreSupported is true if all the assets of the current market are
605605
* supported
606606
*/
607-
assetsAreSupported () {
608-
const [base, quote] = [this.market.base, this.market.quote]
609-
if (!base || !quote) return false
607+
assetsAreSupported (): {
608+
isSupported: boolean;
609+
text: string;
610+
} {
611+
const { market } = this
612+
const [base, quote] = [market.base, market.quote]
613+
if (!base || !quote) {
614+
const symbol = market.base ? market.quoteCfg.symbol : market.baseCfg.symbol
615+
return {
616+
isSupported: false,
617+
text: intl.prep(intl.ID_NOT_SUPPORTED, { asset: symbol.toUpperCase() })
618+
}
619+
}
610620
const { baseCfg, quoteCfg } = this.market
611621
// check if versions are supported. If asset is a token, we check if its
612622
// parent supports the version.
623+
let text = ''
613624
if (base.token && quote.token) {
614625
const bParent = app().assets[base.token.parentID]
615626
const qParent = app().assets[quote.token.parentID]
616-
return qParent.info?.versions.includes(quoteCfg.version) && bParent.info?.versions.includes(baseCfg.version)
627+
if (!bParent.info?.versions.includes(baseCfg.version)) {
628+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: bParent.symbol.toUpperCase(), version: baseCfg.version + '' })
629+
}
630+
if (!qParent.info?.versions.includes(quoteCfg.version)) {
631+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: qParent.symbol.toUpperCase(), version: quoteCfg.version + '' })
632+
}
633+
return {
634+
isSupported: !!qParent.info?.versions.includes(quoteCfg.version) && !!bParent.info?.versions.includes(baseCfg.version),
635+
text
636+
}
617637
}
618638
if (base.token) {
619639
const bParent = app().assets[base.token.parentID]
620-
return quote.info?.versions.includes(quoteCfg.version) && bParent.info?.versions.includes(baseCfg.version)
640+
if (!bParent.info?.versions.includes(baseCfg.version)) {
641+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: bParent.symbol.toUpperCase(), version: baseCfg.version + '' })
642+
}
643+
if (!quote.info?.versions.includes(quoteCfg.version)) {
644+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: quote.symbol.toUpperCase(), version: quoteCfg.version + '' })
645+
}
646+
return {
647+
isSupported: !!quote.info?.versions.includes(quoteCfg.version) && !!bParent.info?.versions.includes(baseCfg.version),
648+
text
649+
}
621650
}
622651
if (quote.token) {
623652
const qParent = app().assets[quote.token.parentID]
624-
return base.info?.versions.includes(baseCfg.version) && qParent.info?.versions.includes(quoteCfg.version)
653+
if (!base.info?.versions.includes(baseCfg.version)) {
654+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: base.symbol.toUpperCase(), version: baseCfg.version + '' })
655+
}
656+
if (!qParent.info?.versions.includes(quoteCfg.version)) {
657+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: quote.symbol.toUpperCase(), version: quoteCfg.version + '' })
658+
}
659+
return {
660+
isSupported: !!base.info?.versions.includes(baseCfg.version) && !!qParent.info?.versions.includes(quoteCfg.version),
661+
text
662+
}
625663
}
626664
// if none them are token, just check if own asset is supported.
627-
return base.info?.versions.includes(baseCfg.version) && quote.info?.versions.includes(quoteCfg.version)
665+
if (!base.info?.versions.includes(baseCfg.version)) {
666+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: base.symbol.toUpperCase(), version: baseCfg.version + '' })
667+
}
668+
if (!quote.info?.versions.includes(quoteCfg.version)) {
669+
text = intl.prep(intl.ID_VERSION_NOT_SUPPORTED, { asset: quote.symbol.toUpperCase(), version: quoteCfg.version + '' })
670+
}
671+
return {
672+
isSupported: !!base.info?.versions.includes(baseCfg.version) && !!quote.info?.versions.includes(quoteCfg.version),
673+
text
674+
}
628675
}
629676

630677
/*
@@ -660,7 +707,7 @@ export default class MarketsPage extends BasePage {
660707
// and ready for trading the form should show up.
661708
Doc.hide(page.orderForm, page.orderTypeBttns)
662709
const feePaid = !this.hasFeePending()
663-
const assetsAreSupported = this.assetsAreSupported()
710+
const assetsAreSupported = this.assetsAreSupported().isSupported
664711
const { base, quote } = this.market
665712
const hasWallets = base && app().assets[base.id].wallet && quote && app().assets[quote.id].wallet
666713

@@ -673,15 +720,15 @@ export default class MarketsPage extends BasePage {
673720
* supported
674721
*/
675722
setLoaderMsgVisibility () {
676-
const { page, market } = this
723+
const { page } = this
677724

678-
if (this.assetsAreSupported()) {
725+
const { isSupported, text } = this.assetsAreSupported()
726+
if (isSupported) {
679727
// make sure to hide the loader msg
680728
Doc.hide(page.loaderMsg)
681729
return
682730
}
683-
const symbol = market.base ? market.quoteCfg.symbol : market.baseCfg.symbol
684-
page.loaderMsg.textContent = intl.prep(intl.ID_NOT_SUPPORTED, { asset: symbol.toUpperCase() })
731+
page.loaderMsg.textContent = text
685732
Doc.show(page.loaderMsg)
686733
Doc.hide(page.noWallet)
687734
}

0 commit comments

Comments
 (0)