Page MenuHomePhabricator

[identity] Reorder device list when updated
ClosedPublic

Authored by bartek on Dec 19 2023, 6:22 AM.
Tags
None
Referenced Files
F2153280: D10404.id35574.diff
Sun, Jun 30, 4:47 PM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Tue, Jun 25, 11:29 AM
Unknown Object (File)
Fri, Jun 14, 4:42 PM
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
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #35574)

Can we update the comment?

1060–1080 ↗(On Diff #35574)

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