Skip to content

Commit

Permalink
fix: fix manage nominations refresh (#1950)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat authored Feb 15, 2024
1 parent fd436a7 commit e09176b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/library/GenerateNominations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const GenerateNominations = ({
setMethod('manual');
}
}
}, [activeAccount]);
}, [activeAccount, defaultNominations]);

// refetch if fetching is triggered
useEffect(() => {
Expand Down
42 changes: 21 additions & 21 deletions src/library/ValidatorList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit e09176b

Please sign in to comment.