File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
src/content/datachannel/basic/js Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -148,17 +148,15 @@ function onReceiveMessageCallback(event) {
148148}
149149
150150function onSendChannelStateChange ( ) {
151- const readyState = sendChannel . readyState ;
151+ const { readyState } = sendChannel ;
152152 console . log ( 'Send channel state is: ' + readyState ) ;
153- if ( readyState === 'open' ) {
154- dataChannelSend . disabled = false ;
153+ const isChannelClosed = readyState !== 'open' ;
154+ const elementsToDisable = [ dataChannelSend , sendButton , closeButton ] ;
155+ elementsToDisable . forEach ( element => {
156+ element . disabled = isChannelClosed ;
157+ } ) ;
158+ if ( ! isChannelClosed ) {
155159 dataChannelSend . focus ( ) ;
156- sendButton . disabled = false ;
157- closeButton . disabled = false ;
158- } else {
159- dataChannelSend . disabled = true ;
160- sendButton . disabled = true ;
161- closeButton . disabled = true ;
162160 }
163161}
164162
You can’t perform that action at this time.
0 commit comments