From 6e6b36ee5094d6ee37fe2475633786137305f330 Mon Sep 17 00:00:00 2001 From: Oliver Pelly Date: Wed, 8 Apr 2026 16:21:33 -0700 Subject: [PATCH] fixed duplicative API calls --- .../app/desktop/components/workspace/workspace.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ui/winstudentgoaltracker/src/app/desktop/components/workspace/workspace.ts b/ui/winstudentgoaltracker/src/app/desktop/components/workspace/workspace.ts index fa32d2a..fa886e8 100644 --- a/ui/winstudentgoaltracker/src/app/desktop/components/workspace/workspace.ts +++ b/ui/winstudentgoaltracker/src/app/desktop/components/workspace/workspace.ts @@ -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 { StudentService } from '../../../shared/services/student.service'; 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; effect(() => { this.studentService.dataVersion(); - if (initialized && this.studentId()) { - this.loadStudentData(this.studentId()!); + if (initialized) { + const id = untracked(() => this.studentId()); + if (id) { + this.loadStudentData(id); + } } initialized = true; });