fix: add xr device index to sort index to try and keep the order consistent
Some checks are pending
/ cargo-fmtcheck (push) Waiting to run
/ cargo-clippy (push) Waiting to run
/ cargo-test (push) Waiting to run
/ appimage (push) Waiting to run

This commit is contained in:
Gabriele Musco 2024-08-26 19:07:48 +02:00
commit 76d71cb0c2
2 changed files with 8 additions and 4 deletions

View file

@ -45,7 +45,7 @@ pub struct DeviceRowModel {
battery_status: Option<EnvisionBatteryStatus>, battery_status: Option<EnvisionBatteryStatus>,
} }
#[derive(Debug, Default)] #[derive(Debug, Default, Clone)]
pub struct DeviceRowModelInit { pub struct DeviceRowModelInit {
pub title: Option<String>, pub title: Option<String>,
pub subtitle: Option<String>, pub subtitle: Option<String>,
@ -74,7 +74,9 @@ impl From<&XRDevice> for DeviceRowModelInit {
.iter() .iter()
.min() .min()
.unwrap_or(&XRDeviceRole::GenericTracker) .unwrap_or(&XRDeviceRole::GenericTracker)
.as_number(), .as_number()
* 1000
+ d.index,
..Default::default() ..Default::default()
} }
} }

View file

@ -237,7 +237,8 @@ impl From<DeviceRole> for XRDeviceRole {
pub struct XRDevice { pub struct XRDevice {
pub roles: Vec<XRDeviceRole>, pub roles: Vec<XRDeviceRole>,
pub name: String, pub name: String,
pub id: String, pub id: u32,
pub index: u32,
pub serial: Option<String>, pub serial: Option<String>,
pub battery: Option<BatteryStatus>, pub battery: Option<BatteryStatus>,
} }
@ -251,7 +252,8 @@ impl XRDevice {
( (
dev.index, dev.index,
Self { Self {
id: dev.id.to_string(), id: dev.id,
index: dev.index,
serial: dev.serial().ok(), serial: dev.serial().ok(),
battery: dev.battery_status().ok().and_then(|bs| { battery: dev.battery_status().ok().and_then(|bs| {
if bs.present { if bs.present {