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
Don't accidentally unpause the story when amp-access resolves. #17560
Conversation
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- What you suggest. It's a bit complex but it's very likely the best and safest solution
- Define a rule where we pay attention that actions are a noop if the main property stays unchanged. Ie:
TOGGLE_ACCESS, false
is noop ifACCESS_STATE
was alreadyfalse
(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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
It's hard to reproduce but the issue was:
amp-story-consent
is displayedamp-access
resolves, and if the user is authorized, callsdispatch(Action.TOGGLE_ACCESS, false)
PAUSED_STATE
tofalse
and accidentally unpause the story(See test case)