Skip to content

Commit 5382a90

Browse files
authored
Merge pull request #530 from smartdevicelink/bugfix/invalid-voice-commands-no-warning
Add warnings for invalid voice command strings
2 parents 0bf5cdb + 89f3a88 commit 5382a90

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/js/src/manager/screen/_VoiceCommandManagerBase.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,20 @@ class _VoiceCommandManagerBase extends _SubManagerBase {
179179
const validatedVoiceCommands = voiceCommands.map((voiceCommand) => {
180180
const voiceCommandStrings = voiceCommand.getVoiceCommands().filter((voiceCommandString) => {
181181
// filter out any whitespace characters
182-
return voiceCommandString !== null && voiceCommandString !== undefined && voiceCommandString.replace(/\s/g, '').length > 0;
182+
const validString = voiceCommandString !== null && voiceCommandString !== undefined && voiceCommandString.replace(/\s/g, '').length > 0;
183+
if (!validString) {
184+
console.warn('Empty or whitespace only voice command string: ', voiceCommandString, ', removed from voice command: ', voiceCommand);
185+
}
186+
return validString;
183187
});
184188
// Updates voice command strings array by only adding ones that are not empty(e.g. ', ' ', ...)
185189
if (voiceCommandStrings.length > 0) {
186190
return voiceCommand.setVoiceCommands(voiceCommandStrings);
187191
}
188192
}).filter((voiceCommand) => {
193+
if (voiceCommand === undefined) {
194+
console.warn('A voice command with no valid strings was removed.');
195+
}
189196
return voiceCommand !== undefined;
190197
});
191198
return validatedVoiceCommands;

0 commit comments

Comments
 (0)