Skip to content

fix: clean up theme matchMedia listener to prevent leak#125

Merged
EVWorth merged 2 commits into
EVWorth:mainfrom
ozantaybas:fix/theme-listener-cleanup
Jun 5, 2026
Merged

fix: clean up theme matchMedia listener to prevent leak#125
EVWorth merged 2 commits into
EVWorth:mainfrom
ozantaybas:fix/theme-listener-cleanup

Conversation

@ozantaybas
Copy link
Copy Markdown
Contributor

What

The change listener on the matchMedia("(prefers-color-scheme: dark)")
query in themeStore.ts was added but never removed, leaking the listener.

How

Extracted the handler and the MediaQueryList into named references, and
added an exported cleanupThemeListener() to allow proper removal.
Behavior is unchanged.

Testing

Added a unit test verifying cleanupThemeListener() calls
removeEventListener with the same handler. All themeStore tests pass
(11/11) and type-check is clean.

Closes #117

@ozantaybas
Copy link
Copy Markdown
Contributor Author

Heads up: the failing Frontend CI check is unrelated to this PR.
All 10 failures come from src/components/editor/QueryToolbar.tsx:346
(Cannot destructure property 'limitEnabled' of 'useSettingsStore(...)'),
which this PR doesn't touch — it only changes themeStore.ts and its test.
The themeStore tests pass (11/11) locally and type-check is clean.
The Rust checks also appear unrelated to a frontend-only change.
Happy to rebase if you'd like once that unrelated test is fixed.

@EVWorth EVWorth merged commit 14cc345 into EVWorth:main Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Theme store matchMedia event listener never cleaned up

2 participants