Page MenuHomePhabricator

[lib] Update `CurrentUserInfo` on `updateUserAvatarActionTypes.success`
ClosedPublic

Authored by atul on Mar 23 2023, 10:27 AM.
Tags
None
Referenced Files
F3551431: D7156.id24035.diff
Thu, Dec 26, 7:20 PM
F3551178: D7156.id24084.diff
Thu, Dec 26, 7:15 PM
F3551060: D7156.id24085.diff
Thu, Dec 26, 7:09 PM
Unknown Object (File)
Fri, Dec 6, 2:16 PM
Unknown Object (File)
Thu, Dec 5, 7:55 AM
Unknown Object (File)
Thu, Dec 5, 7:55 AM
Unknown Object (File)
Thu, Dec 5, 7:55 AM
Unknown Object (File)
Thu, Dec 5, 7:54 AM
Subscribers

Details

Summary

We want to update CurrentUserInfo in Redux on successful updateUserAvatarActionTypes.success.

Test Plan
  1. Observe that avatar is set:

3edb41.png (354ร—1 px, 68 KB)

  1. Send { type: 'remove' } to update_user_avatar and observe that the avatar is unset in Redux:

19b553.png (306ร—1 px, 52 KB)

  1. Send
const emojiUpdateRequest = {
  type: 'emoji',
  emoji: '๐Ÿ‘',
  color: '4b87aa',
};

to update_user_avatar and observe that CurrentUserInfo is updated as expected:

bf091a.png (272ร—1 px, 49 KB)


Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul published this revision for review.Mar 23 2023, 10:33 AM
atul added inline comments.
lib/reducers/user-reducer.js
97โ€“101 โ†—(On Diff #24035)

This condition doesn't "smell right," but it's the only approach I could think of that made flow happy. Should I be doing this differently?

All the other action handlers in reduceCurrentUserInfo update CurrentUserInfo "atomically." As in they either keep or replace CurrentUserInfo "in one go." None of them modify a single field of the object at a time.

The state check is to determine whether the existing ?CurrentUserInfo is truthy, and the !state.anonymous check is to ensure that the existing ?CurrentUserInfo is a ?LoggedInUserInfo (LoggedOutUserInfo doesn't have an avatar field).

ashoat added inline comments.
lib/reducers/user-reducer.js
97โ€“101 โ†—(On Diff #24035)

It seems fine

This revision is now accepted and ready to land.Mar 23 2023, 7:37 PM
atul edited the test plan for this revision. (Show Details)

rebase and land