From 739f88e52ec9d673e23f41545d55626351ce24eb Mon Sep 17 00:00:00 2001 From: Richard Macklin Date: Mon, 14 Jan 2019 11:36:32 -0800 Subject: 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.) --- actioncable/app/assets/javascripts/action_cable.js | 2 +- actioncable/app/javascript/action_cable/connection.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actioncable') 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() } } -- cgit v1.2.3