Remove UI window hooks and wire explicit runtime callbacks

This commit is contained in:
2026-02-07 01:45:52 +01:00
parent 37db70e67e
commit 78701cebf2
4 changed files with 32 additions and 20 deletions

View File

@@ -8,8 +8,8 @@ Active maintainability risks (priority order):
1. Frontend module concentration and global coupling (Critical)
- `wwwroot/js/ui.js` remains the dominant hotspot and owns rendering, modal flows, admin flows, and vote logic.
- Hidden module coupling still exists through global bridges in `wwwroot/js/data.js:131`-`wwwroot/js/data.js:134`, with consumers in `wwwroot/js/ui.js:473`, `wwwroot/js/ui.js:684`, and `wwwroot/js/ui.js:997`.
- Impact: high regression surface and expensive refactors.
- Cross-feature coupling still exists via shared mutable state usage across UI/data modules (`wwwroot/js/ui.js:180`, `wwwroot/js/ui.js:401`, `wwwroot/js/ui.js:622`, `wwwroot/js/data.js:82`).
- Impact: high regression surface and expensive refactors even after removing global `window` bridges.
2. Frontend refresh scheduling can overlap async work (High)
- Refresh loop is still interval-driven in `wwwroot/app.js:290` with async work rooted in `wwwroot/js/data.js:82`.
@@ -29,11 +29,11 @@ Active maintainability risks (priority order):
## B) Active task list
[P1] Decompose frontend UI monolith and remove `window` cross-module hooks
[P1] Decompose frontend UI monolith by feature
- Problem: Severity `High`, Category `Architecture/Complexity`. `ui.js` still mixes rendering, form behavior, and mutation flows.
- Evidence: `wwwroot/js/ui.js:390`, `wwwroot/js/ui.js:684`, `wwwroot/js/ui.js:997`, `wwwroot/js/data.js:131`, `wwwroot/js/data.js:134`.
- Recommendation: split by feature (`suggestions-ui`, `votes-ui`, `admin-ui`, `modals-ui`) and replace `window.*` callbacks with explicit imports/events.
- Acceptance criteria (testable): no feature path depends on `window.refreshPhaseData`, `window.loadVoteData`, or `window.loadSuggestData`.
- Evidence: `wwwroot/js/ui.js:180`, `wwwroot/js/ui.js:401`, `wwwroot/js/ui.js:622`, `wwwroot/js/ui.js:903`, `wwwroot/js/data.js:82`.
- Recommendation: split by feature (`suggestions-ui`, `votes-ui`, `admin-ui`, `modals-ui`) and keep orchestration in a thin composition layer.
- Acceptance criteria (testable): UI behavior is preserved while feature modules own isolated responsibilities and no single file coordinates all vote/admin/modal/suggestion interactions.
- Effort / Risk: `L / Med`.
- Dependencies (if any): none.
@@ -79,7 +79,7 @@ Active maintainability risks (priority order):
## C) Suggested execution order
1. Decompose `ui.js` and remove `window` hooks.
1. Decompose `ui.js` by feature and keep orchestration thin.
2. Introduce serialized refresh scheduler.
3. Remove `Reveal` phase compatibility branches.
4. Normalize/declare unauthenticated 401 contract behavior.