fix: always send device config on save — sync toggle now works both ways
This commit is contained in:
+11
-13
@@ -459,20 +459,18 @@ form.addEventListener('submit', async event => {
|
||||
}
|
||||
populateRemoteConfig(remoteConfigResult);
|
||||
|
||||
// Save device config (skip if sync is enabled — server is source of truth)
|
||||
if (!fields.deviceSyncEnabled.checked) {
|
||||
const deviceConfigResponse = await fetch('/api/device-config', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(deviceConfigPayload()),
|
||||
});
|
||||
const deviceConfigResult = await deviceConfigResponse.json();
|
||||
if (!deviceConfigResponse.ok) {
|
||||
applyErrors(deviceConfigResult.fields || {});
|
||||
throw new Error(deviceConfigResult.error || `HTTP ${deviceConfigResponse.status}`);
|
||||
}
|
||||
populateDeviceConfig(deviceConfigResult);
|
||||
// Save device config (always send — backend validates locked fields when sync is on)
|
||||
const deviceConfigResponse = await fetch('/api/device-config', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(deviceConfigPayload()),
|
||||
});
|
||||
const deviceConfigResult = await deviceConfigResponse.json();
|
||||
if (!deviceConfigResponse.ok) {
|
||||
applyErrors(deviceConfigResult.fields || {});
|
||||
throw new Error(deviceConfigResult.error || `HTTP ${deviceConfigResponse.status}`);
|
||||
}
|
||||
populateDeviceConfig(deviceConfigResult);
|
||||
|
||||
showMessage('Settings saved.', 'success');
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user