Repository navigation
bugfix: hide account button and token modal login on game start - #1986
Conversation
WalkthroughAdds a visibility flag and a public close() method to AccountButton. Updates end-of-game cleanup in Main.ts to also close/hide "account-button" and "token-login" modals alongside existing ones. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Player
participant Game as Game Loop
participant Main as Main.ts
participant Modals as Modal Elements
participant AccountBtn as AccountButton
Player->>Game: Triggers end-of-game
Game->>Main: onGameEnd()
Main->>Modals: Iterate selectors (..., "account-button", "token-login")
alt Element is AccountButton
Main->>AccountBtn: close()
note right of AccountBtn: Sets isVisible=false<br/>Closes AccountModal<br/>requestUpdate()
else Other modal
Main->>Modals: if isModalOpen then close/hide
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/client/AccountModal.ts (1)
238-239: Prefer reactive state or codebase’s “hidden” pattern for visibilityUse Lit reactivity instead of a manual flag + requestUpdate, or align with the app-wide classList.add("hidden") convention for transitions.
Apply if staying with a flag:
- private isVisible = true; + @state() private isVisible = true;Then you can drop explicit requestUpdate() calls tied only to this flag.
src/client/Main.ts (1)
531-533: Restore AccountButton after game ends; verify TokenLogin close() exists
- If AccountButton is hidden on start via close(), make sure you show it again on leave. Otherwise, players lose access to account UI outside games.
- Please confirm token-login exposes close(); if not, the fallback path won’t trigger here.
Example restoration on leave (add inside handleLeaveLobby):
const ab = document.querySelector("account-button") as HTMLElement & { show?: () => void }; ab?.show?.(); // if you add AccountButton.show()Optional consistency tweak: If you want to stick to the codebase’s transition convention, consider adding/removing the "hidden" class for non-modal elements like account-button instead of relying on component APIs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/client/AccountModal.ts(3 hunks)src/client/Main.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: VariableVince
PR: openfrontio/OpenFrontIO#1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.
📚 Learning: 2025-06-09T02:20:43.637Z
Learnt from: VariableVince
PR: openfrontio/OpenFrontIO#1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.
Applied to files:
src/client/Main.ts
🔇 Additional comments (2)
src/client/AccountModal.ts (2)
271-274: Render short‑circuit is fineEarly return cleanly removes the subtree. No functional issues spotted here.
323-327: Ignore show/reset suggestion – AccountButton.close is never called and closing the modal uses AccountModal.close, so the account button never hides.Likely an incorrect or invalid review comment.
Description:
The account button persisted after game starting
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
evan