Skip to content

Commit

Permalink
Merge pull request #2237 from shubhamkmr04/shubham/bolt12-input-error
Browse files Browse the repository at this point in the history
Contacts: Fixed the broken error display logic of bolt 12 address
  • Loading branch information
kaloudis authored Jun 14, 2024
2 parents e1d13ba + e5219ed commit fd5b118
Showing 1 changed file with 115 additions and 90 deletions.
205 changes: 115 additions & 90 deletions views/Settings/AddContact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -736,29 +736,34 @@ export default class AddContact extends React.Component<
autoCapitalize="none"
/>
</View>
<TouchableOpacity style={styles.deleteIcon}>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'lnAddress',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
{isValidLightningAddress && (
<TouchableOpacity
style={styles.deleteIcon}
>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'lnAddress',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
)}
</View>
</>
))}
<Divider
orientation="horizontal"
style={{ marginTop: 10 }}
color={
pubkey?.length == 1 &&
(!isValidLightningAddress || !isValidPubkey) &&
bolt12Address?.length == 1 &&
(!isValidLightningAddress ||
!isValidBolt12Address) &&
themeColor('error')
}
/>
Expand Down Expand Up @@ -803,8 +808,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')
}
/>
Expand All @@ -829,7 +834,7 @@ export default class AddContact extends React.Component<
});
if (!text) {
this.setState({
isValidLightningAddress:
isValidBolt12Address:
true
});
}
Expand All @@ -848,20 +853,24 @@ export default class AddContact extends React.Component<
autoCapitalize="none"
/>
</View>
<TouchableOpacity style={styles.deleteIcon}>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'bolt12Address',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
{isValidBolt12Address && (
<TouchableOpacity
style={styles.deleteIcon}
>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'bolt12Address',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
)}
</View>
</>
))}
Expand All @@ -870,7 +879,7 @@ export default class AddContact extends React.Component<
style={{ marginTop: 10 }}
color={
pubkey?.length == 1 &&
(!isValidLightningAddress || !isValidPubkey) &&
(!isValidBolt12Address || !isValidPubkey) &&
themeColor('error')
}
/>
Expand Down Expand Up @@ -957,20 +966,24 @@ export default class AddContact extends React.Component<
autoCapitalize="none"
/>
</View>
<TouchableOpacity style={styles.deleteIcon}>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'pubkey',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
{isValidPubkey && (
<TouchableOpacity
style={styles.deleteIcon}
>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'pubkey',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
)}
</View>
</>
))}
Expand Down Expand Up @@ -1072,20 +1085,24 @@ export default class AddContact extends React.Component<
autoCapitalize="none"
/>
</View>
<TouchableOpacity style={styles.deleteIcon}>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'onchainAddress',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
{isValidOnchainAddress && (
<TouchableOpacity
style={styles.deleteIcon}
>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'onchainAddress',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
)}
</View>
</>
))}
Expand Down Expand Up @@ -1179,20 +1196,24 @@ export default class AddContact extends React.Component<
autoCapitalize="none"
/>
</View>
<TouchableOpacity style={styles.deleteIcon}>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'nip05',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
{isValidNIP05 && (
<TouchableOpacity
style={styles.deleteIcon}
>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'nip05',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
)}
</View>
</>
))}
Expand Down Expand Up @@ -1285,20 +1306,24 @@ export default class AddContact extends React.Component<
autoCapitalize="none"
/>
</View>
<TouchableOpacity style={styles.deleteIcon}>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'nostrNpub',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
{isValidNpub && (
<TouchableOpacity
style={styles.deleteIcon}
>
<Icon
name="close"
onPress={() =>
this.removeExtraField(
'nostrNpub',
index
)
}
color={themeColor('text')}
underlayColor="transparent"
size={16}
/>
</TouchableOpacity>
)}
</View>
</>
))}
Expand Down

0 comments on commit fd5b118

Please sign in to comment.