use api in title-ui-handler

This commit is contained in:
flx-sta 2024-10-03 17:11:56 -07:00
parent a1adc40371
commit 565d80f262

View File

@ -7,6 +7,7 @@ import { getSplashMessages } from "../data/splash-messages";
import i18next from "i18next";
import { TimedEventDisplay } from "#app/timed-event-manager";
import { version } from "../../package.json";
import { api } from "#app/plugins/api/api";
export default class TitleUiHandler extends OptionSelectUiHandler {
/** If the stats can not be retrieved, use this fallback value */
@ -78,12 +79,13 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
}
updateTitleStats(): void {
Utils.apiFetch("game/titlestats")
.then(request => request.json())
api.getGameTitleStats()
.then(stats => {
this.playerCountLabel.setText(`${stats.playerCount} ${i18next.t("menu:playersOnline")}`);
if (this.splashMessage === "splashMessages:battlesWon") {
this.splashMessageText.setText(i18next.t(this.splashMessage, { count: stats.battleCount }));
if (stats) {
this.playerCountLabel.setText(`${stats.playerCount} ${i18next.t("menu:playersOnline")}`);
if (this.splashMessage === "splashMessages:battlesWon") {
this.splashMessageText.setText(i18next.t(this.splashMessage, { count: stats.battleCount }));
}
}
})
.catch(err => {