Skip to content

feat(perf): remove window event listeners on component unmount#13176

Open
GretaD wants to merge 2 commits into
mainfrom
feat/performance-improvement
Open

feat(perf): remove window event listeners on component unmount#13176
GretaD wants to merge 2 commits into
mainfrom
feat/performance-improvement

Conversation

@GretaD

@GretaD GretaD commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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)

  • The content of this PR was partly or fully generated using AI

… getEnvelopeTags result in computed properties. avoid unnecessary array copy in sortedEnvelops computed

Signed-off-by: greta <gretadoci@gmail.com>
@GretaD GretaD self-assigned this Jun 29, 2026
@GretaD
GretaD marked this pull request as ready for review July 6, 2026 13:03
mounted() {
this.sortOrder = this.mainStore.getPreference('sort-order', 'newest')
document.addEventListener.call(window, 'mailvelope', () => this.checkMailvelope())
window.addEventListener('mailvelope', this.checkMailvelope)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd be worried that the method is invoked with the wrong context. Is Vue binding them automagically?

Comment thread src/components/AppSettingsMenu.vue Outdated
}
},

beforeUnmount() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this ever happen?

…. cache getEnvelopeTags result in computed properties. avoid unnecessary array copy in sortedEnvelops computed

Signed-off-by: greta <gretadoci@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants