Skip to content

Commit

Permalink
HF 30 - Fix proxifying of NFT prices, also improve proxifying UIA ima…
Browse files Browse the repository at this point in the history
…ges safety
  • Loading branch information
1aerostorm committed Jun 7, 2024
1 parent cf3d729 commit 3a4fe9b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
13 changes: 0 additions & 13 deletions app/components/elements/market/MarketPair.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { api, libs } from 'golos-lib-js'
import PagedDropdownMenu from 'app/components/elements/PagedDropdownMenu'
import Icon from 'app/components/elements/Icon'
import { getAssetMeta, getTradablesFor } from 'app/utils/market/utils'
import { proxifyNFTImage } from 'app/utils/ProxifyUrl'

class MarketPair extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -160,9 +159,6 @@ class MarketPair extends React.Component {
const { symbol, } = asset
const { style, dataset } = this.makeItem(asset, depths1, maxDepth1)
let { image_url } = asset
if (image_url) {
image_url = proxifyNFTImage(image_url)
}
return {
key: symbol, value: symbol,
label: (<span className={'Market__bg-' + symbol} style={{lineHeight: '28px'}} data-usd={dataset.market_usd}><img src={image_url} width='28' height='28'/>&nbsp;&nbsp;&nbsp;{symbol}</span>),
Expand All @@ -178,9 +174,6 @@ class MarketPair extends React.Component {
const { symbol } = asset
const { style, dataset } = this.makeItem(asset, depths2, maxDepth2)
let { image_url } = asset
if (image_url) {
image_url = proxifyNFTImage(image_url)
}
return {
key: symbol, value: symbol,
label: (<span className={'Market__bg-' + symbol} style={{lineHeight: '28px'}} data-usd={dataset.market_usd}><img src={image_url} width='28' height='28'/>&nbsp;&nbsp;&nbsp;{symbol}</span>),
Expand All @@ -193,9 +186,6 @@ class MarketPair extends React.Component {
}

let sym1Image = getAssetMeta(assets[sym1]).image_url
if (sym1Image) {
sym1Image = proxifyNFTImage(sym1Image)
}
let left = <div style={{ display: 'inline-block' }}>
<div className='MarketPair__label'>{label1}</div>
<PagedDropdownMenu el='div' className='top-most' items={symbols1} perPage={itemsPerPage}
Expand All @@ -210,9 +200,6 @@ class MarketPair extends React.Component {
</div>

let sym2Image = getAssetMeta(assets[sym2]).image_url
if (sym2Image) {
sym2Image = proxifyNFTImage(sym2Image)
}
let right = <div style={{ display: 'inline-block' }}>
<div className='MarketPair__label'>{label2}</div>
<PagedDropdownMenu el='div' className='top-most' items={symbols2} perPage={itemsPerPage}
Expand Down
10 changes: 2 additions & 8 deletions app/components/pages/Rating.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ class Rating extends React.Component {

const link = '/market/' + sym1 + '/' + sym2

let image_url = getAssetMeta(asset).image_url
if (image_url) {
image_url = proxifyNFTImage(image_url)
}
const image_url = getAssetMeta(asset).image_url

return <Link to={link}><div className='Pair PairTop1'>
<div className='Pair__logo'>
Expand Down Expand Up @@ -178,10 +175,7 @@ class Rating extends React.Component {

const link = '/market/' + sym1 + '/' + sym2

let image_url = getAssetMeta(asset).image_url
if (image_url) {
image_url = proxifyNFTImage(image_url)
}
const image_url = getAssetMeta(asset).image_url

pairItems.push(<Link to={link} key='link'><div className='Pair'>
<div className='Pair__logo'>
Expand Down
2 changes: 1 addition & 1 deletion app/utils/ProxifyUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const proxifyImageUrl = (url, dimensions = '0x0') => {
export const proxifyNFTImage = (url) => {
if (!$STM_Config)
return url
if (!url.startsWith('http'))
if (!url || !url.startsWith || !url.startsWith('http'))
return url
let prefix = ''
if ($STM_Config.images.img_proxy_prefix && $STM_Config.images.use_img_proxy !== false) prefix += fixHost($STM_Config.images.img_proxy_prefix) + '/orig/png/'
Expand Down
4 changes: 4 additions & 0 deletions app/utils/market/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { proxifyNFTImage } from 'app/utils/ProxifyUrl'

function roundUp(num, precision) {
let satoshis = parseFloat(num) * Math.pow(10, precision);

Expand Down Expand Up @@ -73,6 +75,8 @@ function getAssetMeta(asset) {
res.image_url = '/images/golos.png'
} else if (sym === 'GBG') {
res.image_url = '/images/gold-golos.png'
} else {
res.image_url = proxifyNFTImage(res.image_url)
}
return res
}
Expand Down

0 comments on commit 3a4fe9b

Please sign in to comment.