chore(bt): unified get/setDeviceAutoConnect to use similar arguments

This commit is contained in:
Lemmy
2026-03-12 17:29:32 -04:00
parent 3679f7fca5
commit c15fb85c53
2 changed files with 6 additions and 6 deletions
@@ -668,15 +668,14 @@ Item {
spacing: Style.marginXS
visible: Settings.data.network.bluetoothAutoConnect
NIcon {
icon: BluetoothService.getDeviceAutoConnect(modelData.address) ? "repeat" : "repeat-off"
icon: BluetoothService.getDeviceAutoConnect(modelData) ? "repeat" : "repeat-off"
pointSize: Style.fontSizeXS
color: BluetoothService.getDeviceAutoConnect(modelData.address) ? Color.mPrimary : Color.mOnSurface
}
NCheckbox {
label: I18n.tr("common.auto-connect")
labelSize: Style.fontSizeXS
baseSize: Style.baseWidgetSize * 0.5
checked: BluetoothService.getDeviceAutoConnect(modelData.address)
checked: BluetoothService.getDeviceAutoConnect(modelData)
onToggled: checked => BluetoothService.setDeviceAutoConnect(modelData, checked)
}
}
+4 -3
View File
@@ -83,10 +83,11 @@ Singleton {
}
}
function getDeviceAutoConnect(mac) {
if (!mac || !cacheAdapter.autoConnectSettings) {
function getDeviceAutoConnect(device) {
if (!device || !device.address || !cacheAdapter.autoConnectSettings) {
return false;
}
const mac = device.address;
const settings = cacheAdapter.autoConnectSettings[mac];
return settings ? !!settings.autoConnect : false;
}
@@ -679,7 +680,7 @@ Singleton {
return;
}
_autoConnectQueue = adapter.devices.values.filter(dev => dev && dev.paired && !dev.connected && !dev.blocked && getDeviceAutoConnect(dev.address) === true);
_autoConnectQueue = adapter.devices.values.filter(dev => dev && dev.paired && !dev.connected && !dev.blocked && getDeviceAutoConnect(dev) === true);
if (root._autoConnectQueue.length > 0) {
autoConnectStepTimer.restart();