ar(fix) ThunderBird calendar slows after editing one CalDav entry: draft: watch events prop drain #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context (REQUIRED):
This PR is being opened without local testing (to draft and test later, or for someone else to pickup with some reference).
Other than limiting the amount of events rendered by the returned CalDav source, another approach to solving this is to memoize the events as they're first received or locally stored, then use a SubPub pattern to trigger the update of the event metadata on-demand (user dragged, user resized event, user actually edited the event content), to re-render only the respective event.
Describe the bug (REQUIRED)
Currently, it seems like by
watching
theevents
prop, any update (visibility toggle, unsubscribe from calendar, update event details, etc.) triggers a re-render of the entireevents
prop dependency tree (whole calendar, every view, every mode, every event, etc).When manipulating an event or any calendar with multiple events repeated to infinity, it creates a drain of time complexity that crashes Thunderbird entirely.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I modify one event.
UI shows the updated data immediately (re-renders only the modified event).
I take any other action in the calendar and its events (except a global update e.g. color).
Not every event should re-render, but only the affected ones.
Screenshots
Screen.Recording.2025-01-23.at.02.10.37.mov
Additional context
This is my first PR with Thunderbird, it's under-tested, and I ask to pardon any imperfections. It's late here for me to make sure this PR works (setup local environment), but it might help shed some light to someone else with all the toolkit at hand.
How to test this PR**.
This PR is being opened without local testing (to draft and test later, or for someone else to pickup with some reference).