Skip to content

fix term crash when bell is false #7332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions lib/components/term.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/hyper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type uiState = Immutable<{
activeUid: string | null;
activityMarkers: Record<string, boolean>;
backgroundColor: string;
bell: string;
bell: 'SOUND' | false;
bellSoundURL: string | null;
bellSound: string | null;
borderColor: string;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/reducers/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down