fixed duplicative API calls

This commit is contained in:
2026-04-08 16:21:33 -07:00
parent e77c867beb
commit 6e6b36ee50
@@ -1,4 +1,4 @@
import { Component, computed, effect, inject, signal } from '@angular/core'; import { Component, computed, effect, inject, signal, untracked } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { StudentService } from '../../../shared/services/student.service'; import { StudentService } from '../../../shared/services/student.service';
import { StudentCardDto } from '../../../shared/classes/student-card.dto'; import { StudentCardDto } from '../../../shared/classes/student-card.dto';
@@ -41,12 +41,17 @@ export class Workspace {
} }
}); });
// When dataVersion changes and we have a student loaded, refresh // When dataVersion changes and we have a student loaded, refresh.
// Use untracked() for studentId so this effect only re-runs on
// dataVersion changes — route params already handle studentId changes.
let initialized = false; let initialized = false;
effect(() => { effect(() => {
this.studentService.dataVersion(); this.studentService.dataVersion();
if (initialized && this.studentId()) { if (initialized) {
this.loadStudentData(this.studentId()!); const id = untracked(() => this.studentId());
if (id) {
this.loadStudentData(id);
}
} }
initialized = true; initialized = true;
}); });