Skip to content

Commit

Permalink
Sort lookup devices by most recently used
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-snake committed Feb 26, 2025
1 parent b48baa0 commit 4d358de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/internet_identity/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,14 @@ fn lookup(anchor_number: AnchorNumber) -> Vec<DeviceData> {
let Ok(anchor) = state::storage_borrow(|storage| storage.read(anchor_number)) else {
return vec![];
};
anchor
.into_devices()
let mut devices = anchor.into_devices();
devices.sort_by(|a, b| b.last_usage_timestamp.cmp(&a.last_usage_timestamp));
devices
.into_iter()
.map(DeviceData::from)
.map(|mut d| {
// Remove non-public fields.
d.alias = "".to_string();
d.alias = String::new();
d.metadata = None;
d
})
Expand Down

0 comments on commit 4d358de

Please sign in to comment.