From 8488ce1402e6f95204ce54174b96c7e036cb7532 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Sat, 4 Feb 2023 16:22:57 +0100 Subject: [PATCH] fix socket is null if PWA is offline --- public/scripts/network.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index 9ab02d3..ff26d0d 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -139,10 +139,12 @@ class ServerConnection { _disconnect() { this.send({ type: 'disconnect' }); - this._socket.onclose = null; - this._socket.close(); - this._socket = null; - Events.fire('ws-disconnected'); + if (this._socket) { + this._socket.onclose = null; + this._socket.close(); + this._socket = null; + Events.fire('ws-disconnected'); + } } _onDisconnect() {