mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
chore(bt): unified get/setDeviceAutoConnect to use similar arguments
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user