Skip to content

fix: address 6 code-review issues#23

Merged
daimpad merged 1 commit into
mainfrom
fix/code-review-issues
May 27, 2026
Merged

fix: address 6 code-review issues#23
daimpad merged 1 commit into
mainfrom
fix/code-review-issues

Conversation

@daimpad

@daimpad daimpad commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes 6 bugs surfaced by code review:

  • ui.js — ranking rows lose click handler after tab switch: showRankingTab was calling renderRankings() with no argument, resetting _onPlayerRowClick to null. Now passes the stored callback through.

  • chart.js — canvas destroyed by "no data" message: Both renderPlayerChart and renderEloChart were writing to parentElement.innerHTML, destroying the <canvas> node. Switching chart type then silently showed nothing. Fixed by appending a sibling <p> element and toggling canvas.style.display instead.

  • chart.js + state.js — column-shift workaround missing from chart: buildEloHistory had no fix for legacy Google Sheets data, causing the ELO chart to diverge from ranking table values. Extracted normaliseMatch() from state.js and used it in both places.

  • app.js — ghost ELO on save failure: persistPlayers/persistMatches ran before the Supabase write, leaving stale values in localStorage on network error. Moved persist calls inside the try block; on catch, rolls back state.matches and recalculates.

  • app.js — O(N) player updates on match delete: removeMatch was writing all N players back to Supabase. Now only writes the 2–4 players who appeared in the deleted match.

  • branding.js — 3-digit hex crashes darken/hexToRgba: Added expandHex() to convert #f00#ff0000 before slicing.

Test plan

  • All 56 unit tests pass (npm test)
  • Switch between Singles/Doubles ranking tabs — clicking a player row still opens their profile modal
  • Open a player profile with singles games, switch to Doubles tab (no data), switch back to Singles — chart renders correctly
  • Set primaryColor: '#f00' in config.js — app loads without broken CSS variables

https://claude.ai/code/session_01TgxiTLy7fCh5xZPJT8eTVt


Generated by Claude Code

- ui.js: showRankingTab now passes _onPlayerRowClick to renderRankings()
  so player rows stay clickable after switching ranking tabs
- chart.js: replace canvas.parentElement.innerHTML with a sibling <p>
  so the canvas is never destroyed when showing "no data" messages
- chart.js: use normaliseMatch() so legacy column-shifted matches are
  handled correctly in the ELO history chart
- state.js: extract normaliseMatch() so the column-shift workaround
  lives in one place instead of being duplicated across state/ui/chart
- app.js: move persistPlayers/persistMatches inside the try block and
  roll back state.matches on saveMatch failure (no more ghost ELO)
- app.js: removeMatch only writes back affected players, not all N
- branding.js: expand 3-digit hex (#f00) before slicing in darken/hexToRgba

https://claude.ai/code/session_01TgxiTLy7fCh5xZPJT8eTVt
@daimpad daimpad merged commit dd79813 into main May 27, 2026
1 check passed
@daimpad daimpad deleted the fix/code-review-issues branch May 27, 2026 19:03
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.

2 participants