Skip to content

Commit

Permalink
fix: reload pool data on address change correctly (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen Offerijns authored Dec 11, 2020
1 parent d58273d commit f1086c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 0 additions & 3 deletions tinlake-ui/containers/Investment/View/TrancheOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const TrancheOverview: React.FC<Props> = (props: Props) => {
)}
</Heading>
</Box>

<Table>
<TableBody>
<TableRow>
Expand All @@ -147,7 +146,6 @@ const TrancheOverview: React.FC<Props> = (props: Props) => {
</TableRow>
</TableBody>
</Table>

{trancheData?.inMemberlist === true && (
<>
{card === 'home' && (
Expand Down Expand Up @@ -213,7 +211,6 @@ const TrancheOverview: React.FC<Props> = (props: Props) => {
)}
</>
)}

{trancheData?.inMemberlist === false && (
<Info>
<Heading level="6" margin={{ bottom: 'xsmall' }}>
Expand Down
13 changes: 10 additions & 3 deletions tinlake-ui/ducks/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,26 @@ export default function reducer(state: PoolState = initialState, action: AnyActi

let watcher: any = createWatcher([], multicallConfig)

let prevAddress: string | undefined = undefined

export function loadPool(tinlake: any): ThunkAction<Promise<void>, PoolState, undefined, Action> {
return async (dispatch, getState) => {
const address = await tinlake.signer?.getAddress()

const poolId = tinlake.contractAddresses.ROOT_CONTRACT
if ((getState() as any).pool.poolId === poolId) {

// Dont load data again for the same pool and address combination
if ((getState() as any).pool.poolId === poolId && prevAddress === address) {
return
}

// Save the address so we do reload the data if the address changes
prevAddress = address

dispatch({ poolId, type: LOAD_POOL })

const toBN = (val: BigNumber) => new BN(val.toString())

const address = await tinlake.signer?.getAddress()

const addressWatchers = address
? [
{
Expand Down

0 comments on commit f1086c0

Please sign in to comment.