From 64d586ec00a98f24ac2d6d2765914cc9409f97db Mon Sep 17 00:00:00 2001 From: manavdesai27 Date: Mon, 13 Feb 2023 21:03:19 +0530 Subject: [PATCH 1/2] fix: receive back button --- src/app/screens/Receive/index.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/screens/Receive/index.tsx b/src/app/screens/Receive/index.tsx index 4624a36425..23dd88cfd3 100644 --- a/src/app/screens/Receive/index.tsx +++ b/src/app/screens/Receive/index.tsx @@ -112,6 +112,21 @@ function Receive() { navigate("/receive"); } + function handleBack() { + if (invoice == null) { + navigate(-1); + } + + setFormData({ + amount: "0", + description: "", + expiration: "", + }); + setPaid(false); + setPollingForPayment(false); + setInvoice(null); + } + async function createInvoice() { try { setLoading(true); @@ -223,7 +238,7 @@ function Receive() { title={t("title")} headerLeft={ navigate("/")} + onClick={handleBack} icon={} /> } From cf8449ac64bf9f774e3d91b70f49f203f23b72a8 Mon Sep 17 00:00:00 2001 From: manavdesai27 Date: Fri, 17 Feb 2023 19:36:48 +0530 Subject: [PATCH 2/2] chore: clean and refactor code --- src/app/screens/Receive/index.tsx | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/app/screens/Receive/index.tsx b/src/app/screens/Receive/index.tsx index 23dd88cfd3..92a841ac22 100644 --- a/src/app/screens/Receive/index.tsx +++ b/src/app/screens/Receive/index.tsx @@ -100,23 +100,7 @@ function Receive() { }); } - function receiveAnotherPayment() { - setFormData({ - amount: "0", - description: "", - expiration: "", - }); - setPaid(false); - setPollingForPayment(false); - setInvoice(null); - navigate("/receive"); - } - - function handleBack() { - if (invoice == null) { - navigate(-1); - } - + function setDefaults() { setFormData({ amount: "0", description: "", @@ -174,7 +158,10 @@ function Receive() { label={tCommon("actions.receive_again")} primary fullWidth - onClick={receiveAnotherPayment} + onClick={() => { + setDefaults(); + navigate("/receive"); + }} /> )} @@ -238,7 +225,9 @@ function Receive() { title={t("title")} headerLeft={ { + invoice ? setDefaults() : navigate(-1); + }} icon={} /> }