fix: skip device config save when sync is enabled — prevents 'Invalid device config' blocking settings save

This commit is contained in:
Mathieu Moran
2026-08-11 18:57:40 -04:00
parent 34253b3ffb
commit 878ba4a958
+13 -11
View File
@@ -459,18 +459,20 @@ form.addEventListener('submit', async event => {
} }
populateRemoteConfig(remoteConfigResult); populateRemoteConfig(remoteConfigResult);
// Save device config // Save device config (skip if sync is enabled — server is source of truth)
const deviceConfigResponse = await fetch('/api/device-config', { if (!fields.deviceSyncEnabled.checked) {
method: 'POST', const deviceConfigResponse = await fetch('/api/device-config', {
headers: {'Content-Type': 'application/json'}, method: 'POST',
body: JSON.stringify(deviceConfigPayload()), headers: {'Content-Type': 'application/json'},
}); body: JSON.stringify(deviceConfigPayload()),
const deviceConfigResult = await deviceConfigResponse.json(); });
if (!deviceConfigResponse.ok) { const deviceConfigResult = await deviceConfigResponse.json();
applyErrors(deviceConfigResult.fields || {}); if (!deviceConfigResponse.ok) {
throw new Error(deviceConfigResult.error || `HTTP ${deviceConfigResponse.status}`); applyErrors(deviceConfigResult.fields || {});
throw new Error(deviceConfigResult.error || `HTTP ${deviceConfigResponse.status}`);
}
populateDeviceConfig(deviceConfigResult);
} }
populateDeviceConfig(deviceConfigResult);
showMessage('Settings saved.', 'success'); showMessage('Settings saved.', 'success');
} catch (error) { } catch (error) {