Refactors event emission for date and workweek changes

Moves event emission responsibilities for date and
workweek changes to the calling components. This allows
for consolidated updates and optimized event handling,
avoiding redundant emissions and ensuring that events
are triggered with the correct payload.
This commit is contained in:
Janus C. H. Knudsen 2025-10-14 18:10:51 +02:00
parent 5b0ae0ca5c
commit ee4b9b3707
3 changed files with 12 additions and 31 deletions

View file

@ -139,14 +139,18 @@ export class ViewManager {
* Optimized workweek change with consolidated updates
*/
private changeWorkweek(workweekId: string): void {
// Update the calendar config
// Update the calendar config (does not emit events)
calendarConfig.setWorkWeek(workweekId);
// Update button states using cached elements
this.updateAllButtons();
// Trigger a workweek change to apply the new workweek
this.eventBus.emit(CoreEvents.WORKWEEK_CHANGED);
// Emit workweek change event with full payload
const settings = calendarConfig.getWorkWeekSettings();
this.eventBus.emit(CoreEvents.WORKWEEK_CHANGED, {
workWeekId: workweekId,
settings: settings
});
}
/**