diff --git a/src/app/components/Delegations/Delegations.tsx b/src/app/components/Delegations/Delegations.tsx index 1da4ad88..60872348 100644 --- a/src/app/components/Delegations/Delegations.tsx +++ b/src/app/components/Delegations/Delegations.tsx @@ -57,7 +57,8 @@ export const Delegations: React.FC = ({ const [txID, setTxID] = useState(""); const [modalMode, setModalMode] = useState(); const { showError } = useError(); - const [disableModalClose, setDisableModalClose] = useState(false); + const [isAwaitingWalletResponse, setisAwaitingWalletResponse] = + useState(false); // Local storage state for intermediate delegations (withdrawing, unbonding) const intermediateDelegationsLocalStorageKey = @@ -110,7 +111,7 @@ export const Delegations: React.FC = ({ const handleUnbond = async (id: string) => { try { // Prevent the modal from closing - setDisableModalClose(true); + setisAwaitingWalletResponse(true); // Sign the unbonding transaction const { delegation } = await signUnbondingTx( id, @@ -133,7 +134,7 @@ export const Delegations: React.FC = ({ setModalOpen(false); setTxID(""); setModalMode(undefined); - setDisableModalClose(false); + setisAwaitingWalletResponse(false); } }; @@ -142,7 +143,7 @@ export const Delegations: React.FC = ({ const handleWithdraw = async (id: string) => { try { // Prevent the modal from closing - setDisableModalClose(true); + setisAwaitingWalletResponse(true); // Sign the withdrawal transaction const { delegation } = await signWithdrawalTx( id, @@ -168,7 +169,7 @@ export const Delegations: React.FC = ({ setModalOpen(false); setTxID(""); setModalMode(undefined); - setDisableModalClose(false); + setisAwaitingWalletResponse(false); } }; @@ -306,7 +307,7 @@ export const Delegations: React.FC = ({ : handleWithdraw(txID); }} mode={modalMode} - disableModalClose={disableModalClose} + isAwaitingWalletResponse={isAwaitingWalletResponse} /> )} diff --git a/src/app/components/Modals/GeneralModal.tsx b/src/app/components/Modals/GeneralModal.tsx index d7a85c5e..40071cf1 100644 --- a/src/app/components/Modals/GeneralModal.tsx +++ b/src/app/components/Modals/GeneralModal.tsx @@ -8,7 +8,7 @@ interface GeneralModalProps { small?: boolean; children: ReactNode; className?: string; - disableModalClose?: boolean; + isAwaitingWalletResponse?: boolean; closeOnEsc?: boolean; } @@ -18,7 +18,7 @@ export const GeneralModal: React.FC = ({ children, small, className = "", - disableModalClose, + isAwaitingWalletResponse, closeOnEsc = true, }) => { const modalRef = useRef(null); @@ -51,7 +51,7 @@ export const GeneralModal: React.FC = ({ showCloseIcon={false} blockScroll={false} closeOnEsc={closeOnEsc} - closeOnOverlayClick={!disableModalClose} + closeOnOverlayClick={!isAwaitingWalletResponse} > {children} diff --git a/src/app/components/Modals/PreviewModal.tsx b/src/app/components/Modals/PreviewModal.tsx index 94f8d289..c6b2df74 100644 --- a/src/app/components/Modals/PreviewModal.tsx +++ b/src/app/components/Modals/PreviewModal.tsx @@ -21,7 +21,7 @@ interface PreviewModalProps { unbondingTimeBlocks: number; confirmationDepth: number; unbondingFeeSat: number; - disableModalClose: boolean; + isAwaitingWalletResponse: boolean; } export const PreviewModal: React.FC = ({ @@ -36,7 +36,7 @@ export const PreviewModal: React.FC = ({ feeRate, confirmationDepth, unbondingFeeSat, - disableModalClose, + isAwaitingWalletResponse, }) => { const cardStyles = "card border bg-base-300 p-4 text-sm dark:border-0 dark:bg-base-200"; @@ -47,14 +47,14 @@ export const PreviewModal: React.FC = ({

Preview

@@ -121,7 +121,7 @@ export const PreviewModal: React.FC = ({ "Pending" stake is only accessible through the device it was created.

- {disableModalClose ? ( + {isAwaitingWalletResponse ? ( ) : (
diff --git a/src/app/components/Modals/UnbondWithdrawModal.tsx b/src/app/components/Modals/UnbondWithdrawModal.tsx index af93ee76..dfde06b9 100644 --- a/src/app/components/Modals/UnbondWithdrawModal.tsx +++ b/src/app/components/Modals/UnbondWithdrawModal.tsx @@ -20,7 +20,7 @@ interface PreviewModalProps { onClose: (value: boolean) => void; onProceed: () => void; mode: MODE; - disableModalClose: boolean; + isAwaitingWalletResponse: boolean; } export const UnbondWithdrawModal: React.FC = ({ @@ -30,7 +30,7 @@ export const UnbondWithdrawModal: React.FC = ({ onClose, onProceed, mode, - disableModalClose, + isAwaitingWalletResponse, }) => { const { coinName, networkName } = getNetworkConfig(); @@ -67,21 +67,21 @@ export const UnbondWithdrawModal: React.FC = ({ open={open} onClose={onClose} closeOnEsc={false} - disableModalClose={disableModalClose} + isAwaitingWalletResponse={isAwaitingWalletResponse} small >

{title}

{content}

- {disableModalClose ? ( + {isAwaitingWalletResponse ? ( ) : (
diff --git a/src/app/components/Staking/Staking.tsx b/src/app/components/Staking/Staking.tsx index 994a381f..15738cfe 100644 --- a/src/app/components/Staking/Staking.tsx +++ b/src/app/components/Staking/Staking.tsx @@ -91,7 +91,8 @@ export const Staking: React.FC = ({ useState(); // Selected fee rate, comes from the user input const [selectedFeeRate, setSelectedFeeRate] = useState(0); - const [disableModalClose, setDisableModalClose] = useState(false); + const [isAwaitingWalletResponse, setIsAwaitingWalletResponse] = + useState(false); const [previewModalOpen, setPreviewModalOpen] = useState(false); const [resetFormInputs, setResetFormInputs] = useState(false); const [feedbackModal, setFeedbackModal] = useState<{ @@ -227,7 +228,7 @@ export const Staking: React.FC = ({ ]); const handleResetState = () => { - setDisableModalClose(false); + setIsAwaitingWalletResponse(false); setFinalityProvider(undefined); setStakingAmountSat(0); setStakingTimeBlocks(0); @@ -246,7 +247,7 @@ export const Staking: React.FC = ({ const handleSign = async () => { try { // Prevent the modal from closing - setDisableModalClose(true); + setIsAwaitingWalletResponse(true); // Initial validation if (!btcWallet) throw new Error("Wallet is not connected"); if (!address) throw new Error("Address is not set"); @@ -297,7 +298,7 @@ export const Staking: React.FC = ({ }, }); } finally { - setDisableModalClose(false); + setIsAwaitingWalletResponse(false); } }; @@ -665,7 +666,7 @@ export const Staking: React.FC = ({ feeRate={feeRate} unbondingTimeBlocks={unbondingTime} unbondingFeeSat={unbondingFeeSat} - disableModalClose={disableModalClose} + isAwaitingWalletResponse={isAwaitingWalletResponse} /> )}