Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contacts: Fixed the broken error display logic of bolt 12 address #2237

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading