summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-12-04 10:54:35 -0200
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-12-04 11:44:27 -0200
commit9207574ac7315e07f91fb68858d7363d70ec3751 (patch)
treea1e9371f5888198af263a7b0259ce804d82f99e4
parent4cd6553c9dc1d822a8abd4827388311d9beed9cf (diff)
downloadmullvadvpn-9207574ac7315e07f91fb68858d7363d70ec3751.tar.xz
mullvadvpn-9207574ac7315e07f91fb68858d7363d70ec3751.zip
Refactor to reduce repeated code
-rw-r--r--gui/packages/desktop/src/main/index.js12
1 files changed, 4 insertions, 8 deletions
diff --git a/gui/packages/desktop/src/main/index.js b/gui/packages/desktop/src/main/index.js
index e2542382e7..5cc11a29b1 100644
--- a/gui/packages/desktop/src/main/index.js
+++ b/gui/packages/desktop/src/main/index.js
@@ -618,17 +618,13 @@ const ApplicationMain = {
},
async _updateLocation() {
- const newState = this._tunnelState;
+ const state = this._tunnelState.state;
- if (
- newState.state === 'connected' ||
- newState.state === 'disconnected' ||
- newState.state === 'connecting'
- ) {
+ if (state === 'connected' || state === 'disconnected' || state === 'connecting') {
try {
// It may take some time to fetch the new user location.
// So take the user to the last known location when disconnected.
- if (newState.state === 'disconnected' && this._lastDisconnectedLocation) {
+ if (state === 'disconnected' && this._lastDisconnectedLocation) {
this._setLocation(this._lastDisconnectedLocation);
}
@@ -644,7 +640,7 @@ const ApplicationMain = {
// Broadcast the new location.
// There is a chance that the location is not stale if the tunnel state before the location
// request is the same as after receiving the response.
- if (this._tunnelState.state === newState.state) {
+ if (this._tunnelState.state === state) {
this._setLocation(location);
}
} catch (error) {