[identity] Reorder device list when updated
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:
- Register a user (mobile device)
- Log in the user on a "web" device
- Check database (or call GetDeviceListForUser RPC) - last device list entry has the following order (simplified for brevity): ["ios", "web"]
Now for web-only users:
- Register a user (mobile device)
- Call logout to remove the device
- Login with web - a log is displayed: "No valid primary device found..."
- Log in with mobile again. Check database - last device list entry has the following order: ["ios", "web"]. Mobile was added BEFORE web
Reviewers: varun, michal
Reviewed By: michal
Subscribers: ashoat, tomek
Differential Revision: https://phab.comm.dev/D10404