fix: do not ping the server on edit if the preauth secret didn't change (#9368)

* fix: do not ping the server on edit if the preauth secret didn't change

* Update app/screens/edit_server/index.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Felipe Martin 2026-01-12 17:45:12 +01:00 committed by GitHub
parent c3b141e77c
commit 9632cfa141
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -57,6 +57,7 @@ const EditServer = ({closeButtonId, componentId, server, theme}: ServerProps) =>
const [buttonDisabled, setButtonDisabled] = useState(Boolean(!server.displayName));
const [displayNameError, setDisplayNameError] = useState<string | undefined>();
const [preauthSecret, setPreauthSecret] = useState<string>('');
const [initialPreauthSecret, setInitialPreauthSecret] = useState<string>('');
const [preauthSecretError, setPreauthSecretError] = useState<string | undefined>();
const [showAdvancedOptions, setShowAdvancedOptions] = useState<boolean>(false);
const [validating, setValidating] = useState(false);
@ -73,6 +74,7 @@ const EditServer = ({closeButtonId, componentId, server, theme}: ServerProps) =>
const credentials = await getServerCredentials(server.url);
const currentPreauthSecret = credentials?.preauthSecret || '';
setPreauthSecret(currentPreauthSecret);
setInitialPreauthSecret(currentPreauthSecret);
// Auto-open advanced options if preauth secret exists
if (currentPreauthSecret) {
@ -171,11 +173,14 @@ const EditServer = ({closeButtonId, componentId, server, theme}: ServerProps) =>
return;
}
// Validate preauth secret if changed
const isValidServer = await validateServer();
if (!isValidServer) {
setSaving(false);
return;
// Only validate server connection if preauth secret has changed
const preauthSecretChanged = preauthSecret.trim() !== initialPreauthSecret.trim();
if (preauthSecretChanged) {
const isValidServer = await validateServer();
if (!isValidServer) {
setSaving(false);
return;
}
}
// Save display name
@ -193,7 +198,7 @@ const EditServer = ({closeButtonId, componentId, server, theme}: ServerProps) =>
}
dismissModal({componentId});
}, [buttonDisabled, displayName, displayNameError, preauthSecretError, server.url, preauthSecret, formatMessage, validateServer, componentId]);
}, [buttonDisabled, displayName, displayNameError, preauthSecretError, server.url, preauthSecret, initialPreauthSecret, formatMessage, validateServer, componentId]);
const handleDisplayNameTextChanged = useCallback((text: string) => {
setDisplayName(text);