diff --git a/Navigation.js b/Navigation.js
index e800a04f0..d0e5f5cc8 100644
--- a/Navigation.js
+++ b/Navigation.js
@@ -133,7 +133,15 @@ const WalletsRoot = () => (
-
+
+
(
-
+
{
const { invoice, fromWallet, isModal } = useRoute().params;
const { setSelectedWallet, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
const { width, height } = useWindowDimensions();
const { colors } = useTheme();
- const { goBack, navigation, navigate, setParams, setOptions, dangerouslyGetParent } = useNavigation();
+ const { goBack, popToRoot, navigate, setParams, setOptions } = useNavigation();
const [isLoading, setIsLoading] = useState(typeof invoice === 'string');
const [isFetchingInvoices, setIsFetchingInvoices] = useState(true);
const [showPreimageQr, setShowPreimageQr] = useState(false);
@@ -37,6 +39,9 @@ const LNDViewInvoice = () => {
valueText: {
color: colors.alternativeTextColor2,
},
+ valueRoot: {
+ backgroundColor: colors.background,
+ },
valueSats: {
color: colors.alternativeTextColor2,
},
@@ -69,20 +74,13 @@ const LNDViewInvoice = () => {
setOptions(
isModal === true
? {
- ...BlueNavigationStyle(navigation, true, () => dangerouslyGetParent().pop()),
- title: loc.lnd.lightning_invoice,
- headerLeft: null,
headerStyle: {
- ...BlueNavigationStyle().headerStyle,
backgroundColor: colors.customHeader,
},
gestureEnabled: false,
}
: {
- ...BlueNavigationStyle(),
- title: loc.lnd.lightning_invoice,
headerStyle: {
- ...BlueNavigationStyle().headerStyle,
backgroundColor: colors.customHeader,
},
},
@@ -107,7 +105,7 @@ const LNDViewInvoice = () => {
)[0];
if (typeof updatedUserInvoice !== 'undefined') {
setParams({ invoice: updatedUserInvoice });
- setIsLoading(true);
+ setIsLoading(false);
if (updatedUserInvoice.ispaid) {
// we fetched the invoice, and it is paid :-)
setIsFetchingInvoices(false);
@@ -154,24 +152,35 @@ const LNDViewInvoice = () => {
navigate('LNDViewAdditionalInvoiceInformation', { fromWallet });
};
- if (isLoading) {
- return (
-
-
-
- );
- }
+ useEffect(() => {
+ if (invoice.ispaid) {
+ navigate('Success', {
+ amount: invoice.amt,
+ amountUnit: BitcoinUnit.SATS,
+ invoiceDescription: invoice.description,
+ onDonePressed: popToRoot,
+ });
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [invoice]);
- if (typeof invoice === 'object') {
- const currentDate = new Date();
- const now = (currentDate.getTime() / 1000) | 0;
- const invoiceExpiration = invoice.timestamp + invoice.expire_time;
-
- if (showPreimageQr) {
+ const render = () => {
+ if (isLoading) {
return (
-
-
-
+
+
+
+ );
+ }
+
+ if (typeof invoice === 'object') {
+ const currentDate = new Date();
+ const now = (currentDate.getTime() / 1000) | 0;
+ const invoiceExpiration = invoice.timestamp + invoice.expire_time;
+
+ if (showPreimageQr) {
+ return (
+
{loc.lndViewInvoice.preimage}:
@@ -190,77 +199,58 @@ const LNDViewInvoice = () => {
text={invoice.payment_preimage && typeof invoice.payment_preimage === 'string' ? invoice.payment_preimage : 'none'}
/>
-
- );
- }
+ );
+ }
- if (invoice.ispaid || invoice.type === 'paid_invoice') {
- return (
-
-
-
- {invoice.type === 'paid_invoice' && invoice.value && (
-
- {invoice.value}
- {loc.lndViewInvoice.sats}
-
- )}
- {invoice.type === 'user_invoice' && invoice.amt && (
-
- {invoice.amt}
- {loc.lndViewInvoice.sats}
-
- )}
- {!invoice.ispaid && invoice.memo && invoice.memo.length > 0 && {invoice.memo}}
-
+ if (invoice.ispaid || invoice.type === 'paid_invoice') {
+ return (
+ <>
+
+ {invoice.type === 'paid_invoice' && invoice.value && (
+
+ {invoice.value}
+ {loc.lndViewInvoice.sats}
+
+ )}
+ {invoice.type === 'user_invoice' && invoice.amt && (
+
+ {invoice.amt}
+ {loc.lndViewInvoice.sats}
+
+ )}
+ {!invoice.ispaid && invoice.memo && invoice.memo.length > 0 && {invoice.memo}}
+
-
-
- {loc.lndViewInvoice.has_been_paid}
-
-
- {invoice.payment_preimage && typeof invoice.payment_preimage === 'string' ? (
-
- {loc.send.create_details}
-
-
- ) : (
-
- )}
-
-
- );
- }
- if (invoiceExpiration < now && !invoice.ispaid) {
- return (
-
-
-
+
+
+ {loc.lndViewInvoice.has_been_paid}
+
+
+ {invoice.payment_preimage && typeof invoice.payment_preimage === 'string' ? (
+
+ {loc.send.create_details}
+
+
+ ) : (
+
+ )}
+
+ >
+ );
+ }
+ if (invoiceExpiration < now && !invoice.ispaid) {
+ return (
+
{loc.lndViewInvoice.wasnt_paid_and_expired}
-
- );
- } else if (invoiceExpiration > now && invoice.ispaid) {
- if (invoice.ispaid) {
- return (
-
-
- {loc.lndViewInvoice.has_been_paid}
-
-
);
}
- }
- }
- // Invoice has not expired, nor has it been paid for.
- return (
-
-
-
-
+ // Invoice has not expired, nor has it been paid for.
+ return (
+
{
+
{
title={loc.lndViewInvoice.additional_info}
/>
-
+ );
+ }
+ };
+
+ return (
+
+
+
+ {render()}
);
@@ -302,11 +301,6 @@ const styles = StyleSheet.create({
root: {
flex: 1,
},
- center: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- },
qrCodeContainer: { borderWidth: 6, borderRadius: 8, borderColor: '#FFFFFF' },
valueRoot: {
flex: 2,
@@ -372,7 +366,6 @@ const styles = StyleSheet.create({
activeRoot: {
flex: 1,
alignItems: 'center',
- marginTop: 8,
justifyContent: 'space-between',
},
activeQrcode: {
@@ -387,3 +380,22 @@ const styles = StyleSheet.create({
});
export default LNDViewInvoice;
+
+LNDViewInvoice.navigationOptions = ({ navigation, route }) =>
+ route.params.isModal === true
+ ? {
+ ...BlueNavigationStyle(navigation, true, () => navigation.dangerouslyGetParent().pop()),
+ title: loc.lndViewInvoice.lightning_invoice,
+ headerLeft: null,
+ headerStyle: {
+ ...BlueNavigationStyle().headerStyle,
+ },
+ gestureEnabled: false,
+ }
+ : {
+ ...BlueNavigationStyle(),
+ title: loc.lndViewInvoice.lightning_invoice,
+ headerStyle: {
+ ...BlueNavigationStyle().headerStyle,
+ },
+ };