Skip to content

Commit

Permalink
fix: history search by hash
Browse files Browse the repository at this point in the history
always defaulting to current selected account make search by hash impossible
  • Loading branch information
tien committed Dec 16, 2023
1 parent 7394360 commit cc72990
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions apps/web/src/components/widgets/history/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type HistoryProps = {
}

// TODO: lots of repetitive account look up using `encodeAnyAddress`
const InnerHistory = (props: HistoryProps) => {
const _History = (props: HistoryProps) => {
const allAccounts = useRecoilValue(accountsState)

const [items, setItems] = useState<ExtrinsicNode[]>([])
Expand Down Expand Up @@ -316,13 +316,16 @@ const InnerHistory = (props: HistoryProps) => {
}

const History = (props: HistoryProps) => {
const selectedAccounts = useRecoilValue(selectedAccountsState)
const accountsToSearch = props.accounts ?? selectedAccounts

// To invalidate component after query changes
const key = useMemo(() => JSON.stringify({ ...props, accounts: accountsToSearch }), [accountsToSearch, props])
const key = useMemo(() => JSON.stringify(props), [props])

return <InnerHistory key={key} {...props} accounts={accountsToSearch} />
return <_History key={key} {...props} />
}

export default History

export const SelectedAccountsHistory = (props: Omit<HistoryProps, 'accounts'>) => {
const accountsToSearch = useRecoilValue(selectedAccountsState)

return <History {...props} accounts={accountsToSearch} />
}
6 changes: 3 additions & 3 deletions apps/web/src/routes/portfolio/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Asset, { AssetsList, AssetsListLocked } from '@components/recipes/Asset'
import AnimatedFiatNumber from '@components/widgets/AnimatedFiatNumber'
import ErrorBoundary from '@components/widgets/ErrorBoundary'
import PortfolioAllocationGraph from '@components/widgets/PortfolioAllocationGraph'
import History from '@components/widgets/history/History'
import { SelectedAccountsHistory } from '@components/widgets/history/History'
import Stakes from '@components/widgets/staking/Stakes'
import { Eye, EyeOff } from '@talismn/icons'
import { Button, IconButton } from '@talismn/ui'
Expand Down Expand Up @@ -111,9 +111,9 @@ const AssetsOverview = () => {
}

const HistoryOverview = () => (
<div css>
<div>
<SectionHeader headlineText="History" />
<History maxCount={8} />
<SelectedAccountsHistory maxCount={8} />
<div css={{ display: 'flex' }}>
<Button variant="secondary" as={Link} to="history" css={{ marginTop: '1.8rem', marginLeft: 'auto' }}>
View all history
Expand Down

0 comments on commit cc72990

Please sign in to comment.