mirror of https://github.com/jetkvm/kvm.git
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:
parent
47782856f3
commit
54cbd98781
|
|
@ -56,7 +56,21 @@ export default function SettingsAudioRoute() {
|
|||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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}` }),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue