11import { html , TemplateResult } from "lit" ;
22import { customElement , query , state } from "lit/decorators.js" ;
3+ import { Env } from "src/core/configuration/Env" ;
34import { copyToClipboard , translateText } from "../client/Utils" ;
45import {
56 ClientInfo ,
89 GameRecordSchema ,
910} from "../core/Schemas" ;
1011import { generateID } from "../core/Util" ;
11- import { getServerConfigFromClient } from "../core/configuration/ConfigLoader" ;
12+ import { getServerConfig } from "../core/configuration/ConfigLoader" ;
1213import { GameMode } from "../core/game/Game" ;
1314import { UserSettings } from "../core/game/UserSettings" ;
1415import { getApiBase } from "./Api" ;
@@ -511,7 +512,7 @@ export class JoinPrivateLobbyModal extends BaseModal {
511512 }
512513
513514 private async checkActiveLobby ( lobbyId : string ) : Promise < boolean > {
514- const config = await getServerConfigFromClient ( ) ;
515+ const config = getServerConfig ( ) ;
515516 const url = `/${ config . workerPath ( lobbyId ) } /api/game/${ lobbyId } /exists` ;
516517
517518 const response = await fetch ( url , {
@@ -548,22 +549,12 @@ export class JoinPrivateLobbyModal extends BaseModal {
548549 private async checkArchivedGame (
549550 lobbyId : string ,
550551 ) : Promise < "success" | "not_found" | "version_mismatch" | "error" > {
551- const archivePromise = fetch ( `${ getApiBase ( ) } /game/${ lobbyId } ` , {
552+ const archiveResponse = await fetch ( `${ getApiBase ( ) } /game/${ lobbyId } ` , {
552553 method : "GET" ,
553554 headers : {
554555 "Content-Type" : "application/json" ,
555556 } ,
556557 } ) ;
557- const gitCommitPromise = fetch ( `/commit.txt` , {
558- method : "GET" ,
559- headers : { "Content-Type" : "application/json" } ,
560- cache : "no-cache" ,
561- } ) ;
562-
563- const [ archiveResponse , gitCommitResponse ] = await Promise . all ( [
564- archivePromise ,
565- gitCommitPromise ,
566- ] ) ;
567558
568559 if ( archiveResponse . status === 404 ) {
569560 return "not_found" ;
@@ -578,16 +569,7 @@ export class JoinPrivateLobbyModal extends BaseModal {
578569 return "version_mismatch" ;
579570 }
580571
581- let myGitCommit = "" ;
582- if ( gitCommitResponse . status === 404 ) {
583- // commit.txt is not found when running locally
584- myGitCommit = "DEV" ;
585- } else if ( gitCommitResponse . status === 200 ) {
586- myGitCommit = ( await gitCommitResponse . text ( ) ) . trim ( ) ;
587- } else {
588- console . error ( "Error getting git commit:" , gitCommitResponse . status ) ;
589- return "error" ;
590- }
572+ const myGitCommit = Env . GIT_COMMIT ;
591573
592574 // Allow DEV to join games created with a different version for debugging.
593575 if ( myGitCommit !== "DEV" && parsed . data . gitCommit !== myGitCommit ) {
@@ -616,7 +598,7 @@ export class JoinPrivateLobbyModal extends BaseModal {
616598 private async pollPlayers ( ) {
617599 const lobbyId = this . currentLobbyId ;
618600 if ( ! lobbyId ) return ;
619- const config = await getServerConfigFromClient ( ) ;
601+ const config = getServerConfig ( ) ;
620602
621603 fetch ( `/${ config . workerPath ( lobbyId ) } /api/game/${ lobbyId } ` , {
622604 method : "GET" ,
0 commit comments