Skip to content

DEV: Reduce unnecessary UI updates when posts change #33918

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

Merged
merged 5 commits into from
Jul 29, 2025

Conversation

megothss
Copy link
Contributor

@megothss megothss commented Jul 29, 2025

This PR refactors the post update logic in the post stream and store services to minimize unnecessary UI rerenders:

  • In StoreService, properties are selectively updated: only changed values are applied, preventing redundant updates and improving render efficiency.
  • Uses untrack to avoid creating unwanted Glimmer tracking contexts during property comparisons, reducing computation errors.
  • All property updates are batched to trigger a single rerender.

This PR is improves #33864 which was reverted by #33917 due to the possibility of tracking errors in edge cases.

megothss added 5 commits July 25, 2025 14:01
Replaced promise chaining with async/await syntax to improve clarity and handle asynchronous logic. Added JSDoc comments to document method parameters and behavior.

Updated logic to conditionally preserve cooked HTML and ensure the topic reference is correctly updated.
Updated property assignment logic in `store` to only update changed values, preventing unnecessary rerenders in Glimmer.
Removed unnecessary resolved promise and streamlined the return behavior for cases where `postId` is not provided.
Introduced `untrack` and `deepEqual` to optimize property comparisons. Updated logic to batch property updates, ensuring rerenders are only triggered when necessary.
Prevents max call stack errors in the comparison logic by replacing `deepEqual` with a strict equality check (`===`).
@megothss megothss merged commit 216df43 into main Jul 29, 2025
16 checks passed
@megothss megothss deleted the dev/prevent-rerenderings branch July 29, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants