Skip to content

Commit

Permalink
[DDW] Fix stake slider pools selection
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaglumac committed Oct 27, 2020
1 parent 4169830 commit 103e4dd
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@ export default class StakePoolsRanking extends Component<Props, State> {
const selectedWallet = wallets.find(
(wallet) => wallet.id === selectedWalletId
);
const hasSelectedWallet = !!selectedWallet;
const isAllWalletsSelected = selectedWalletId === ALL_WALLETS_SELECTION_ID;
const wasSelectedWalletChanged =
selectedWalletId !== selectedDelegationWalletId;

if (
selectedWalletId === selectedDelegationWalletId ||
(selectedWalletId !== ALL_WALLETS_SELECTION_ID && !selectedWallet)
) {
// Prevent ranking stake pools if we don't have data for the selected wallet ready
if (wasSelectedWalletChanged && !isAllWalletsSelected && !hasSelectedWallet)
return;
}

let amountValue = 0;
let sliderValue = 0;

if (selectedWalletId === ALL_WALLETS_SELECTION_ID) {
amountValue = Math.min(
getAllAmounts(wallets).toNumber(),
Expand All @@ -205,6 +205,11 @@ export default class StakePoolsRanking extends Component<Props, State> {
}
amountValue = Math.max(amountValue, MIN_DELEGATION_FUNDS);
sliderValue = Math.round(Math.log(amountValue) * RANKING_SLIDER_RATIO);
const hasSliderValueChanged = sliderValue !== this.state.sliderValue;

// Prevent ranking stake pools if selected wallet and slider value remains unchanged
if (!wasSelectedWalletChanged && !hasSliderValueChanged) return;

const displayValue = formattedWalletAmount(
new BigNumber(amountValue),
false
Expand Down

0 comments on commit 103e4dd

Please sign in to comment.