Skip to content

Commit

Permalink
Fix sound toggle button to handle loading state and undefined settings
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Jan 30, 2025
1 parent 00937cf commit 8acfb09
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export function TrajectoryActions({
onExportTrajectory,
}: TrajectoryActionsProps) {
const { settings, saveUserSettings } = useCurrentSettings();
// Ensure settings is defined before accessing properties
const soundEnabled = settings?.ENABLE_SOUND_NOTIFICATIONS ?? true;

const toggleSound = async () => {
await saveUserSettings({
...settings,
ENABLE_SOUND_NOTIFICATIONS: !settings?.ENABLE_SOUND_NOTIFICATIONS,
ENABLE_SOUND_NOTIFICATIONS: !soundEnabled,
});
};
return (
Expand All @@ -45,11 +47,7 @@ export function TrajectoryActions({
testId="sound-toggle"
onClick={toggleSound}
icon={
settings?.ENABLE_SOUND_NOTIFICATIONS === true ? (
<HiVolumeUp size={15} />
) : (
<HiVolumeOff size={15} />
)
soundEnabled ? <HiVolumeUp size={15} /> : <HiVolumeOff size={15} />
}
/>
</div>
Expand Down

0 comments on commit 8acfb09

Please sign in to comment.