From 26594015ce702f41dad39326d80206def6eca72b Mon Sep 17 00:00:00 2001 From: Anthony Date: Sun, 18 Jul 2021 22:06:14 +0200 Subject: [PATCH] fix flow errors --- ui/component/walletTipAmountSelector/view.jsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ui/component/walletTipAmountSelector/view.jsx b/ui/component/walletTipAmountSelector/view.jsx index 0e154c11d..a0246ca47 100644 --- a/ui/component/walletTipAmountSelector/view.jsx +++ b/ui/component/walletTipAmountSelector/view.jsx @@ -34,7 +34,7 @@ type Props = { uri: string, onTipErrorChange: (string) => void, activeTab: string, - shouldDisableReviewButton: (string) => void + shouldDisableReviewButton: (boolean) => void }; function WalletTipAmountSelector(props: Props) { @@ -45,24 +45,22 @@ function WalletTipAmountSelector(props: Props) { const [canReceiveFiatTip, setCanReceiveFiatTip] = React.useState(); // dont persist because it needs to be calc'd per creator const [hasCardSaved, setHasSavedCard] = usePersistedState('comment-support:hasCardSaved', false); + // if it's fiat but there's no card saved OR the creator can't receive fiat tips + const shouldDisableFiatSelectors = (activeTab === TAB_FIAT && (!hasCardSaved || !canReceiveFiatTip)); + /** * whether tip amount selection/review functionality should be disabled * @param [amount] LBC amount (optional) * @returns {boolean} */ function shouldDisableAmountSelector(amount) { - - const shouldDisable = - // if it's LBC but the balance isn't enough - (amount > balance && activeTab !== TAB_FIAT) || - // if it's fiat but there's no card saved OR the creator can't receive fiat tips - (activeTab === TAB_FIAT && (!hasCardSaved || !canReceiveFiatTip)); - - shouldDisableReviewButton(shouldDisable); - - return shouldDisable; + // if it's LBC but the balance isn't enough, or fiat conditions met + // $FlowFixMe + return (amount > balance && activeTab !== TAB_FIAT) || shouldDisableFiatSelectors; } + shouldDisableReviewButton(shouldDisableFiatSelectors); + // setup variables for tip API let channelClaimId, tipChannelName; // if there is a signing channel it's on a file