Page MenuHomePhabricator

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

Authored by kamil on Thu, Jun 6, 4:19 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 28, 11:36 AM
Unknown Object (File)
Sat, Jun 22, 1:08 AM
Unknown Object (File)
Fri, Jun 21, 6:24 PM
Unknown Object (File)
Thu, Jun 20, 11:07 PM
Unknown Object (File)
Thu, Jun 20, 5:00 PM
Unknown Object (File)
Wed, Jun 19, 2:26 PM
Unknown Object (File)
Mon, Jun 17, 1:22 PM
Unknown Object (File)
Mon, Jun 17, 12:13 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.Thu, Jun 6, 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.Fri, Jun 7, 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