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)
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
Unknown Object (File)
Thu, Dec 5, 7:54 AM
Unknown Object (File)
Nov 5 2024, 4:33 AM
Unknown Object (File)
Nov 4 2024, 11:20 PM
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
Branch
arcpatch-D7156 (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

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