-
Notifications
You must be signed in to change notification settings - Fork 794
Feature: Elo being displayed on the PlayPage (#3029) #3048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think all this logic should be in Matchmaking.ts
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point. I'll fix it tomorrow. I don't have any time today sadly.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The button it is attached to is located in PlayPage.ts. I would have to migrate him to Matchmaking first, unless I am not missing out on something here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,35 @@ | ||
| import { LitElement, html } from "lit"; | ||
| import { customElement } from "lit/decorators.js"; | ||
| import { customElement, state } from "lit/decorators.js"; | ||
| import { UserMeResponse } from "../../core/ApiSchemas"; | ||
|
|
||
| @customElement("play-page") | ||
| export class PlayPage extends LitElement { | ||
| @state() private elo: string = "..."; | ||
| private _onUserMeResponse: (e: Event) => void; | ||
|
Comment on lines
+7
to
+8
|
||
|
|
||
| connectedCallback() { | ||
| super.connectedCallback(); | ||
|
|
||
| this._onUserMeResponse = (e: Event): void => { | ||
| const event = e as CustomEvent<UserMeResponse | false>; | ||
|
|
||
| if (!event.detail) { | ||
| this.elo = "..."; | ||
| return; | ||
| } | ||
|
|
||
| this.elo = | ||
| event.detail?.player?.leaderboard?.oneVone?.elo?.toString() ?? "..."; | ||
| }; | ||
|
|
||
| document.addEventListener("userMeResponse", this._onUserMeResponse); | ||
| } | ||
|
Comment on lines
+10
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -n 'userMeResponse' --type ts --type js -C 3Repository: openfrontio/OpenFrontIO Length of output: 17824 🏁 Script executed: rg -n 'dispatchEvent' --type ts --type js | grep -i 'usermeresp\|userme'Repository: openfrontio/OpenFrontIO Length of output: 49 🏁 Script executed: fd -e ts -e js | xargs grep -l 'dispatchEvent.*userMeResponse\|new CustomEvent.*[Uu]serMe'Repository: openfrontio/OpenFrontIO Length of output: 85 🏁 Script executed: rg -n 'onUserMe\s*=' src/client/Main.ts -A 30 | head -80Repository: openfrontio/OpenFrontIO Length of output: 1247 🏁 Script executed: rg -n 'onUserMe\s*\(' src/client/Main.ts -B 5 -A 2Repository: openfrontio/OpenFrontIO Length of output: 246 🏁 Script executed: sed -n '440,550p' src/client/Main.tsRepository: openfrontio/OpenFrontIO Length of output: 3619 🏁 Script executed: rg -n 'getUserMe' src/client/Main.ts -B 2 -A 5Repository: openfrontio/OpenFrontIO Length of output: 641 🏁 Script executed: rg -n 'window.showPage\|page-matchmaking' src/client/Main.ts | head -20Repository: openfrontio/OpenFrontIO Length of output: 49 🏁 Script executed: find src -name "*.ts" -type f | xargs grep -l 'page-matchmaking' | head -5Repository: openfrontio/OpenFrontIO Length of output: 111 🏁 Script executed: cat -n src/client/Api.ts | grep -A 10 'export function getUserMe'Repository: openfrontio/OpenFrontIO Length of output: 49 🏁 Script executed: sed -n '1,50p' src/client/PlayPage.tsRepository: openfrontio/OpenFrontIO Length of output: 132 🏁 Script executed: find src -name "*PlayPage*" -o -name "*playpage*" -o -name "*play-page*"Repository: openfrontio/OpenFrontIO Length of output: 100 🏁 Script executed: rg -l 'class PlayPage' --type tsRepository: openfrontio/OpenFrontIO Length of output: 100 🏁 Script executed: rg 'export function getUserMe' -A 15Repository: openfrontio/OpenFrontIO Length of output: 49 🏁 Script executed: rg 'getUserMe' src/client/Api.ts -A 15Repository: openfrontio/OpenFrontIO Length of output: 512 🏁 Script executed: cat -n src/client/components/PlayPage.ts | head -50Repository: openfrontio/OpenFrontIO Length of output: 1947 Read ELO from cached state on connect, not just from event listener. The 🤖 Prompt for AI Agents |
||
|
|
||
| disconnectedCallback() { | ||
| super.disconnectedCallback(); | ||
| document.removeEventListener("userMeResponse", this._onUserMeResponse); | ||
| } | ||
|
|
||
| createRenderRoot() { | ||
| return this; | ||
| } | ||
|
|
@@ -159,6 +186,17 @@ export class PlayPage extends LitElement { | |
| class="relative z-10 text-2xl" | ||
| data-i18n="matchmaking_button.play_ranked" | ||
| ></span> | ||
| <span> | ||
| <span | ||
| class="relative z-10 text-xs font-medium text-purple-100 opacity-90 group-hover:opacity-100 transition-opacity" | ||
| data-i18n="matchmaking_button.elo" | ||
| ></span> | ||
|
Comment on lines
+189
to
+193
|
||
| <span | ||
| class="relative z-10 text-xs font-medium text-purple-100 opacity-90 group-hover:opacity-100 transition-opacity" | ||
| > | ||
| ${this.elo}</span | ||
| > | ||
| </span> | ||
| <span | ||
| class="relative z-10 text-xs font-medium text-purple-100 opacity-90 group-hover:opacity-100 transition-opacity" | ||
| data-i18n="matchmaking_button.description" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matchmaking_button.elohas a trailing space ("ELO: "). Trailing whitespace in translations is fragile and makes it harder for translators/tools to manage spacing/punctuation.Prefer removing the trailing space and handling spacing in markup/CSS, or switch this string to a placeholder format (e.g., "ELO: {elo}") and render it as a single translated string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix, instead use vairables "ELO: {elo}"