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

Abort share fetches if the current user has changed #118

Closed
wants to merge 1 commit into from
Closed

Abort share fetches if the current user has changed #118

wants to merge 1 commit into from

Conversation

abridger
Copy link
Contributor

@abridger abridger commented May 2, 2017

Add a resetRequired flag to override the current fetch request and reset if the current user has changed while the request is being made. If the component is not fetching, and has already been populated, reset as normal. This feels slightly clumsy, but corrects an issue where users were being shown the shares of other users, or concatenations of user shares because the userId was only updating when the fetch request was already in progress. Setting a resetRequired flag allows the results of the existing request to be ignored, and a new request made with the updated user details.

Should fix this bug: https://trello.com/c/5v4YpJjr/452-first-time-going-in-on-a-user-who-does-not-have-any-pixel-kit-shares-you-see-other-peoples-pixel-kit-shares

Add a `resetRequired` flag to override the current fetch request and reset if the current user has changed while the request is being made. If the component is not fetching, and has already been populated, reset as normal. This feels slightly clumsy, but corrects an issue where users were being shown the shares of other users, or concatenations of user shares because the `userId` was only updating when the fetch request was already in progress. Setting a `resetRequired` flag allows the results of the existing request to be ignored, and a new request made with the updated user details.

Should fix this bug: https://trello.com/c/5v4YpJjr/452-first-time-going-in-on-a-user-who-does-not-have-any-pixel-kit-shares-you-see-other-peoples-pixel-kit-shares
// Abort the current request if a reset is required
if (this.resetRequired) {
this.reset();
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can use a more sophisticated way to cancel the fetch() request? whatwg/fetch#27

To be honest I feel we should cancel/abort/defer this request even before we get a result, no?
If we have a fetching property, wouldn't be nice to have the promise somewhere so we could just abort it and replace with something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've had a go at implementing cancelable promises in the PR for various other fixes: b547eff

This seems to fix the problem in a more elegant way, so I'll close this PR. We can always come back to this solution if things blow up in our faces.

Copy link
Contributor

Choose a reason for hiding this comment

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

WIIIIIN!!!

@abridger abridger closed this May 4, 2017
@abridger abridger deleted the user-creations branch May 26, 2017 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants