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

Fix optimistic response for cached games #59

Merged
merged 1 commit into from
Jun 13, 2021

Conversation

GuilleAngulo
Copy link
Contributor

@GuilleAngulo GuilleAngulo commented May 27, 2021

Issue

At the explore page, the apollo cache is used to store the games and the optimistic response with the empty game is being pushed inside the cache overwriting the game fragment and producing a flash (with an empty game). This only happens here, as the other pages are not using the cache to store the games (index, game/[slug], ...).

Proposed Solution

In order to fix it, the optimisticGameResponse is modified to read the game fragment from cache (by using the id) and an optimistic response is created based on it if available. Otherwise, it will continue creating an empty structure response with the id as it does not have a negative impact when the game is not cached. This way both cases (with cache and without) are covered.

Hopefully now everything is working as expected.

@willianjusten
Copy link
Member

Awesome work! Tested and now works perfectly!

@willianjusten willianjusten merged commit e5f7619 into Won-Games:master Jun 13, 2021
@GuilleAngulo
Copy link
Contributor Author

Greeat! Thanks!

@GuilleAngulo GuilleAngulo deleted the optimistic_wishlist branch June 14, 2021 12:50
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.

2 participants