Page MenuHomePhabricator

[identity] Reorder device list when updated
ClosedPublic

Authored by bartek on Dec 19 2023, 6:22 AM.
Tags
None
Referenced Files
F3396575: D10404.id35615.diff
Sun, Dec 1, 1:23 PM
Unknown Object (File)
Fri, Nov 22, 8:34 AM
Unknown Object (File)
Sun, Nov 17, 10:18 PM
Unknown Object (File)
Sat, Nov 9, 5:32 AM
Unknown Object (File)
Wed, Nov 6, 11:44 PM
Unknown Object (File)
Oct 18 2024, 3:57 AM
Unknown Object (File)
Oct 18 2024, 3:57 AM
Unknown Object (File)
Oct 18 2024, 3:57 AM
Subscribers

Details

Summary

Resolves ENG-5841. Each time we update the device list (login/register/logout), we should determine primary device and reorder the list accordingly.

Depends on D10400

Test Plan

Added unit tests for the reordering function. Also tested manually by:

  1. Register a user (mobile device)
  2. Log in the user on a "web" device
  3. Check database (or call GetDeviceListForUser RPC) - last device list entry has the following order (simplified for brevity): ["ios", "web"]

Now for web-only users:

  1. Register a user (mobile device)
  2. Call logout to remove the device
  3. Login with web - a log is displayed: "No valid primary device found..."
  4. Log in with mobile again. Check database - last device list entry has the following order: ["ios", "web"]. Mobile was added BEFORE web

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Dec 19 2023, 7:17 AM
services/identity/src/database/device_list.rs
1152 ↗(On Diff #34841)
services/identity/src/database/device_list.rs
1103–1106 ↗(On Diff #34841)

I could've used HashSet here because we only use map keys below

michal added inline comments.
services/identity/src/database/device_list.rs
780–782

Can we update the comment?

1060–1080

Possibly another option would be to make two HashSets and compare them

This revision is now accepted and ready to land.Jan 15 2024, 3:49 AM

Update comment, use HashSet difference