mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 15:03:29 +00:00
strict mode: GameInfoSchema.parse (#1763)
## Description: Update the code for strict mode. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [ ] I have read and accepted the CLA agreement (only required once).
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
ClientInfo,
|
||||
GameConfig,
|
||||
GameInfo,
|
||||
GameInfoSchema,
|
||||
TeamCountConfig,
|
||||
} from "../core/Schemas";
|
||||
import { generateID } from "../core/Util";
|
||||
@@ -671,6 +672,7 @@ export class HostLobbyModal extends LitElement {
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then(GameInfoSchema.parse)
|
||||
.then((data: GameInfo) => {
|
||||
console.log(`got game info response: ${JSON.stringify(data)}`);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, query, state } from "lit/decorators.js";
|
||||
import { translateText } from "../client/Utils";
|
||||
import { GameInfo } from "../core/Schemas";
|
||||
import { GameInfo, GameInfoSchema } from "../core/Schemas";
|
||||
import { generateID } from "../core/Util";
|
||||
import {
|
||||
WorkerApiArchivedGameLobbySchema,
|
||||
@@ -11,6 +11,7 @@ import { getServerConfigFromClient } from "../core/configuration/ConfigLoader";
|
||||
import { JoinLobbyEvent } from "./Main";
|
||||
import "./components/baseComponents/Button";
|
||||
import "./components/baseComponents/Modal";
|
||||
|
||||
@customElement("join-private-lobby-modal")
|
||||
export class JoinPrivateLobbyModal extends LitElement {
|
||||
@query("o-modal") private modalEl!: HTMLElement & {
|
||||
@@ -285,6 +286,7 @@ export class JoinPrivateLobbyModal extends LitElement {
|
||||
},
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then(GameInfoSchema.parse)
|
||||
.then((data: GameInfo) => {
|
||||
this.players = data.clients?.map((p) => p.username) ?? [];
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user