From aaf47167b5bb2a4ac15e2cdfdfcac71498dcd7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 31 Jan 2022 23:40:39 +0100 Subject: [PATCH] status/bluetooth: Bail out and hide UI when there's no adapter While _sync() does already handle the case where there's no adapter just fine (hiding the item and the indicator), let's make the handling a bit more obvious and add an explicit check for !this._adapter where we bail out and hide the UI. Part-of: --- js/ui/status/bluetooth.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index a7768c824..d84bc3ad5 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -130,13 +130,20 @@ class Indicator extends PanelMenu.SystemIndicator { } _sync() { - let devices = this._getDeviceInfos(); + const adapterJustAppeared = !this._adapter && this._client.default_adapter; + this._adapter = this._client.default_adapter ?? null; + if (!this._adapter) { + this._item.visible = false; + this._indicator.visible = false; + return; + } + + const devices = this._getDeviceInfos(); const connectedDevices = devices.filter(dev => dev.connected); const nConnectedDevices = connectedDevices.length; - if (this._client.default_adapter && this._adapter) + if (!adapterJustAppeared) this._setHadSetupDevices(devices.length > 0); - this._adapter = this._client.default_adapter ?? null; let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;