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) {
148
148
}
149
149
150
150
function onSendChannelStateChange ( ) {
151
- const readyState = sendChannel . readyState ;
151
+ const { readyState } = sendChannel ;
152
152
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 ) {
155
159
dataChannelSend . focus ( ) ;
156
- sendButton . disabled = false ;
157
- closeButton . disabled = false ;
158
- } else {
159
- dataChannelSend . disabled = true ;
160
- sendButton . disabled = true ;
161
- closeButton . disabled = true ;
162
160
}
163
161
}
164
162
You can’t perform that action at this time.
0 commit comments