Fix setTimeout async anti-pattern in calendar-year component #128
@@ -41,8 +41,9 @@ 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 () => {
|
||||
// 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(
|
||||
@@ -57,7 +58,8 @@ export class CalendarYear {
|
||||
this.userInput.remainingVacationDaysSignal.set(remainingDays);
|
||||
}
|
||||
this.isLoading.set(false);
|
||||
}, 1);
|
||||
})();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user