Skip to content

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

Merged
JuliaKalder merged 3 commits into
mainfrom
fix/issue-118
Jun 3, 2026
Merged

fix: extract shared filterTemplates() to eliminate duplication (#118)#191
JuliaKalder merged 3 commits 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

JuliBot and others added 3 commits May 18, 2026 23:06
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
# Conflicts:
#	modules/ui-helpers.js
#	options/options.js
#	popup/popup.js
@JuliaKalder JuliaKalder merged commit 6d76131 into main Jun 3, 2026
1 check passed
@JuliaKalder JuliaKalder deleted the fix/issue-118 branch June 3, 2026 12:52
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