Release 0.3 : Telescope and The Quest for Infinity.... Scroll
Welcome adventurers, sit down while I tell a little story of a brave programmer who slayed an issue so boldly, his PR request broke a record all time high of 57 comments.
Alright so Release 0.3. Got it done right on time, just by the hair... I took on an issue on Telescope that was to add paging functionality to the search results, which also related to the another issue which is to enable infinite scrolling to the same component. Prior to this, humphd (our valiant maintainer and professor, whos been reviewing like a million PRs for the past few days.) has already added the SWR react hook to implement the same feature but on the home page feed. So I used that as a reference point.
I started work on the issue and first tried to implement the swr react hook with the current search components we had. This was confusing and tricky since with a search page we want to wait for the parameters for the search to be entered and then wait for the user to click the search button before making our fetch call, so I tried to figure out a way to make it work for about a day and was really stumped, I couldn't get it working. I got the backend to fetch for the right data but getting the front end to fetch and infinitely scroll was tough.
Luckily around this time, PRs are getting merged and reviewed left and right, and some include the same components that I was working on. Well thanks to PR #1343 it turns out our prof and another student had already made changes to the search components so that a new component for search results would be the one fetching requests with the SWR react hook. This was great for me because that was the part I needed figuring out, and it was already done. However it still needed the infinite scrolling functionality which I've been reading docs on the past few days so I kind of had an idea of what to do.
So I switched the swr function from the regular one to swrInfinite which will enable infinite scrolling. Passed the next page function to the timeline component which will increment the page index when fetching for results and made the edits to the backend to accept the new page parameters in the query. And would you believe it worked! The posts load as you scroll down to the bottom of the page.
It just keeps scrolling! |
For the most part I thought I was done, I'll submit a PR and maybe get a few requested changes in. Boy was I wrong..... Merged finally at a total of 57 comments, I think I must have revised the code with @humphd for about 2-3 days. But it was a good learning experience because he pointed out a lot of discrepancies in my code and suggested ways to code it better.
57..... |
Anyways, after a few days of back and forth reviews and revisions and happily obliging to the profs requests, it's finally merged to the master and I can sleep comfortably knowing that anyone using the search results will now infinitely scroll to their hearts desires
Thanks for reading!
Comments
Post a Comment