From e09176bd74f4f78b1d8c2fb2779c77967a9f1c5d Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Thu, 15 Feb 2024 12:00:58 +0700 Subject: [PATCH] fix: fix manage nominations refresh (#1950) --- src/library/GenerateNominations/index.tsx | 2 +- src/library/ValidatorList/index.tsx | 42 +++++++++++------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/library/GenerateNominations/index.tsx b/src/library/GenerateNominations/index.tsx index dec926d037..997ebd7399 100644 --- a/src/library/GenerateNominations/index.tsx +++ b/src/library/GenerateNominations/index.tsx @@ -85,7 +85,7 @@ export const GenerateNominations = ({ setMethod('manual'); } } - }, [activeAccount]); + }, [activeAccount, defaultNominations]); // refetch if fetching is triggered useEffect(() => { diff --git a/src/library/ValidatorList/index.tsx b/src/library/ValidatorList/index.tsx index ccab7612f5..fe007d6c0c 100644 --- a/src/library/ValidatorList/index.tsx +++ b/src/library/ValidatorList/index.tsx @@ -184,20 +184,6 @@ export const ValidatorListInner = ({ ListItemsPerPage ); - // Reset list when validator list changes. - useEffect(() => { - if (alwaysRefetchValidators) { - if ( - JSON.stringify(initialValidators.map((v) => v.address)) !== - JSON.stringify(validatorsDefault.map((v) => v.address)) - ) { - setFetched(false); - } - } else { - setFetched(false); - } - }, [initialValidators, nominator]); - // handle filter / order update const handleValidatorsFilterUpdate = ( filteredValidators = Object.assign(validatorsDefault) @@ -251,6 +237,13 @@ export const ValidatorListInner = ({ setSearchTerm('validators', newValue); }; + // Handle validator list bootstrapping. + const setupValidatorList = () => { + setValidatorsDefault(prepareInitialValidators()); + setValidators(prepareInitialValidators()); + setFetched(true); + }; + // Set default filters. Should re-render if era stakers re-syncs as era points effect the // performance order. useEffect(() => { @@ -286,19 +279,26 @@ export const ValidatorListInner = ({ }; }, [syncing]); - // Handle validator list bootstrapping. - const setupValidatorList = () => { - setValidatorsDefault(prepareInitialValidators()); - setValidators(prepareInitialValidators()); - setFetched(true); - }; + // Reset list when validator list changes. + useEffect(() => { + if (alwaysRefetchValidators) { + if ( + JSON.stringify(initialValidators.map((v) => v.address)) !== + JSON.stringify(validatorsDefault.map((v) => v.address)) + ) { + setFetched(false); + } + } else { + setFetched(false); + } + }, [initialValidators, nominator]); // Configure validator list when network is ready to fetch. useEffect(() => { if (isReady && isNotZero(activeEra.index)) { setupValidatorList(); } - }, [isReady, activeEra.index, syncing]); + }, [isReady, activeEra.index, syncing, fetched]); // Control render throttle. useEffect(() => {