From 8e4bd926a73b3002946c5c979b6750bee2a51fde Mon Sep 17 00:00:00 2001 From: saml33 <30796577+saml33@users.noreply.github.com> Date: Tue, 11 May 2021 06:32:21 +1000 Subject: [PATCH] improve alert modal buttons and fix alerts not loading on connect wallet (#8) --- components/AlertsModal.tsx | 57 ++++++++++++++++++++++++++------------ hooks/useWallet.tsx | 2 +- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/components/AlertsModal.tsx b/components/AlertsModal.tsx index f1db7d8..f98b4c7 100644 --- a/components/AlertsModal.tsx +++ b/components/AlertsModal.tsx @@ -111,12 +111,22 @@ const AlertsModal: FunctionComponent = ({ copyToClipboard(code) } - const handleCloseTgCodeView = () => { + const handleNewFromTgCode = () => { + set((s) => { + s.tgCode = null + }) resetForm() - setShowTgCode(false) } - const handleCloseSuccessView = () => { + const handleCloseModal = () => { + set((s) => { + ;(s.success = ''), (s.tgCode = null) + }) + resetForm() + onClose() + } + + const handleNewFromSuccess = () => { resetForm() set((s) => { s.success = '' @@ -169,13 +179,14 @@ const AlertsModal: FunctionComponent = ({ } return ( - + {tgCode && showTgCode ? ( ) : success ? (
@@ -184,12 +195,17 @@ const AlertsModal: FunctionComponent = ({

{"We'll let you know if it's triggered."}

- +
+ + +
) : ( <> @@ -381,10 +397,11 @@ const AlertsModal: FunctionComponent = ({ export default AlertsModal const TelegramModal = ({ - tgCode, + handleCloseModal, handleCopyToClipboard, - handleCloseTgCodeView, + handleNewFromTgCode, isCopied, + tgCode, }) => { return (
@@ -417,9 +434,15 @@ const TelegramModal = ({
  • Paste the code and send message
  • - + +
    + + +
    ) } diff --git a/hooks/useWallet.tsx b/hooks/useWallet.tsx index df86c03..bd3863d 100644 --- a/hooks/useWallet.tsx +++ b/hooks/useWallet.tsx @@ -146,7 +146,7 @@ export default function useWallet() { if (connected && marginAccounts.length > 0) { alertActions.loadAlerts(marginAccountsPublicKey) } - }, [marginAccounts]) + }, [connected, marginAccounts]) useInterval(() => { if (connected && marginAccount) {