From 555d5039b57ced98d0945915a2957af79bbccaeb Mon Sep 17 00:00:00 2001 From: Tobias Roeddiger Date: Mon, 9 Sep 2024 15:38:59 +0200 Subject: [PATCH] Update OpenEarable.js --- assets/js/OpenEarable.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/js/OpenEarable.js b/assets/js/OpenEarable.js index d6ef817..1b9d068 100644 --- a/assets/js/OpenEarable.js +++ b/assets/js/OpenEarable.js @@ -281,7 +281,11 @@ class BLEManager { optionalServices: optionalServiceUUIDs }); this.gattServer = await this.device.gatt.connect(); - this.device.addEventListener('gattserverdisconnected', this.handleDisconnected.bind(this)); + if (!this.device.disconnectHandlerAdded) { + this.device.addEventListener('gattserverdisconnected', this.handleDisconnected.bind(this)); + this.device.disconnectHandlerAdded = true; + } + this.notifyAll(this.onConnectedSubscribers); }); }