💥 fix: slow start

the bluetooth module was trying to connect to the bluetooth service before it was ready
This commit is contained in:
retrozinndev
2025-10-03 21:46:08 -03:00
parent c4eb2a84ef
commit b835de79ef
+8 -3
View File
@@ -108,11 +108,18 @@ export class Bluetooth extends GObject.Object {
]
);
// async to prevent slow start
setTimeout(() => {
this.#lastDevice = this.getLastConnectedDevice();
this.notify("last-device");
}, 1200);
this.#connections.set(AstalBluetooth.get_default(), [
AstalBluetooth.get_default().connect("notify::devices", (_) => {
AstalBluetooth.get_default().connect("device-added", (_) => {
this.#lastDevice = this.getLastConnectedDevice();
this.notify("last-device");
}),
AstalBluetooth.get_default().connect("device-removed", (_) => {
this.#lastDevice = this.getLastConnectedDevice();
this.notify("last-device");
})
@@ -144,8 +151,6 @@ export class Bluetooth extends GObject.Object {
const lastDevice = connectedDevices[connectedDevices.length - 1];
console.log(`last device: ${lastDevice?.address}`);
return lastDevice ?? null;
}