diff options
author | Richard Macklin <richard.github@nrm.com> | 2019-01-14 11:36:32 -0800 |
---|---|---|
committer | Richard Macklin <richard.github@nrm.com> | 2019-01-14 11:52:46 -0800 |
commit | 739f88e52ec9d673e23f41545d55626351ce24eb (patch) | |
tree | b6581633dcc9527fde5299846fd4f8d3518e3fd6 | |
parent | 6320916513891938f7d2f0b5c9c36968ee2d8705 (diff) | |
download | rails-739f88e52ec9d673e23f41545d55626351ce24eb.tar.gz rails-739f88e52ec9d673e23f41545d55626351ce24eb.tar.bz2 rails-739f88e52ec9d673e23f41545d55626351ce24eb.zip |
Simplify `this.isActive() && this.webSocket` into `this.isActive()`
in Connection#close. We can do this because `isActive()` can only
return `true` if `this.webSocket` is truthy. (We can't have an active
connection without having instantiated a WebSocket. This is confirmed
in the code: Connection#isActive calls Connection#isState which calls
Connection#getState, which checks if `this.webSocket` is truthy and
returns `null` otherwise.)
-rw-r--r-- | actioncable/app/assets/javascripts/action_cable.js | 2 | ||||
-rw-r--r-- | actioncable/app/javascript/action_cable/connection.js | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable.js b/actioncable/app/assets/javascripts/action_cable.js index d860fba76e..a68c76f299 100644 --- a/actioncable/app/assets/javascripts/action_cable.js +++ b/actioncable/app/assets/javascripts/action_cable.js @@ -191,7 +191,7 @@ if (!allowReconnect) { this.monitor.stop(); } - if (this.isActive() && this.webSocket) { + if (this.isActive()) { return this.webSocket.close(); } }; diff --git a/actioncable/app/javascript/action_cable/connection.js b/actioncable/app/javascript/action_cable/connection.js index fddb920748..96bac132c1 100644 --- a/actioncable/app/javascript/action_cable/connection.js +++ b/actioncable/app/javascript/action_cable/connection.js @@ -44,7 +44,7 @@ class Connection { close({allowReconnect} = {allowReconnect: true}) { if (!allowReconnect) { this.monitor.stop() } - if (this.isActive() && this.webSocket) { + if (this.isActive()) { return this.webSocket.close() } } |