Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't accidentally unpause the story when amp-access resolves. #17560

Merged
merged 1 commit into from Aug 20, 2018

Conversation

gmajoulet
Copy link
Contributor

It's hard to reproduce but the issue was:

  • Story is paused on render because amp-story-consent is displayed
  • amp-access resolves, and if the user is authorized, calls dispatch(Action.TOGGLE_ACCESS, false)
  • this action would set PAUSED_STATE to false and accidentally unpause the story

(See test case)

@@ -147,6 +147,11 @@ const actions = (state, action, data) => {
switch (action) {
// Triggers the amp-acess paywall.
case Action.TOGGLE_ACCESS:
// Don't change the PAUSED_STATE if ACCESS_STATE is not changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right fix? If I actually do sign in via another window and change my auth status, will this get triggered? Seems like it should be "don't unpause if we're still waiting for consent.". Should we have multiple states like "paused due to consent", "paused due to access", etc, then a single PAUSED_STATE that is true if any of the others are true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Unfortunately" you're right... This fix addresses this very problem, but that's it :(
So far we're safe because we use the paused state for consent, share menu, paywall, bookend, and these can never happen at the same time.

Because the access authorizations could resolve at any time, it's the first time we could have a conflict, if it resolves why the consent|share menu|bookend is displayed.

We could do:

  1. What you suggest. It's a bit complex but it's very likely the best and safest solution
  2. Define a rule where we pay attention that actions are a noop if the main property stays unchanged. Ie: TOGGLE_ACCESS, false is noop if ACCESS_STATE was already false (this PR). As long as consent, share menu, ..., can't happen at the same time, we should be safe.
    But we might have to do (1) eventually...

What do you think? Do you want to implement (1) right now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our conversation earlier, let's go ahead as-is until we prove out how difficult option 2 is.

@@ -147,6 +147,11 @@ const actions = (state, action, data) => {
switch (action) {
// Triggers the amp-acess paywall.
case Action.TOGGLE_ACCESS:
// Don't change the PAUSED_STATE if ACCESS_STATE is not changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our conversation earlier, let's go ahead as-is until we prove out how difficult option 2 is.

@gmajoulet gmajoulet merged commit 987c6ab into ampproject:master Aug 20, 2018
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants