refactor room file structure - #584
Merged
Merged
Conversation
geoffrey-wu
added a commit
that referenced
this pull request
Sep 20, 2026
…vals on disconnect (#532) * fix: clean up empty multiplayer rooms and their cleanup intervals Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat: dark nav bar color on dark mode (#572) * Isolate singleplayer tossup card collapse state for repeated question IDs (#571) * Initial plan * Fix duplicate singleplayer tossup card DOM ids Co-authored-by: geoffrey-wu <42471355+geoffrey-wu@users.noreply.github.com> * make the uniqueId shorter * apply change to bonuses --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: geoffrey-wu <42471355+geoffrey-wu@users.noreply.github.com> Co-authored-by: Geoffrey Wu <geoffreywu1000@gmail.com> * /api/set-list: fix default so there’s no limit * set default limit higher * Add URL-synced tokenized set-name search to /db/set-list (#576) * Refactor mixin abstract methods and add generic typing (#578) * Refactor mixin abstract methods and add generic typing * remove comments * run `npm audit fix` * fix ObjectId import for webpack and browser * multiplayer: add toggle correct for owners in private rooms (#580) * move toggleCorrect to TossupRoom.js * implement toggleCorrect permissions * implement logic for multiplayer * implement logic wrt public and private rooms * Refactor message protocol (#581) * barebones implementation * move setReadingSpeed to QuestionRoom * move SET_USERNAME handling to Room * remove redundant handling * refactor client-only bonus message types * move redundant reading speed handling * refactor client-only question message types * refactor client-only room message types * refactor client-only tossup room message types * fix give-answer handling * add ability to sort set list page (#573) * feat: add ability to sort cols on set list page * refactor: replace bidirectional sort with sortTable * fix: make sortTable correct and fast enough for large tables The bubble sort restarted its scan from the top after every single swap and moved one row per pass, so reversing n rows cost O(n^2) DOM mutations. On the set list (711 rows) that locked up the tab; measured under jsdom, reversing an ordered table took 1.5 s at 100 rows, 30 s at 250, and over 90 s at 500. Read the rows once, sort them with a comparator, and reinsert them through a DocumentFragment so each row moves exactly once. The same table now reverses in 16-83 ms in the browser. Three correctness fixes come with it: - Cells that cannot be compared (blank text, or non-numeric text in a numeric column) parsed to NaN. Every NaN comparison is false, so those rows never swapped and no row could bubble past them, leaving the table sorted in segments rather than as a whole. They now sort to the bottom in both directions. - Numeric columns sorted descending on the first click while text columns sorted ascending. Every column now starts ascending. - Direction was inferred by running an ascending pass and checking whether it moved anything, so descending was only reachable from an already-sorted column. The active column and direction are now recorded on the sorted element as data-sort-column and data-sort-ascending, which callers can also read to render header indicators. Text now compares with Intl.Collator({ numeric: true }) so "Set 9" sorts before "Set 10". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EPFeG9eLBDYimTx7ELc8b * fix: don't offer set list sorting on columns whose data hasn't loaded The three count columns are filled with "-" placeholders by the first request and only get real numbers from the second, much slower one. Clicking them before that request lands sorted a column of placeholders, which did nothing at all - no reorder, no feedback. Those headers now start greyed out and unclickable, and become sortable when the counts arrive. If that request fails they stay disabled rather than offering a sort over data that never came; previously the failure was swallowed entirely. Also: - Scope the header lookup to this table. document.querySelectorAll('th') matched every header cell on the page, so a table added to the shared nav would have shifted every column index and silently sorted the wrong column. - Show which column is sorted and in which direction, via a caret and aria-sort on the header. Direction is read back from the dataset that sortTable now writes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EPFeG9eLBDYimTx7ELc8b * slight cleanup * clicking on a column again resets the sort --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Geoffrey Wu <geoffreywu1000@gmail.com> * refactor sort table and use for user-stats (#582) * move eventListener logic to tables.js * implement new sort for user stats * Refactor server multiplayer room message types (#583) * remove ServerTossupRoom.js * remove GIVE_ANSWER_LIVE_UPDATE as a dependency of tossup-room * basic MULTIPLAYER_ROOM_MESSAGE_TYPE + give-answer-live-update implementation * implement MULTIPLAYER_ROOM_MESSAGE_TYPE * remove redundant toggle stop on power case * move username logic to Room.js * implement client-side MULTIPLAYER_CLIENT_MESSAGE_TYPE * implement server-side MULTIPLAYER_CLIENT_MESSAGE_TYPE * remove redundant types * fix redundant message types * implement toggle-correct message type * refactor room file structure (#584) * move room files and update imports * move client files and update imports * move client rooms and update imports * fix: prune votekickList on success and via TTL cleanup (#531) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix QuestionClient messages not being handled * replace crown emoji denoting private room owner with icon (#586) * feat: replace emoji with crown icon * Delete .env.example --------- Co-authored-by: Geoffrey Wu <geoffreywu1000@gmail.com> * fix: clean up empty multiplayer rooms and their cleanup intervals Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * slightly better room deletion conditions --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Geoffrey Wu <geoffreywu1000@gmail.com> Co-authored-by: Lawrence Tong <lawrencetong1030@gmail.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: geoffrey-wu <42471355+geoffrey-wu@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.