Update LightningSettings.tsx

This commit is contained in:
Marcos Rodriguez Vélez 2025-01-01 20:32:28 -04:00 committed by GitHub
parent cbda4cafab
commit c5c2ce8a61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -106,29 +106,30 @@ const LightningSettings: React.FC = () => {
setURI(typeof setLndHubUrl === 'string' ? setLndHubUrl.trim() : value.trim());
};
const save = useCallback(async () => {
setIsLoading(true);
try {
await DefaultPreference.setName(GROUP_IO_BLUEWALLET);
if (URI) {
const normalizedURI = new URL(URI.replace(/([^:]\/)\/+/g, '$1')).toString();
const save = useCallback(async () => {
setIsLoading(true);
try {
await DefaultPreference.setName(GROUP_IO_BLUEWALLET);
if (URI) {
const normalizedURI = new URL(URI.replace(/([^:]\/)\/+/g, '$1')).toString();
await LightningCustodianWallet.isValidNodeAddress(normalizedURI);
// Validate the normalized URI
await LightningCustodianWallet.isValidNodeAddress(normalizedURI);
await setLNDHub(normalizedURI);
} else {
await clearLNDHub();
}
presentAlert({ message: loc.settings.lightning_saved, type: AlertType.Toast });
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
} catch (error) {
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
presentAlert({ message: loc.settings.lightning_error_lndhub_uri });
console.log(error);
await setLNDHub(normalizedURI);
} else {
await clearLNDHub();
}
setIsLoading(false);
}, [URI]);
presentAlert({ message: loc.settings.lightning_saved, type: AlertType.Toast });
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
} catch (error) {
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
presentAlert({ message: loc.settings.lightning_error_lndhub_uri });
console.log(error);
}
setIsLoading(false);
}, [URI]);
const importScan = () => {
scanQrHelper(route.name).then(data => {