File tree 1 file changed +14
-2
lines changed
lib/js/src/manager/screen/utils
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 {
144
144
return true ; // nothing to delete
145
145
}
146
146
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
149
157
return new AddCommand ( )
150
158
. setCmdID ( voiceCommand . _getCommandId ( ) )
151
159
. setVrCommands ( voiceCommand . getVoiceCommands ( ) ) ;
152
160
} ) ;
153
161
162
+ if ( addCommands . length !== this . _pendingVoiceCommands . length ) {
163
+ console . log ( 'One or more VoiceCommands contained duplicate items and will not be sent.' ) ;
164
+ }
165
+
154
166
const addCommandPromises = addCommands . map ( addCommand => {
155
167
return this . _lifecycleManager . sendRpcResolve ( addCommand ) ;
156
168
} ) ;
You can’t perform that action at this time.
0 commit comments