Page MenuHomePhabricator

[lib] introduce savedEmojiAvatarSelectorForCurrentUser selector
ClosedPublic

Authored by ginsu on Apr 12 2023, 11:55 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 21, 1:00 PM
Unknown Object (File)
Fri, Jun 21, 11:36 AM
Unknown Object (File)
Fri, Jun 21, 6:38 AM
Unknown Object (File)
Sun, Jun 16, 7:29 AM
Unknown Object (File)
Wed, Jun 12, 2:00 PM
Unknown Object (File)
Fri, Jun 7, 6:01 AM
Unknown Object (File)
Fri, Jun 7, 5:53 AM
Unknown Object (File)
Fri, Jun 7, 5:18 AM
Subscribers

Details

Summary

Based on some feedback I got in D7359, when we "reset" the emoji avatar during the emoji avatar creation flow, we want to reset to the current state in redux which we are considering the source of truth. This is the selector that would be called in EmojiAvatarCreation to get the current emoji avatar from redux for the current user

Depends on D7401

Test Plan

The reset functionality behaves as expected as seen in the demo below

An example where we are getting a random default avatar:

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu added inline comments.
lib/selectors/user-selectors.js
220 ↗(On Diff #25051)

This is for the case if the user has an ens/image avatar already set as their current avatar and they want to switch to an emoji avatar

221 ↗(On Diff #25051)

I thought making the new default emoji avatar when you are creating a new emoji avatar would make the experience more dynamic; however, if we just want to use the default emoji avatar based off the hash function I created earlier I can switch this

ashoat added inline comments.
lib/selectors/user-selectors.js
221 ↗(On Diff #25051)

I like this idea

This revision is now accepted and ready to land.Apr 12 2023, 5:48 PM
lib/selectors/user-selectors.js
221 ↗(On Diff #25051)

That said, one thing that's weird here is that the random selection changes based on the inputs to the selector. If in the future we changed the selector to have a new param, then we might see the output of the selector randomly change.

In our case we actually aren't worried about this because we only do "spot checks" of this value (see D7403), once when EmojiAvatarCreation first renders and then once when onPressReset is called.

To better reflect that this is only used for spot checks, and that its value can change randomly, I think we should return a function (that takes no parameters) here. We do that elsewhere in the codebase in cases where the value can change randomly or over time.