Improving the number of requests for team.
This commit is contained in:
parent
278c7c5112
commit
40e392e003
@ -15,6 +15,7 @@ import ConquerTeam from '@burguillosinfo/conquer/team';
|
|||||||
export default class MapNode {
|
export default class MapNode {
|
||||||
private feature: Feature | null = null;
|
private feature: Feature | null = null;
|
||||||
private callbacks: Record<string, Array<() => void>> = {}
|
private callbacks: Record<string, Array<() => void>> = {}
|
||||||
|
private cachedTeam: ConquerTeam | null = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@JsonProperty() private uuid: string,
|
@JsonProperty() private uuid: string,
|
||||||
@ -30,10 +31,13 @@ export default class MapNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getTeam(): Promise<ConquerTeam | null> {
|
public async getTeam(): Promise<ConquerTeam | null> {
|
||||||
|
if (this.cachedTeam === null) {
|
||||||
if (this.team === null) {
|
if (this.team === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return ConquerTeam.getTeam(this.team);
|
this.cachedTeam = await ConquerTeam.getTeam(this.team);
|
||||||
|
}
|
||||||
|
return this.cachedTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ export default class ConquerUser {
|
|||||||
private uuid: string;
|
private uuid: string;
|
||||||
@JsonProperty()
|
@JsonProperty()
|
||||||
private team: string | null;
|
private team: string | null;
|
||||||
|
private cachedTeam: ConquerTeam | null = null;
|
||||||
|
|
||||||
constructor(kind: string, uuid: string, username: string, is_admin = false, registration_date: string | null = null, last_activity: string | null = null) {
|
constructor(kind: string, uuid: string, username: string, is_admin = false, registration_date: string | null = null, last_activity: string | null = null) {
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
@ -38,10 +39,13 @@ export default class ConquerUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getTeam(): Promise<ConquerTeam | null> {
|
public async getTeam(): Promise<ConquerTeam | null> {
|
||||||
|
if (this.cachedTeam === null) {
|
||||||
if (this.team === null) {
|
if (this.team === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return ConquerTeam.getTeam(this.team);
|
this.cachedTeam = await ConquerTeam.getTeam(this.team);
|
||||||
|
}
|
||||||
|
return this.cachedTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getSelfUser(): Promise<ConquerUser | null> {
|
public static async getSelfUser(): Promise<ConquerUser | null> {
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user