feat(perf): remove window event listeners on component unmount#13176
Open
GretaD wants to merge 2 commits into
Open
feat(perf): remove window event listeners on component unmount#13176GretaD wants to merge 2 commits into
GretaD wants to merge 2 commits into
Conversation
… getEnvelopeTags result in computed properties. avoid unnecessary array copy in sortedEnvelops computed Signed-off-by: greta <gretadoci@gmail.com>
| mounted() { | ||
| this.sortOrder = this.mainStore.getPreference('sort-order', 'newest') | ||
| document.addEventListener.call(window, 'mailvelope', () => this.checkMailvelope()) | ||
| window.addEventListener('mailvelope', this.checkMailvelope) |
Member
There was a problem hiding this comment.
I'd be worried that the method is invoked with the wrong context. Is Vue binding them automagically?
| } | ||
| }, | ||
|
|
||
| beforeUnmount() { |
…. cache getEnvelopeTags result in computed properties. avoid unnecessary array copy in sortedEnvelops computed Signed-off-by: greta <gretadoci@gmail.com>
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.
Changes in this PR:
Envelope.vue — deduplicate store getter calls + resize listener leak
getEnvelopeTags(this.data.databaseId) was being called separately inside
both isImportant and tags on every render. Since Envelope is rendered once
per message in a list, this doubles the store lookups per envelope per
render cycle. The new envelopeAllTags computed property calls it once and Vue caches the result, both isImportant and tags then read from the cache and only recompute when the store data actually changes. The resize listener had the same leak as above added in mounted() but never removed. The new beforeUnmount hook fixes that.
EnvelopeList.vue—remove unnecessary array copy + deduplicate tag lookups
[...this.envelopes] was creating a full array copy on every computed
evaluation with no reason to, the spread was defensive but the computed
property is read-only. With large mailboxes, this is a pointless allocation on every render.
isAtLeastOneSelectedImportant and isAtLeastOneSelectedUnimportant were each
iterating selectedEnvelopes and calling getEnvelopeTags per envelope, so N selected envelopes meant 2N store calls. The new selectedEnvelopeTags computed property fetches tags once for all selected envelopes, and both computed properties read from that cache.
🤖 AI (if applicable)