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

FIXES full screen leaderboard out of order when webhook returns new data #757

Closed

Conversation

husseinizaid
Copy link

This commit centralizes the leaderboard sorting logic within the useEffect hooks in the ScuntLeaderboard component. Previously, sorting was redundantly applied in individual child components.

Contribution:

Changes include:

  • Refactor in ScuntLeaderboard Component: Centralized the sorting logic within the useEffect hooks to handle updates from 'scores' and 'update' events. Ensured that the leaderboard state is sorted just once when the data is received or updated.
  • Update in Child Components: Removed local sorting logic in ScuntLeaderboardMobile and other child components. Adjusted these components to use the sorted leaderboard data as passed from the parent component (ScuntLeaderboard).
    -Prop Passing: Updated the ScuntLeaderboardShow component to correctly pass down the sorted leaderboard data to its child components.

These updates enhance the maintainability and consistency of the leaderboard's order across the application.

Issue:

When leaderboard full screen, teams are ordered based on points but as soon as the leaderboard data gets updated via webhook, the order is no longer retained

Closes #571

Accomplishments:

Consistency Across Components: By centralizing the sorting logic, we've ensured that all components reflect a consistent order of the leaderboard data.
Reduced Redundancy: Eliminated redundant sorting in child components, thereby simplifying the codebase and enhancing maintainability.
Resolved Issue #571: Addressed the main concern of the leaderboard order getting disrupted upon receiving new data, ensuring a seamless and consistent user experience.

…ffect hooks in the ScuntLeaderboard component. Previously, sorting was redundantly applied in individual child components
@jameskokoska
Copy link
Collaborator

ECE444?

Copy link
Collaborator

@Freeassassin Freeassassin left a comment

Choose a reason for hiding this comment

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

Looks good! Solid job on identifying where to sort the array in the frontend to ensure that the correct state gets passed down. However, the implementation that I think would have been more optimized is what I implemented here a5fe4cd. This way the array gets sorted at the backend level meaning that it is the most optimized since it is run as database query. Meaning that there is no need for "time consuming" computations in the frontend that can slow down the website load times (in this case its just a sort but you get the idea).

Sorry that the issue was still marked as open while we had fixed it in hot fixes committed to the production branch 😬I still need to consolidate the code together a bit. But I guess it also provides a chance to take a look at the solution we ended up implementing. And just for full transparency, here fe85b34 I still sorted the array in the frontend for some reason lol.

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.

Full screen leaderboard out of order when webhook returns new data
3 participants