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 client-side duplicate comments bug on submit
and load more
#322
Fix client-side duplicate comments bug on submit
and load more
#322
Conversation
I can confirm manually, this is fixing the bug! |
@roschaefer Yesterday we discussed that you wanted to favor simplicity over complexity and asked to load the remaining comments all in one request (set "$limit" to "0"/"-1"). However, this does not work because default pagination settings are done in the API (https://github.com/Human-Connection/API/blob/develop/config/default.json#L9-L12).
I also read the FeathersJS documentation and found a link to feathersjs/feathers#382 (comment) which also sais it is a bad practice to let the client load all data at once. So I would say, we leave loading mechanism as it is right now, just applying this fix. Then you can also write your regression test ;) By the way, I've also found an issue with the _.uniq function not working as I expected which allowed the duplicates to be added to the store in the first place. It seems even though you load the same object from the API, the JS object is not identical. Therefore I explicitly compare the object _id now. You can easily test this by removing the $skip parameter from find(). That will certainly load the same data (from index 0 onward) again and again when you press "show more comments" or add/manipulate a comment. After I fixed it, there will be no more duplicates in the store. @mimicc83 @appinteractive |
@ionphractal you could set the limit to an insane amount, not pretty but would work. But loading all is really not a good practice. |
@ionphractal why do you use promise instead of async/await from es6? |
submit
and load more
@ionphractal and one more thing: When we go through the closed and recently updated pull requests later, we would like to tell by the titles what has changed 🙂 |
@appinteractive I think the "max" setting in the API config would then determine the limit. So you have to change it there, which is really not pretty :D @roschaefer Ok. |
Also I stumbled over an error in the example code of the Vuex/VueJS guide, see: vuejs/vuex#1425
After implementing tests I believe, the |
I think I'm done here. I was not able to expose the bug with a regression test. I still doubt that we really fixed this bug in In general, let's never recursively call async actions from now on, please. |
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.
See my comment, I'm unable to reproduce the bug with a test
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.
Seem's ok from my view
This PR fixes #321 .
The issue there is a race condition when the processing of the results too longer after loading additional comments from the API while calling fetchAllByContributionId.
It was either caused in https://github.com/Human-Connection/WebApp/blob/develop/store/comments.js#L54 or when loading additional comments via "Load more comments" button or when the page is loaded with a given comment ID.
You can simulate the race condition by changing https://github.com/Human-Connection/WebApp/blob/develop/store/comments.js#L90-L96 to
The bug was introduced in #256 because I previously assumed find() returns a Promise and treated it like that in https://github.com/Human-Connection/WebApp/blob/develop/store/comments.js#L65-L66.
The function now returns a proper Promise.
@roschaefer @appinteractive @Lulalaby Would you please test?