Skip to content

fix: extract shared filterTemplates() to eliminate duplication (#118)#191

Open
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-118
Open

fix: extract shared filterTemplates() to eliminate duplication (#118)#191
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-118

Conversation

@JuliaKalder
Copy link
Copy Markdown
Owner

Summary

  • Extracted the duplicated filterTemplates() function from popup/popup.js and options/options.js into a new shared module modules/ui-helpers.js
  • The two implementations were structurally identical, differing only in the CSS selector used (.template-item vs .template-card)
  • Each consumer is now a one-liner that calls filterTemplateList(selector) from the shared module

Changes

  • New: modules/ui-helpers.js — exports filterTemplateList(itemSelector)
  • Updated: popup/popup.js — imports and delegates to filterTemplateList()
  • Updated: options/options.js — imports and delegates to filterTemplateList()

Testing

Ran existing test suite (npm test). The 7 pre-existing failures in migrateV0toV1 are unrelated to this change and present on main before this fix. No new failures introduced.

Fixes #118

Both popup.js and options.js contained identical filterTemplates()
implementations differing only in CSS selector (.template-item vs
.template-card). Extract to modules/ui-helpers.js as filterTemplateList()
with a selector parameter; each consumer becomes a one-liner wrapper.

Fixes #118
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.

[LOW] filterTemplates() duplicated between popup.js and options.js — same algorithm, different CSS selectors

1 participant