From bc989d06f478fa94583de5c2be8c13228964c89c Mon Sep 17 00:00:00 2001 From: shubham Date: Thu, 13 Jun 2024 17:43:51 +0530 Subject: [PATCH 1/2] Fixed the broken error display logic of bolt 12 address --- views/Settings/AddContact.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/views/Settings/AddContact.tsx b/views/Settings/AddContact.tsx index cea70434b..932082d9f 100644 --- a/views/Settings/AddContact.tsx +++ b/views/Settings/AddContact.tsx @@ -757,8 +757,9 @@ export default class AddContact extends React.Component< orientation="horizontal" style={{ marginTop: 10 }} color={ - pubkey?.length == 1 && - (!isValidLightningAddress || !isValidPubkey) && + bolt12Address?.length == 1 && + (!isValidLightningAddress || + !isValidBolt12Address) && themeColor('error') } /> @@ -803,8 +804,8 @@ export default class AddContact extends React.Component< orientation="horizontal" style={{ marginTop: 16 }} color={ - index === lnAddress?.length - 2 && - !isValidLightningAddress && + index === bolt12Address?.length - 2 && + !isValidBolt12Address && themeColor('error') } /> @@ -829,7 +830,7 @@ export default class AddContact extends React.Component< }); if (!text) { this.setState({ - isValidLightningAddress: + isValidBolt12Address: true }); } @@ -870,7 +871,7 @@ export default class AddContact extends React.Component< style={{ marginTop: 10 }} color={ pubkey?.length == 1 && - (!isValidLightningAddress || !isValidPubkey) && + (!isValidBolt12Address || !isValidPubkey) && themeColor('error') } /> From e5219edfda5a2b6178db9403a03f3e8067448f4f Mon Sep 17 00:00:00 2001 From: shubham Date: Thu, 13 Jun 2024 17:52:36 +0530 Subject: [PATCH 2/2] Show remove extra field icon only if there is no error in the field --- views/Settings/AddContact.tsx | 192 +++++++++++++++++++--------------- 1 file changed, 108 insertions(+), 84 deletions(-) diff --git a/views/Settings/AddContact.tsx b/views/Settings/AddContact.tsx index 932082d9f..6d62b7abd 100644 --- a/views/Settings/AddContact.tsx +++ b/views/Settings/AddContact.tsx @@ -736,20 +736,24 @@ export default class AddContact extends React.Component< autoCapitalize="none" /> - - - this.removeExtraField( - 'lnAddress', - index - ) - } - color={themeColor('text')} - underlayColor="transparent" - size={16} - /> - + {isValidLightningAddress && ( + + + this.removeExtraField( + 'lnAddress', + index + ) + } + color={themeColor('text')} + underlayColor="transparent" + size={16} + /> + + )} ))} @@ -849,20 +853,24 @@ export default class AddContact extends React.Component< autoCapitalize="none" /> - - - this.removeExtraField( - 'bolt12Address', - index - ) - } - color={themeColor('text')} - underlayColor="transparent" - size={16} - /> - + {isValidBolt12Address && ( + + + this.removeExtraField( + 'bolt12Address', + index + ) + } + color={themeColor('text')} + underlayColor="transparent" + size={16} + /> + + )} ))} @@ -958,20 +966,24 @@ export default class AddContact extends React.Component< autoCapitalize="none" /> - - - this.removeExtraField( - 'pubkey', - index - ) - } - color={themeColor('text')} - underlayColor="transparent" - size={16} - /> - + {isValidPubkey && ( + + + this.removeExtraField( + 'pubkey', + index + ) + } + color={themeColor('text')} + underlayColor="transparent" + size={16} + /> + + )} ))} @@ -1073,20 +1085,24 @@ export default class AddContact extends React.Component< autoCapitalize="none" /> - - - this.removeExtraField( - 'onchainAddress', - index - ) - } - color={themeColor('text')} - underlayColor="transparent" - size={16} - /> - + {isValidOnchainAddress && ( + + + this.removeExtraField( + 'onchainAddress', + index + ) + } + color={themeColor('text')} + underlayColor="transparent" + size={16} + /> + + )} ))} @@ -1180,20 +1196,24 @@ export default class AddContact extends React.Component< autoCapitalize="none" /> - - - this.removeExtraField( - 'nip05', - index - ) - } - color={themeColor('text')} - underlayColor="transparent" - size={16} - /> - + {isValidNIP05 && ( + + + this.removeExtraField( + 'nip05', + index + ) + } + color={themeColor('text')} + underlayColor="transparent" + size={16} + /> + + )} ))} @@ -1286,20 +1306,24 @@ export default class AddContact extends React.Component< autoCapitalize="none" /> - - - this.removeExtraField( - 'nostrNpub', - index - ) - } - color={themeColor('text')} - underlayColor="transparent" - size={16} - /> - + {isValidNpub && ( + + + this.removeExtraField( + 'nostrNpub', + index + ) + } + color={themeColor('text')} + underlayColor="transparent" + size={16} + /> + + )} ))}