Skip to content

refactor: eliminate 7 clone groups across services, bot, and web#36

Merged
masmuss merged 6 commits into
mainfrom
refactor/cleanup-duplications
Jun 14, 2026
Merged

refactor: eliminate 7 clone groups across services, bot, and web#36
masmuss merged 6 commits into
mainfrom
refactor/cleanup-duplications

Conversation

@masmuss

@masmuss masmuss commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Changes

Eliminated 7 of 9 clone groups (395→97 lines, 4.4%→1.1% duplication).

HIGH — report.service.ts

  • Extracted ticketDetailsWith constant — shared with query block between getTicketById and getTicketByTicketCode
  • Extracted requireTicket(tx, id) — shared "find or throw" helper for updateTicketStatus and updateTicketPriority
  • -58 lines

HIGH — category.actions.server.ts

  • Extracted getCategoryFromForm(event) — shared form parsing + lookup for deleteCategoryAction and toggleCategoryAction
  • -17 lines

MEDIUM — settings / categories pages

  • Extracted useCategoryDialog() Svelte 5 composable (.svelte.ts) — shared category CRUD dialog state between settings-categories-tab.svelte and categories/+page.svelte
  • -27 lines

LOW — table-state.svelte.ts

  • Extracted buildQuery(state), toggleSortInPlace(), hasSimpleFilters(), stateGetters() as module-level functions shared by both createTableState and createSimpleTableState
  • Eliminated 3 clone groups (62+24 lines)
  • -135 lines

LOW — commands.ts (bot)

  • Extracted requireReporter(ctx) — shared registration check between /status and /report handlers
  • -5 lines

Verification

  • tsc --noEmit passes for services, bot, web
  • svelte-check passes with 0 errors
  • Pre-commit hooks pass on all 5 commits

Remaining (intentionally skipped)

  1. data-table.svelte / progressive-table.svelte (34 lines) — different configs, co-located
  2. agents-table.svelte / invite-codes-table.svelte (15 lines) — import block only

masmuss added 6 commits June 14, 2026 21:27
… report.service; extract getCategoryFromForm in category.actions
…d, replace SvelteURL with URL

- stateGetters(...) spread evaluates getters as plain values at spread time,
  killing reactivity. Reverted to inline getters in both createTableState and
  createSimpleTableState so getter descriptors are preserved.

- Added syncCount guard: the URL-watch  was reverting programmatic filter
  changes because goto is async — the effect runs before the URL actually updates,
  reads the stale URL, and restores the old filter state.

- Replaced SvelteURL with native URL in syncToURL to avoid any potential
  interference from SvelteURLSearchParams syncing back to the parent URL.
@masmuss masmuss merged commit e8e8149 into main Jun 14, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant