From 76d71cb0c255b0bbb224ebee4a0c3fe22928b541 Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Mon, 26 Aug 2024 19:07:48 +0200 Subject: [PATCH] fix: add xr device index to sort index to try and keep the order consistent --- src/ui/factories/device_row_factory.rs | 6 ++++-- src/xr_devices.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ui/factories/device_row_factory.rs b/src/ui/factories/device_row_factory.rs index 73198c0..c7b5ef2 100644 --- a/src/ui/factories/device_row_factory.rs +++ b/src/ui/factories/device_row_factory.rs @@ -45,7 +45,7 @@ pub struct DeviceRowModel { battery_status: Option, } -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct DeviceRowModelInit { pub title: Option, pub subtitle: Option, @@ -74,7 +74,9 @@ impl From<&XRDevice> for DeviceRowModelInit { .iter() .min() .unwrap_or(&XRDeviceRole::GenericTracker) - .as_number(), + .as_number() + * 1000 + + d.index, ..Default::default() } } diff --git a/src/xr_devices.rs b/src/xr_devices.rs index 05d9904..5f8ee4c 100644 --- a/src/xr_devices.rs +++ b/src/xr_devices.rs @@ -237,7 +237,8 @@ impl From for XRDeviceRole { pub struct XRDevice { pub roles: Vec, pub name: String, - pub id: String, + pub id: u32, + pub index: u32, pub serial: Option, pub battery: Option, } @@ -251,7 +252,8 @@ impl XRDevice { ( dev.index, Self { - id: dev.id.to_string(), + id: dev.id, + index: dev.index, serial: dev.serial().ok(), battery: dev.battery_status().ok().and_then(|bs| { if bs.present {