1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Preventing swaps data re-fetch when navigating back to home screeen (#12370)

This commit is contained in:
ryanml 2021-10-18 10:31:34 -07:00 committed by GitHub
parent 2712048c0e
commit 308cca1897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,6 +118,7 @@ export default function Swap() {
const chainId = useSelector(getCurrentChainId);
const isSwapsChain = useSelector(getIsSwapsChain);
const useNewSwapsApi = useSelector(getUseNewSwapsApi);
const prevUseNewSwapsApi = useRef(useNewSwapsApi);
const networkAndAccountSupports1559 = useSelector(
checkNetworkAndAccountSupports1559,
);
@ -193,7 +194,7 @@ export default function Swap() {
// eslint-disable-next-line
useEffect(() => {
if (isFeatureFlagLoaded) {
if (isFeatureFlagLoaded && prevUseNewSwapsApi.current === useNewSwapsApi) {
fetchTokens(chainId, useNewSwapsApi)
.then((tokens) => {
dispatch(setSwapsTokens(tokens));
@ -214,6 +215,7 @@ export default function Swap() {
dispatch(prepareToLeaveSwaps());
};
}
prevUseNewSwapsApi.current = useNewSwapsApi;
}, [
dispatch,
chainId,