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
Add optimistic rendering to article reactions #681
Conversation
…timistic rendering later. No functional changes
I noticed that there is a version of the reaction buttons implemented in Preact which already has optimistic rendering. Is the plan to migrate that component over to that? |
@gatlee yeah, that is the plan. But I could see us merging this in the meantime. Since you're already engaged in this, would you be interested in attempting to rewrite the whole article reactions area as a preact component? It's not an immediate team priority, so we'll review and likely merge the current change unless you want to jump the line and write the preact version. Let me know what your capacity for this is. |
Awesome! I look forward to the feedback. Also, I'd be happy to work on a preact version of the component. I believe I'd be capable of doing so. I'll get working on it soon! |
Did a minor update to the code to revert the optimistic render on error. Not entirely sure why such a minor change resulted in a test failure however. |
@benhalpern On a side note: I haven't been able to work much on porting it to Preact since I've been quite busy. It might be better to review and merge this since in the meantime I probably won't have time to finish the port very soon I had a small technical question too. So far I've added a Reactions.jsx which loads with a Inside the Reactions.jsx I have this. document.addEventListener('DOMContentLoaded', () => {
const root = document.getElementById('article-reaction-actions');
const child = document.getElementById('article-reaction-child');
render(<Reactions />, root, child);
}); Which only renders my custom Reactions element when the page is refreshed but is not triggered when the user clicks an article (presumably because the DOM isn't reloaded when opening an article). I was wondering if you had some idea of what the best way would be to get the render to occur whenever an article is opened |
Hey @gatlee , where did you place the We use a modified version of instantclick, which changes the way site navigation works. If you place the No need to stress this, as there are probably better ways for this to be handled. |
The javascript_pack_tag is in the I found the proper event listener to use for InstantClick here which seems to work correctly. I should be good to go ahead now. Thanks for the help! |
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.
LGTM and thanks for this PR! Sorry it took us this long to review this. I went ahead and resolved the merge conflict.
No worries. Glad I could contribute! |
What type of PR is this? (check all applicable)
Description
Added optimistic rendering.
I am quite new to to this so I'm not sure how to write tests for it. If any tests should be written I can try to.
Additionally, ESLint tests did not pass after the commit. However, before I started work on the commit, it did not pass either. I have tried to the best of my ability to follow code guidelines in the areas I modified but have not refactored or cleaned up the other parts of the code.
Any suggestions are welcome!
Thanks
Gatlee Kaw
Related Tickets & Documents
#443
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?