zooniverse / front-end-monorepo

A rebuild of the front-end for zooniverse.org
https://www.zooniverse.org
Apache License 2.0
104 stars 30 forks source link

Classifier: previously seen tutorial opens after logging in. #2954

Closed eatyourgreens closed 2 years ago

eatyourgreens commented 2 years ago

Package

lib-classifier

Describe the bug

On a project like PH TESS, where I've already seen the tutorial, the tutorial will still open if I log in after the Classifier store has been created.

To Reproduce

Steps to reproduce the behavior:

  1. While signed out of Panoptes, visit https://www.zooniverse.org/projects/nora-dot-eisner/planet-hunters-tess/classify/workflow/11235.
  2. Dismiss the tutorial, which opens for all anonymous users.
  3. Sign in.
  4. The tutorial opens again, even if your project preferences mark it as seen.

Expected behavior

The tutorial should only open if I haven't seen it before.

Additional context

When you sign in, upp.loadingState should be reset, while your preferences load, so that tutorial.hasNotBeenSeen returns false here: https://github.com/zooniverse/front-end-monorepo/blob/afddbb4683c5664eea33d6889257316d5f5b5f11/packages/lib-classifier/src/store/TutorialStore/Tutorial/Tutorial.js#L21-L23

If the UPP loading state is still set to 'success', from the initial user check when the classifier mounted, then tutorial.hasNotBeenSeen will be true while your preferences load, which will then trigger the tutorial to open.

eatyourgreens commented 2 years ago

When I sign out on the PH TESS Classify page, then sign back in again, the UPP loading state is initially 'success' when it's first checked by the tutorial, while the UPP itself is undefined. When the loading state is 'success', the tutorial should always open for a logged-out user, so that could be where the bug is.

Screenshot of console logs showing user project preference state while logging in. During the first check of loading state, loading state is 'success' but UPP is undefined.
eatyourgreens commented 2 years ago

I gave this bug about an hour of time this morning, without getting anywhere useful. I'm going to have to put it down to focus on British Library work.

eatyourgreens commented 2 years ago

When I sign out in the project app, that change doesn't seem to be passed down to the classifier. 🤔

Here you can see that the classifier key, which is the current user ID, does not change to no-user after logging out.

Screenshot of the console log after logging out, showing that the classifier key is still 149, as if I am still logged in.

The classifier key is set here, in the classifier wrapper: https://github.com/zooniverse/front-end-monorepo/blob/0b1232ce7371ddc54c07e92f448bd848660957a3/packages/app-project/src/screens/ClassifyPage/components/ClassifierWrapper/ClassifierWrapper.js#L86-L93

eatyourgreens commented 2 years ago

I've opened #2962 for that auth bug, and #2963 to fix it.

eatyourgreens commented 2 years ago

Signing out (#2962) is a different bug from this one. I can reliably reproduce this bug if I log in when UPP.loadingState is set to 'success' in the classifier.

I'm not sure what the best approach to tackle this bug is. If you start to sign in, should we reset the user state to 'initialised'?

eatyourgreens commented 2 years ago

I’ve got a fix for this, but it involves a change to loadingState for all the resource stores in the classifierStore tree. I’ll hold off on opening a PR until I’m happy with that change.

eatyourgreens commented 2 years ago

Re-opening this because the bug has appeared again on staging. https://frontend.preview.zooniverse.org/projects/nora-dot-eisner/planet-hunters-tess/classify/workflow/11235