Refactor ApplicantsDialog to remove unused cardToken and improve card fetching logic. Updated openCard method to check against selectedId instead of cardToken for better state management.
This commit is contained in:
@@ -67,7 +67,6 @@ export class ApplicantsDialog {
|
|||||||
private selectedId: string | null;
|
private selectedId: string | null;
|
||||||
private sort: ApplicantSort = 'name';
|
private sort: ApplicantSort = 'name';
|
||||||
private dir: 'asc' | 'desc' = 'asc';
|
private dir: 'asc' | 'desc' = 'asc';
|
||||||
private cardToken = 0;
|
|
||||||
private busy = false;
|
private busy = false;
|
||||||
private readonly cardHost = new PersonCardHost();
|
private readonly cardHost = new PersonCardHost();
|
||||||
private painted: PersonCard | null = null;
|
private painted: PersonCard | null = null;
|
||||||
@@ -294,16 +293,15 @@ export class ApplicantsDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async openCard(personId: string): Promise<void> {
|
private async openCard(personId: string): Promise<void> {
|
||||||
const token = ++this.cardToken;
|
|
||||||
try {
|
try {
|
||||||
const card = await fetchPerson(this.options.schoolId, personId, getLocale());
|
const card = await fetchPerson(this.options.schoolId, personId, getLocale());
|
||||||
if (token !== this.cardToken) {
|
if (personId !== this.selectedId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.paintCard(card);
|
this.paintCard(card);
|
||||||
} catch {
|
} catch {
|
||||||
if (token !== this.cardToken) {
|
if (personId !== this.selectedId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user