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

Node config: require confirmation to delete a node #1489

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"views.Settings.AddEditNode.scanLndhub": "Scan LNDHub QR",
"views.Settings.AddEditNode.scanSpark": "Scan Spark QR",
"views.Settings.AddEditNode.deleteNode": "Delete Node config",
"views.Settings.AddEditNode.tapToConfirm": "Tap to confirm",
"views.Settings.AddEditNode.copyNode": "Copy Node config",
"views.Settings.AddEditNode.nodeInterface": "Node interface",
"views.Settings.AddEditNode.useTor": "Use Tor",
Expand Down
29 changes: 23 additions & 6 deletions views/Settings/NodeConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ interface NodeConfigurationState {
customMailboxServer: string;
localKey: string;
remoteKey: string;
deletionAwaitingConfirmation: boolean;
}

const ScanBadge = ({ onPress }: { onPress: () => void }) => (
Expand Down Expand Up @@ -110,7 +111,8 @@ export default class NodeConfiguration extends React.Component<
mailboxServer: 'mailbox.terminal.lightning.today:443',
customMailboxServer: '',
localKey: '',
remoteKey: ''
remoteKey: '',
deletionAwaitingConfirmation: false
};

async UNSAFE_componentWillMount() {
Expand Down Expand Up @@ -457,7 +459,8 @@ export default class NodeConfiguration extends React.Component<
mailboxServer,
customMailboxServer,
localKey,
remoteKey
remoteKey,
deletionAwaitingConfirmation
} = this.state;
const {
loading,
Expand Down Expand Up @@ -1318,10 +1321,24 @@ export default class NodeConfiguration extends React.Component<
{saved && (
<View style={styles.button}>
<Button
title={localeString(
'views.Settings.AddEditNode.deleteNode'
)}
onPress={() => this.deleteNodeConfig()}
title={
deletionAwaitingConfirmation
? localeString(
'views.Settings.AddEditNode.tapToConfirm'
)
: localeString(
'views.Settings.AddEditNode.deleteNode'
)
}
onPress={() => {
if (!deletionAwaitingConfirmation) {
this.setState({
deletionAwaitingConfirmation: true
});
} else {
this.deleteNodeConfig();
}
}}
containerStyle={{
borderColor: themeColor('delete')
}}
Expand Down