fix: verify audio source change and show accurate feedback

After setting audio output source, fetch the actual value from backend
to verify the change was applied successfully. This prevents the UI
from showing incorrect state when the backend fails to apply the change.

The optimistic update provides immediate feedback, but we now verify
the actual result and show error if backend returned a different value
than expected.
This commit is contained in:
Alex P 2025-10-23 23:59:02 +03:00
parent 47782856f3
commit 54cbd98781
1 changed files with 15 additions and 1 deletions

View File

@ -56,7 +56,21 @@ export default function SettingsAudioRoute() {
);
return;
}
notifications.success(m.audio_settings_output_source_success());
// Verify the change was applied by fetching the actual value
send("getAudioOutputSource", {}, (getResp: JsonRpcResponse) => {
if ("result" in getResp) {
const actualSource = getResp.result as string;
settings.setAudioOutputSource(actualSource);
if (actualSource === source) {
notifications.success(m.audio_settings_output_source_success());
} else {
notifications.error(
m.audio_settings_output_source_failed({ error: `Expected ${source}, got ${actualSource}` }),
);
}
}
});
});
};