mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-03 05:20:44 +00:00
have client stop polling for public servers after game starts
This commit is contained in:
+10
-1
@@ -15,6 +15,7 @@ import { consolex } from "../core/Consolex";
|
||||
import "./components/FlagInput";
|
||||
import { FlagInput } from "./components/FlagInput";
|
||||
import page from "page";
|
||||
import { PublicLobby } from "./PublicLobby";
|
||||
|
||||
class Client {
|
||||
private gameStop: () => void;
|
||||
@@ -23,6 +24,8 @@ class Client {
|
||||
private flagInput: FlagInput | null = null;
|
||||
|
||||
private joinModal: JoinPrivateLobbyModal;
|
||||
private publicLobby: PublicLobby;
|
||||
|
||||
constructor() {}
|
||||
|
||||
initialize(): void {
|
||||
@@ -37,6 +40,9 @@ class Client {
|
||||
if (!this.usernameInput) {
|
||||
consolex.warn("Username input element not found");
|
||||
}
|
||||
|
||||
this.publicLobby = document.querySelector("public-lobby") as PublicLobby;
|
||||
|
||||
window.addEventListener("beforeunload", (event) => {
|
||||
consolex.log("Browser is closing");
|
||||
if (this.gameStop != null) {
|
||||
@@ -119,7 +125,10 @@ class Client {
|
||||
disableNPCs: event.detail.disableNPCs,
|
||||
creativeMode: event.detail.creativeMode,
|
||||
},
|
||||
() => this.joinModal.close(),
|
||||
() => {
|
||||
this.joinModal.close();
|
||||
this.publicLobby.stop();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,13 @@ export class PublicLobby extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.lobbiesInterval !== null) {
|
||||
clearInterval(this.lobbiesInterval);
|
||||
this.lobbiesInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.lobbies.length === 0) return html``;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user