Skip to content

Commit

Permalink
Merge pull request #12 from threshold-network/main-cleanup
Browse files Browse the repository at this point in the history
"Main" branch clean-up

Ref: #1 
Depends on: #7 #8 #10 #11 

This pull request aggregates each partial clean-up PR (mentioned above). It's
introduced to reduce complexity of merge conflicts and allow continuous work
without blocking while waiting for partial PRs to be merged.
Moreover it's a place for general cleanup commits that couldn't be addressed to
any of the PRs.
  • Loading branch information
michalsmiarowski authored Jan 15, 2024
2 parents 3e02b42 + f568bab commit afbd6b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ const AppBody = () => {
}
}, [connector, dispatch, account])

useEffect(() => {
dispatch(fetchETHPriceUSD())
}, [dispatch])

usePosthog()
useSaveConnectedAddressToStore()
useSentry()
Expand Down
19 changes: 14 additions & 5 deletions src/components/tBTC/BridgeActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export type BridgeActivityProps = {

type BridgeActivityContextValue = {
[Property in keyof BridgeActivityProps]-?: BridgeActivityProps[Property]
} & { isBridgeHistoryEmpty: boolean }
} & {
isBridgeHistoryEmpty: boolean
}

const BridgeActivityContext = createContext<
BridgeActivityContextValue | undefined
Expand Down Expand Up @@ -87,12 +89,15 @@ export const BridgeAcivityHeader: FC<StackProps> = (props) => {
export const BridgeActivityData: FC<ListProps> = (props) => {
const { data, isBridgeHistoryEmpty, isFetching, emptyState } =
useBridgeActivityContext()
const { active } = useWeb3React()

return isFetching ? (
<BridgeActivityLoadingState />
) : (
<List spacing="1" mt="2" {...props}>
{isBridgeHistoryEmpty ? emptyState : data.map(renderActivityItem)}
{active && !isBridgeHistoryEmpty
? data.map(renderActivityItem)
: emptyState}
</List>
)
}
Expand Down Expand Up @@ -182,14 +187,18 @@ export const ActivityItemWrapper: FC = ({ children }) => (

export const BridgeActivityEmptyHistoryImg: FC = () => {
const { isBridgeHistoryEmpty, isFetching } = useBridgeActivityContext()
const epmtyHistoryImg = useColorModeValue(
const { active } = useWeb3React()
const emptyHistoryImg = useColorModeValue(
emptyHistoryImageSrcLight,
emptyHistoryImageSrcDark
)

return isBridgeHistoryEmpty && !isFetching ? (
const shouldRenderEmptyState =
!active || (isBridgeHistoryEmpty && !isFetching)

return shouldRenderEmptyState ? (
<>
<Image alt="no-history" src={epmtyHistoryImg} mx="auto" mt={16} mb={4} />
<Image alt="no-history" src={emptyHistoryImg} mx="auto" mt={16} mb={4} />
<BodyMd textAlign="center">You have no history yet.</BodyMd>
</>
) : (
Expand Down
6 changes: 3 additions & 3 deletions src/contexts/TokenContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { createContext } from "react"
import { Contract } from "@ethersproject/contracts"
import { AddressZero } from "@ethersproject/constants"
import { Contract } from "@ethersproject/contracts"
import { useWeb3React } from "@web3-react/core"
import React, { createContext } from "react"
import { featureFlags } from "../constants"
import { useKeep } from "../web3/hooks/useKeep"
import { useNu } from "../web3/hooks/useNu"
import { useT } from "../web3/hooks/useT"
Expand All @@ -11,7 +12,6 @@ import { Token } from "../enums"
import { TokenState } from "../types"
import { useTBTCTokenContract } from "../web3/hooks"
import { useTBTCv2TokenContract } from "../web3/hooks/useTBTCv2TokenContract"
import { featureFlags } from "../constants"

interface TokenContextState extends TokenState {
contract: Contract | null
Expand Down

0 comments on commit afbd6b5

Please sign in to comment.