Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handling of token page throttling #1100

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/containers/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { Transaction } from '../Transactions'
import { Network } from '../Network'
import { Validator } from '../Validators'
import { PayString } from '../PayStrings'
import Token from '../Token'
import { Token } from '../Token'
import { NFT } from '../NFT/NFT'
import { legacyRedirect } from './legacyRedirects'
import { useCustomNetworks } from '../shared/hooks'
Expand Down
4 changes: 0 additions & 4 deletions src/containers/Token/TokenHeader/actionTypes.js

This file was deleted.

43 changes: 0 additions & 43 deletions src/containers/Token/TokenHeader/actions.js

This file was deleted.

60 changes: 8 additions & 52 deletions src/containers/Token/TokenHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { useContext, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { loadTokenState } from './actions'
import { Loader } from '../../shared/components/Loader'
import './styles.scss'
import { localizeNumber, formatLargeNumber } from '../../shared/utils'
import SocketContext from '../../shared/SocketContext'
import Currency from '../../shared/components/Currency'
import { Account } from '../../shared/components/Account'
import DomainLink from '../../shared/components/DomainLink'
import { TokenTableRow } from '../../shared/components/TokenTableRow'
import { useLanguage } from '../../shared/hooks'
import { LEDGER_ROUTE, TRANSACTION_ROUTE } from '../../App/routes'
import { RouteLink } from '../../shared/routing'
import { TokenData } from '../../../rippled/token'

const CURRENCY_OPTIONS = {
style: 'currency',
Expand All @@ -23,44 +18,21 @@ const CURRENCY_OPTIONS = {
}

interface TokenHeaderProps {
loading: boolean
accountId: string
currency: string
data: {
balance: string
reserve: number
sequence: number
rate: number
obligations: string
domain: string
emailHash: string
previousLedger: number
previousTxn: string
flags: string[]
}
actions: {
loadTokenState: typeof loadTokenState
}
data: TokenData
}

const TokenHeader = ({
actions,
export const TokenHeader = ({
accountId,
currency,
data,
loading,
}: TokenHeaderProps) => {
const language = useLanguage()
const { t } = useTranslation()
const rippledSocket = useContext(SocketContext)

useEffect(() => {
actions.loadTokenState(currency, accountId, rippledSocket)
}, [accountId, actions, currency, rippledSocket])
const { domain, rate, emailHash, previousLedger, previousTxn } = data

const renderDetails = () => {
const { domain, rate, emailHash, previousLedger, previousTxn } = data

const prevTxn = previousTxn && previousTxn.replace(/(.{20})..+/, '$1...')
const abbrvEmail = emailHash && emailHash.replace(/(.{20})..+/, '$1...')
return (
Expand Down Expand Up @@ -156,7 +128,9 @@ const TokenHeader = ({
language,
CURRENCY_OPTIONS,
)
const obligationsBalance = formatLargeNumber(Number.parseFloat(obligations))
const obligationsBalance = formatLargeNumber(
Number.parseFloat(obligations || '0'),
)

return (
<div className="section header-container">
Expand Down Expand Up @@ -201,7 +175,6 @@ const TokenHeader = ({
)
}

const { emailHash } = data
return (
<div className="box token-header">
<div className="section box-header">
Expand All @@ -213,24 +186,7 @@ const TokenHeader = ({
/>
)}
</div>
<div className="box-content">
{loading ? <Loader /> : renderHeaderContent()}
</div>
<div className="box-content">{renderHeaderContent()}</div>
</div>
)
}

export default connect(
(state: any) => ({
loading: state.tokenHeader.loading,
data: state.tokenHeader.data,
}),
(dispatch) => ({
actions: bindActionCreators(
{
loadTokenState,
},
dispatch,
),
}),
)(TokenHeader)
33 changes: 0 additions & 33 deletions src/containers/Token/TokenHeader/reducer.js

This file was deleted.

108 changes: 0 additions & 108 deletions src/containers/Token/TokenHeader/test/actions.test.js

This file was deleted.

79 changes: 0 additions & 79 deletions src/containers/Token/TokenHeader/test/reducer.test.js

This file was deleted.

Loading
Loading