File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
lib/js/src/manager/screen/utils Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -144,13 +144,25 @@ class _VoiceCommandUpdateOperation extends _Task {
144144 return true ; // nothing to delete
145145 }
146146
147- // make an AddCommand request for every voice command
148- const addCommands = this . _pendingVoiceCommands . map ( voiceCommand => {
147+ // filter the voice command list of any voice commands with duplicate items
148+ const addCommands = this . _pendingVoiceCommands . filter ( voiceCommand => {
149+ // Sets can only hold unique values. The size will be different if there are duplicates
150+ const uniqueList = new Set ( voiceCommand . getVoiceCommands ( ) ) ;
151+ if ( voiceCommand . getVoiceCommands ( ) . length !== uniqueList . size ) {
152+ return false ;
153+ }
154+ return true ;
155+ } ) . map ( voiceCommand => {
156+ // make an AddCommand request for every voice command
149157 return new AddCommand ( )
150158 . setCmdID ( voiceCommand . _getCommandId ( ) )
151159 . setVrCommands ( voiceCommand . getVoiceCommands ( ) ) ;
152160 } ) ;
153161
162+ if ( addCommands . length !== this . _pendingVoiceCommands . length ) {
163+ console . log ( 'One or more VoiceCommands contained duplicate items and will not be sent.' ) ;
164+ }
165+
154166 const addCommandPromises = addCommands . map ( addCommand => {
155167 return this . _lifecycleManager . sendRpcResolve ( addCommand ) ;
156168 } ) ;
You can’t perform that action at this time.
0 commit comments