Page MenuHomePhabricator

[lib] introduce savedEmojiAvatarSelectorForCurrentUser selector
ClosedPublic

Authored by ginsu on Apr 12 2023, 11:55 AM.
Tags
None
Referenced Files
F3281761: D7402.id25051.diff
Sat, Nov 16, 10:11 AM
Unknown Object (File)
Sun, Nov 10, 1:12 PM
Unknown Object (File)
Tue, Nov 5, 4:15 AM
Unknown Object (File)
Sun, Oct 27, 2:19 AM
Unknown Object (File)
Sun, Oct 27, 2:19 AM
Unknown Object (File)
Sun, Oct 27, 2:19 AM
Unknown Object (File)
Sun, Oct 27, 2:19 AM
Unknown Object (File)
Sun, Oct 27, 2:19 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
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu added inline comments.
lib/selectors/user-selectors.js
220

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

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

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

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.