Skip to content

Commit 0b15203

Browse files
dbieberclaude
andcommitted
Modify settings UI to only send changed values to server
- Compare each setting with its original value in the client - Only include changed settings in the request payload - Keep server-side processing unchanged 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 10103d6 commit 0b15203

File tree

1 file changed

+18
-1
lines changed
  • gonotego/settings-server/src

1 file changed

+18
-1
lines changed

gonotego/settings-server/src/App.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,29 @@ const SettingsUI = () => {
143143
const handleSave = async () => {
144144
setSaveStatus('saving');
145145
try {
146+
// Create an object with only the changed settings
147+
const changedSettings = {};
148+
149+
// Compare each setting with its original value
150+
for (const [key, value] of Object.entries(settings)) {
151+
// Get the original value
152+
const originalValue = originalSettings[key];
153+
154+
// Check if this setting has changed using string comparison
155+
// This handles all types of settings including arrays (via JSON.stringify)
156+
if (JSON.stringify(value) !== JSON.stringify(originalValue)) {
157+
changedSettings[key] = value;
158+
}
159+
}
160+
161+
console.log('Sending only changed settings:', changedSettings);
162+
146163
const response = await fetch('/api/settings', {
147164
method: 'POST',
148165
headers: {
149166
'Content-Type': 'application/json',
150167
},
151-
body: JSON.stringify(settings),
168+
body: JSON.stringify(changedSettings),
152169
});
153170

154171
if (!response.ok) {

0 commit comments

Comments
 (0)