Skip to content

Commit

Permalink
fix(pools): don't unsubscribe from ActivePools (#2080)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat authored Apr 12, 2024
1 parent 44c6bcd commit 7f3d3a6
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/contexts/Pools/ActivePool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@

import { setStateWithRef } from '@w3ux/utils';
import type { ReactNode } from 'react';
import {
createContext,
useContext,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { createContext, useContext, useMemo, useRef, useState } from 'react';
import { useEffectIgnoreInitial } from '@w3ux/hooks';
import { useNetwork } from 'contexts/Network';
import { useActiveAccounts } from 'contexts/ActiveAccounts';
Expand Down Expand Up @@ -235,20 +228,14 @@ export const ActivePoolProvider = ({ children }: { children: ReactNode }) => {
}
}, [network, isReady, accountPoolIds]);

// Reset everything when `activeAccount` changes.
useEffectIgnoreInitial(() => {
ActivePoolsController.unsubscribe();
resetActivePoolId();
}, [activeAccount]);

// Reset on network change and component unmount. NOTE: ActivePoolsController also unsubscribes on
// network change; this is handled by the Api instance.
useEffect(() => {
useEffectIgnoreInitial(() => {
resetActivePoolId();
return () => {
resetActivePoolId();
};
}, [network]);
}, [activeAccount, network]);

return (
<ActivePoolContext.Provider
Expand Down

0 comments on commit 7f3d3a6

Please sign in to comment.