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 pagination bug #120

Merged
merged 9 commits into from
Aug 19, 2024
Merged

Fix pagination bug #120

merged 9 commits into from
Aug 19, 2024

Conversation

vantage-ola
Copy link
Owner

No description provided.

@vantage-ola vantage-ola linked an issue Aug 15, 2024 that may be closed by this pull request
Copy link

vercel bot commented Aug 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tracknow ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 5:34pm
tracknow-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 5:34pm

@vantage-ola
Copy link
Owner Author

the first two commits smash this issue #98

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 100 lines in your changes missing coverage. Please review.

Project coverage is 49.82%. Comparing base (4d8382b) to head (f2fe265).
Report is 12 commits behind head on main.

Files Patch % Lines
...acknow/web/src/components/User/UserAddLaptimes.tsx 0.00% 21 Missing ⚠️
tracknow/web/src/components/User/UserProfile.tsx 0.00% 21 Missing ⚠️
...ow/web/src/components/User/UserAccountSettings.tsx 0.00% 19 Missing ⚠️
tracknow/web/src/components/Post/Post.tsx 0.00% 11 Missing ⚠️
tracknow/web/src/components/Navbar/Navbar.tsx 0.00% 10 Missing ⚠️
tracknow/web/src/App.tsx 0.00% 7 Missing ⚠️
tracknow/web/src/components/MainLayout.tsx 0.00% 6 Missing ⚠️
tracknow/web/src/components/Home/Home.tsx 0.00% 4 Missing ⚠️
tracknow/web/src/components/User/UserLaptimes.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
- Coverage   50.48%   49.82%   -0.66%     
==========================================
  Files          39       40       +1     
  Lines        1141     1142       +1     
  Branches      152      149       -3     
==========================================
- Hits          576      569       -7     
- Misses        565      573       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -20,7 +17,24 @@ type PostProps = {
// homepage posts( recent) posts of users
export const HomePost: React.FC<PostProps> = ({ laptimes, fetchMoreData, hasMore }) => {

const { laptime_loading } = useLaptimes();
// intersection observation api instead of the bad infinite scroll component
Copy link
Owner Author

Choose a reason for hiding this comment

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

I resolved the bug by removing the InfiniteScroll component (an external library) from Post.tsx and replacing it with a custom Intersection Observer method to load more data. This approach is more efficient and reliable.

The InfiniteScroll component has a flaw: it requires additional pixels beyond the viewport height to trigger the loading of more data. This means that if you restrict the parent Flex component to 100vh, the component won't work correctly. For example:

<Flex height='100vh'> <InfiniteScroll /> </Flex>
In this scenario, the height must be greater than 100vh for the component to function properly. It's unclear how many extra pixels are needed to reach the 'end' of the page, making it impractical when you want to restrict the page height to 100vh and keep it in place.

By using a custom Intersection Observer method, I was able to achieve a more seamless and predictable infinite scrolling experience.

@vantage-ola
Copy link
Owner Author

I couldnt figure out how the new LiteYouTubeEmbed really works during render, so I will update the test for the misFunctions later. Using this new component helped fixes the bug where the iframe was always re-rendering and causing flickering issue while scrolling.

@vantage-ola vantage-ola merged commit 7158ea5 into main Aug 19, 2024
5 of 7 checks passed
@vantage-ola vantage-ola deleted the fix/pagination branch August 19, 2024 23:09
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.

home post pagination kinda broke 🥲
1 participant