diff --git a/app/config/schema.json b/app/config/schema.json index b8a30ae4..6bcf8500 100644 --- a/app/config/schema.json +++ b/app/config/schema.json @@ -33,7 +33,10 @@ }, "bell": { "description": "Supported Options:\n1. 'SOUND' -> Enables the bell as a sound\n2. false: turns off the bell", - "type": "string" + "enum": [ + "SOUND", + false + ] }, "bellSound": { "description": "base64 encoded string of the sound file to use for the bell\nif null, the default bell will be used", @@ -357,7 +360,10 @@ }, "bell": { "description": "Supported Options:\n1. 'SOUND' -> Enables the bell as a sound\n2. false: turns off the bell", - "type": "string" + "enum": [ + "SOUND", + false + ] }, "bellSound": { "description": "base64 encoded string of the sound file to use for the bell\nif null, the default bell will be used", diff --git a/lib/components/term.tsx b/lib/components/term.tsx index 741a023c..6772bc91 100644 --- a/lib/components/term.tsx +++ b/lib/components/term.tsx @@ -416,8 +416,8 @@ export default class Term extends React.PureComponent< return !e.catched; } - setBellSound(bell: string | null, sound: string | null) { - if (bell?.toUpperCase() === 'SOUND') { + setBellSound(bell: 'SOUND' | false, sound: string | null) { + if (bell && bell.toUpperCase() === 'SOUND') { this.bellSound = sound ? new Audio(sound) : this.defaultBellSound; } else { this.bellSound = null; diff --git a/lib/config.d.ts b/lib/config.d.ts index c6f8940b..7a6053e9 100644 --- a/lib/config.d.ts +++ b/lib/config.d.ts @@ -46,7 +46,7 @@ type profileConfigOptions = { * 1. 'SOUND' -> Enables the bell as a sound * 2. false: turns off the bell */ - bell: string; + bell: 'SOUND' | false; /** * base64 encoded string of the sound file to use for the bell * if null, the default bell will be used diff --git a/lib/hyper.d.ts b/lib/hyper.d.ts index 90c67012..264d01e2 100644 --- a/lib/hyper.d.ts +++ b/lib/hyper.d.ts @@ -47,7 +47,7 @@ export type uiState = Immutable<{ activeUid: string | null; activityMarkers: Record; backgroundColor: string; - bell: string; + bell: 'SOUND' | false; bellSoundURL: string | null; bellSound: string | null; borderColor: string; @@ -347,7 +347,7 @@ import type {FitAddon} from 'xterm-addon-fit'; import type {SearchAddon} from 'xterm-addon-search'; export type TermProps = { backgroundColor: string; - bell: string; + bell: 'SOUND' | false; bellSound: string | null; bellSoundURL: string | null; borderColor: string; diff --git a/lib/reducers/ui.ts b/lib/reducers/ui.ts index 9ccfbd1e..b5195ac9 100644 --- a/lib/reducers/ui.ts +++ b/lib/reducers/ui.ts @@ -217,7 +217,7 @@ const reducer: IUiReducer = (state = initial, action) => { } if (allowedBells.has(config.bell)) { - ret.bell = config.bell; + ret.bell = (config.bell as any) === 'false' ? false : config.bell; } if (config.bellSoundURL !== state.bellSoundURL) {