Page MenuHomePhabricator

[lib] update device list when updating `UserStore`
ClosedPublic

Authored by kamil on Jun 6 2024, 4:19 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 3:07 PM
Unknown Object (File)
Wed, Nov 20, 2:40 PM
Unknown Object (File)
Wed, Nov 20, 2:40 PM
Unknown Object (File)
Sat, Nov 2, 12:06 AM
Unknown Object (File)
Sat, Nov 2, 12:03 AM
Unknown Object (File)
Sat, Nov 2, 12:03 AM
Unknown Object (File)
Sat, Nov 2, 12:03 AM
Unknown Object (File)
Fri, Nov 1, 11:42 PM
Subscribers

Details

Summary
Test Plan
  1. Add this code to master (with usingCommServicesAccessToken = true) and check if device lists are populated.
  2. Make change in user store (e.g. add user) and verify is device list is fetched for this user.
  3. Make sure this effect does not re-render when not needed.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kamil held this revision as a draft.
lib/selectors/user-selectors.js
217 ↗(On Diff #41036)

commbot is the only user without a device list - we want to avoid calling Identity to get that

kamil published this revision for review.Jun 6 2024, 4:27 AM
lib/handlers/user-infos-handler.react.js
82–93 ↗(On Diff #41036)

We would typically use dispatchActionPromise here, but I talked to Kamil about this and he doesn't need to have a failed action, nor a loading status for this action. So I think this is fine. We should just make sure this code doesn't result in errors - can getDeviceListsForUsers throw?

tomek added inline comments.
lib/handlers/user-infos-handler.react.js
82–93 ↗(On Diff #41036)

I don't think there's a good reason to not use dispatchActionPromise, but it's up to you.

lib/selectors/user-selectors.js
213–214 ↗(On Diff #41036)

You can use a shorthand when a lambda contains only the return statement.

lib/handlers/user-infos-handler.react.js
82–93 ↗(On Diff #41036)

can getDeviceListsForUsers throw?

Added try catch block

I don't think there's a good reason to not use dispatchActionPromise, but it's up to you.

In this case dispatchActionPromise seems like an overkill - a lot more code/types to add and we'll end up polluting redux with dispatched actions that'll never be handled but I can update this as you suggested. However, I'd prefer to do it in a separate diff with other improvements: ENG-8384.

This revision is now accepted and ready to land.Jun 7 2024, 7:08 AM
lib/selectors/user-selectors.js
217 ↗(On Diff #41036)

Good call-out. For now we don't have a good solution for this. Eventually we'll probably want to add a device list for this user, but not a priority for now