Page MenuHomePhabricator

[native] Add nux handler
ClosedPublic

Authored by inka on Aug 14 2024, 8:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 13, 9:44 PM
Unknown Object (File)
Tue, Nov 26, 8:33 PM
Unknown Object (File)
Tue, Nov 26, 12:03 PM
Unknown Object (File)
Wed, Nov 20, 12:35 PM
Unknown Object (File)
Wed, Nov 20, 12:35 PM
Unknown Object (File)
Wed, Nov 20, 12:35 PM
Unknown Object (File)
Wed, Nov 20, 12:35 PM
Unknown Object (File)
Wed, Nov 20, 12:34 PM
Subscribers

Details

Summary

issue: ENG-8537

Test Plan

Tested that when a user opens the app of the first time and logs in, the tips are displayed
Tested that a subsequent login doesn't result in tips being shown

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

inka added inline comments.
native/components/nux-handler.react.js
20–22 ↗(On Diff #43392)

I probably need to come up with a better condition, because this should probably only show up after registration, not after every login...

@tomek proposed using useOnFirstLaunchEffect

inka requested review of this revision.Aug 14 2024, 8:19 AM
native/components/nux-handler.react.js
20–22 ↗(On Diff #43392)

Ginsu recently introduced alertStore, which is meant to help with this sort of thing. Not sure if you're aware or using it already, but it lets us persist some state to say that an alert has already been shown, to avoid doing it multiple times

tomek requested changes to this revision.Aug 14 2024, 10:13 AM
tomek added inline comments.
native/components/nux-handler.react.js
30–34 ↗(On Diff #43392)

Can we create these params based on the specification of the tips (somewhere deeper in the stack where we have a mapping between a tip and a next tip)?

native/components/nux-tips-context.react.js
69 ↗(On Diff #43392)

We shouldn't mutate the content of the memo. If we need to do something like this, we should use a state and set a new value based on the old one.

This revision now requires changes to proceed.Aug 14 2024, 10:13 AM
native/components/nux-handler.react.js
20–22 ↗(On Diff #43392)

alertStore gets reset on logout, so it doesn't achieve what we want

tomek added inline comments.
native/components/nux-tips-context.react.js
30 ↗(On Diff #43503)
31–35 ↗(On Diff #43503)

Interesting approach, and gets the job done! It might be quite confusing because firstTip isn't a tip and it doesn't make sense for it to have a tooltipLocation, but I don't think we have to spend too much time searching for a better solution.

77 ↗(On Diff #43503)
91 ↗(On Diff #43503)

I think it would be even better if it was a memo instead.

92–100 ↗(On Diff #43503)

I don't think we have to create a copy of the value. You can also consider using values(nuxTip).every(type => tipsProps[type]).

This revision is now accepted and ready to land.Aug 20 2024, 7:30 AM
ashoat requested changes to this revision.Aug 20 2024, 1:17 PM

Requesting changes because it seems like alertStore can be used here, and I'd rather avoid reimplementing logic when we can share it instead

native/components/nux-handler.react.js
20–22 ↗(On Diff #43392)

Could we use a Redux migration to populate alertStore in such a way that the NUX won't get shown for clients that were logged-in at the time of the migration?

This revision now requires changes to proceed.Aug 20 2024, 1:17 PM

Open to building a separate mechanism here if it's necessary, or if the use case doesn't match alertStore very well, or if minimal code will be replaced because the existing approach is so simple. Curious for @tomek's take here as well

Open to building a separate mechanism here if it's necessary

Is using useOnFirstLaunchEffect bad somehow? Or do we care about the tips not showing up for users who are already logged in?

native/components/nux-handler.react.js
20–22 ↗(On Diff #43392)

That should not be a problem.
But my problem is that alertStore is reset when the user logs out. So when they log back in, they see the tips again. And I thought we only want to display tips after first launch of the app. Is that incorrect? Do we want to display the tips after every login?
(alertStore gets cleared by resetUserSpecificState, but I think this is correct)

Requesting changes because it seems like alertStore can be used here, and I'd rather avoid reimplementing logic when we can share it instead

I'm also really confused by this comment. We're using an existing mechanism and we're not reimplementing the logic. Also, it seems like useOnFirstLaunchEffect better expresses the requirements.

native/components/nux-tips-context.react.js
27–46 ↗(On Diff #43503)

I was thinking about it and it seems we can avoid introducing an artificial entry by storing the first tip as a separate variable. Would that work?

inka requested review of this revision.Aug 22 2024, 4:07 AM

Requesting review since both me and @tomek are a bit confused

I don't love that we have two separate mechanisms for this. alertStore's purpose is to record when we show various alerts, and help us control how often we show them based on when they're been shown before. That's basically this use case as well. If there are some differences, I would think it would be better to extend alertStore to do what we want here (eg. use useOnFirstLaunchEffect or persist in a similar fashion) rather than building a separate mechanism.

I'm going to resign as I'm heading to vacation starting tomorrow and it doesn't appear that we have the time to do things right here.

native/components/nux-handler.react.js
49 ↗(On Diff #43503)

Will useOnFirstLaunchEffect re-run the NUX if the user logs out and back in as another account? (Not sure what we desire here, but I'd like to understand it better)

I don't love that we have two separate mechanisms for this. alertStore's purpose is to record when we show various alerts, and help us control how often we show them based on when they're been shown before. That's basically this use case as well. If there are some differences, I would think it would be better to extend alertStore to do what we want here (eg. use useOnFirstLaunchEffect or persist in a similar fashion) rather than building a separate mechanism.

I'm going to resign as I'm heading to vacation starting tomorrow and it doesn't appear that we have the time to do things right here.

Ahhh, ok. So the NUX tips are kind of alerts, and we think that they should the same mechanism the alerts use. That makes sense to me, but the approach from this diff is pragmatic - we're using an existing utility that doesn't introduce any new logic. I don't think this code will change frequently, and if we ever decide to modify the logic, we could then modify it to use the alert store.

rather than building a separate mechanism.

This still confuses me. We're using an existing mechanism, that is really generic and we're not modifying it in any way. Not sure what is the new thing we're building here.

native/components/nux-handler.react.js
49 ↗(On Diff #43503)

This will run only once. Only uninstalling the application will allow rerunning the function.

Not sure what we desire here

I believe that it is unlikely that someone new will log in to the app where another person has logged out. So we can assume, that usually when one person sees the NUX, we don't need to show them it again after logging in again (even as another account because it is likely the same person).

native/components/nux-tips-context.react.js
27–46 ↗(On Diff #43503)

No, because we need these other params when we navigate to the community drawer tip

92–100 ↗(On Diff #43503)

I have to do it for flow

Address review, move handler (ENG-9085)

This revision is now accepted and ready to land.Aug 23 2024, 5:12 AM
This revision was automatically updated to reflect the committed changes.