Page MenuHomePhabricator

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

Authored by atul on Mar 23 2023, 10:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 3:04 AM
Unknown Object (File)
Thu, Mar 28, 3:03 AM
Unknown Object (File)
Thu, Mar 28, 3:03 AM
Unknown Object (File)
Thu, Mar 28, 3:02 AM
Unknown Object (File)
Thu, Mar 28, 2:52 AM
Unknown Object (File)
Mar 13 2024, 11:48 PM
Unknown Object (File)
Mar 7 2024, 5:57 AM
Unknown Object (File)
Mar 7 2024, 5:57 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