fix: move device list sorting to ViewModel

This commit is contained in:
andrekir 2024-11-11 17:58:15 -03:00
parent 7e54ad950c
commit 417523967e
2 changed files with 2 additions and 8 deletions

View file

@ -70,9 +70,7 @@ class BTScanModel @Inject constructor(
}
// Include paired Bluetooth devices
ble.bondedDevices.forEach {
addDevice(BLEDeviceListEntry(it))
}
ble.bondedDevices.map(::BLEDeviceListEntry).sortedBy { it.name }.forEach(::addDevice)
// Include Network Service Discovery
tcp.forEach { service ->

View file

@ -365,11 +365,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (devices == null) return
var hasShownOurDevice = false
devices.values
// Display the device list in alphabetical order while keeping the "None (Disabled)"
// device (fullAddress == n) at the top
.sortedBy { dle -> if (dle.fullAddress == "n") "0" else dle.name }
.forEach { device ->
devices.values.forEach { device ->
if (device.fullAddress == scanModel.selectedNotNull) {
hasShownOurDevice = true
}