Fix: Resolve memory leaks and improve menu update reliability#129
Merged
Conversation
|
Good work! Looks like the original author is not super active anymore, maybe time for a fork? |
Contributor
Author
|
Yeah, unfortunately it seems the original owner has gone quiet. Let’s give it a bit more time and hope they come back – but if not, I’d be happy to help get this back on track. |
Owner
|
Great work, i will merged the changes. Thank you for your work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hello,
This pull request addresses several critical issues in the
sidebar-cardrelated to memory leaks and unreliable state updates. The changes ensure that the card is more performant, stable, and robust, especially in dynamic environments where views are frequently changed.Key Fixes and Improvements:
1. Resolved Critical Memory Leaks
setIntervaltimers (for the clock and date) and globalwindowevent listeners but never cleaned them up. When the card was removed from the DOM (e.g., by navigating to another view), these timers and listeners would continue to run in the background, consuming memory and CPU resources.connectedCallback()anddisconnectedCallback()lifecycle methods to properly manage resources._clockInterval,_dateInterval).clearInterval()and event listeners are properly removed withremoveEventListener()insidedisconnectedCallback(), preventing any resource leaks.2. More Reliable Active Menu State
clickevent listeners onpaper-tabelements and a direct call within the_menuAction()method. This could fail if navigation was triggered by other means and could lead to race conditions.location-changedevent. This is a far more robust and centralized approach that correctly reflects the application's current path.location-changedevent handler is bound to the component instance in the constructor to ensure the correctthiscontext._updateActiveMenu()call has been removed from the_menuActionhandler.3. General Code Structure
0.1.9.7.0to reflect these important fixes.These changes significantly improve the stability and performance of the
sidebar-card. Thank you for considering this contribution!