From 31686d0b827fcbf83377d0c30c7f5671f863241f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 23:17:39 +0000 Subject: [PATCH 1/2] Initial plan -- 2.54.0 From ae28ffa07ad52a6a649045a9758d4e4a2175a60e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 23:20:40 +0000 Subject: [PATCH 2/2] fix: replace setTimeout async anti-pattern with queueMicrotask and void Co-authored-by: THoguet <61246905+THoguet@users.noreply.github.com> --- .../components/calendar-year/calendar-year.ts | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/app/components/calendar-year/calendar-year.ts b/src/app/components/calendar-year/calendar-year.ts index 2923d38..4f7829c 100644 --- a/src/app/components/calendar-year/calendar-year.ts +++ b/src/app/components/calendar-year/calendar-year.ts @@ -41,23 +41,25 @@ export class CalendarYear { console.log('Optimizing vacations with data:', vacationData); this.isLoading.set(true); this.loadingProgress.set(0); - // Simulate server-side calculation with a small delay - setTimeout(async () => { - if (this.selectedDates) { - // Create a copy to avoid mutating the original signal data - const remainingDays = await this.selectedDates.optimizeVacations( - { ...vacationData }, - this.calendarSettingsService, - this.calendarService, - (progress: number) => { - this.loadingProgress.set(progress); - }, - ); - // Update the remaining vacation days signal - this.userInput.remainingVacationDaysSignal.set(remainingDays); - } - this.isLoading.set(false); - }, 1); + // Defer execution to allow UI to update + queueMicrotask(() => { + void (async () => { + if (this.selectedDates) { + // Create a copy to avoid mutating the original signal data + const remainingDays = await this.selectedDates.optimizeVacations( + { ...vacationData }, + this.calendarSettingsService, + this.calendarService, + (progress: number) => { + this.loadingProgress.set(progress); + }, + ); + // Update the remaining vacation days signal + this.userInput.remainingVacationDaysSignal.set(remainingDays); + } + this.isLoading.set(false); + })(); + }); }); } -- 2.54.0