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

refactor: more granular error boundaries #706

Merged
merged 1 commit into from
Jul 4, 2023
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 apps/web/src/components/widgets/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const ErrorBoundaryDebuggerChildren = (props: PropsWithChildren<{ error?: Error;

return (
<div
css={{ border: '1px dotted red' }}
css={{ 'display': 'contents', '> *': { outline: '1px dotted red' } }}
onContextMenu={event => {
event.preventDefault()
event.stopPropagation()
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/components/widgets/staking/PoolStakes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import { selectedSubstrateAccountsState } from '@domains/accounts'
import { usePoolStakes } from '@domains/nominationPools/hooks'
import { useRecoilValue } from 'recoil'
import PoolStakeItem from './PoolStakeItem'
import ErrorBoundary from '../ErrorBoundary'

const PoolStakes = () => {
const pools = usePoolStakes(useRecoilValue(selectedSubstrateAccountsState))

return (
<>
{pools?.map((pool, index) => (
<PoolStakeItem key={index} item={pool} />
<ErrorBoundary key={index} orientation="horizontal">
<PoolStakeItem item={pool} />
</ErrorBoundary>
))}
</>
)
Expand Down
12 changes: 8 additions & 4 deletions apps/web/src/components/widgets/staking/Stakes.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import SectionHeader from '@components/molecules/SectionHeader'
import StakeItem from '@components/recipes/StakeItem'
import { ChainProvider, chainsState } from '@domains/chains'
import { Button, HiddenDetails, Text } from '@talismn/ui'
import { Suspense, useId } from 'react'
import { Link } from 'react-router-dom'
import { useRecoilValue } from 'recoil'

import { ChainProvider, chainsState } from '@domains/chains'
import ErrorBoundary from '../ErrorBoundary'
import PoolStakes from './PoolStakes'
import ValidatorStakes from './ValidatorStakes'

Expand Down Expand Up @@ -59,8 +59,12 @@ const Stakes = () => {
fallback={<StakeItem.Skeleton className={skeletonId} css={{ order: 1, display: 'none' }} />}
>
<ChainProvider value={chain}>
<PoolStakes />
<ValidatorStakes />
<ErrorBoundary orientation="horizontal">
<PoolStakes />
</ErrorBoundary>
<ErrorBoundary orientation="horizontal">
<ValidatorStakes />
</ErrorBoundary>
</ChainProvider>
</Suspense>
))}
Expand Down
9 changes: 7 additions & 2 deletions apps/web/src/components/widgets/staking/ValidatorStakes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useDeriveState, useQueryMultiState, useQueryState } from '@talismn/reac
import { useMemo } from 'react'
import { useRecoilValue, useRecoilValueLoadable, waitForAll } from 'recoil'
import ValidatorStakeItem from './ValidatorStakeItem'
import ErrorBoundary from '../ErrorBoundary'

const useStakes = () => {
const accounts = useRecoilValue(selectedSubstrateAccountsState)
Expand Down Expand Up @@ -79,7 +80,9 @@ const BaseValidatorStakes = () => {
return (
<>
{stakes.map((props, index) => (
<ValidatorStakeItem key={index} {...props} />
<ErrorBoundary key={index} orientation="horizontal">
<ValidatorStakeItem {...props} />
</ErrorBoundary>
))}
</>
)
Expand All @@ -95,7 +98,9 @@ const ValidatorStakesWithFastUnstake = () => {
return (
<>
{stakes.map((props, index) => (
<ValidatorStakeItem key={index} {...props} />
<ErrorBoundary key={index} orientation="horizontal">
<ValidatorStakeItem key={index} {...props} />
</ErrorBoundary>
))}
</>
)
Expand Down
Loading