feat: cache

This commit is contained in:
TrèsAbhi committed 2026-01-02 14:26:05 -06:00
1 parent b96f925d9a
commit 4b8e73fa57
1 file changed
+9 -8
+9 -8
View File
@@ -92,7 +92,9 @@ export class ServerAPI extends AbstractAPI {
return strings; return strings;
} }
_tankList: TankList | undefined;
async tankList() { async tankList() {
if (this._tankList === undefined) {
const group = this.metadata.group("TankEntity"); const group = this.metadata.group("TankEntity");
const list: TankListEntry[] = []; const list: TankListEntry[] = [];
const strings = await this.strings("en"); const strings = await this.strings("en");
@@ -112,7 +114,10 @@ export class ServerAPI extends AbstractAPI {
list.push({ id, slug }); list.push({ id, slug });
} }
return { list }; this._tankList = { list };
}
return this._tankList;
} }
async tanks() { async tanks() {
@@ -120,13 +125,14 @@ export class ServerAPI extends AbstractAPI {
const data: Tanks = { tanks: {} }; const data: Tanks = { tanks: {} };
for (const { id } of tankList.list) { for (const { id } of tankList.list) {
data.tanks[id] = await this._tank(id, tankList); data.tanks[id] = await this.tank(id);
} }
return data; return data;
} }
async _tank(id: string, tankList: TankList) { async tank(id: string) {
const tankList = await this.tankList();
const tankListEntry = tankList.list.find((tank) => tank.id === id); const tankListEntry = tankList.list.find((tank) => tank.id === id);
if (!tankListEntry) { if (!tankListEntry) {
@@ -141,11 +147,6 @@ export class ServerAPI extends AbstractAPI {
return { tank, compensation, slug } satisfies Tank; return { tank, compensation, slug } satisfies Tank;
} }
async tank(id: string) {
const tankList = await this.tankList();
return this._tank(id, tankList);
}
async avatars() { async avatars() {
return this.metadata.group("ProfileAvatarEntity"); return this.metadata.group("ProfileAvatarEntity");
} }