Simplify navigation event handling and week info rendering
Removes redundant period info update event and consolidates week information calculation Streamlines navigation event flow by using navigation completed event for week info updates Removes separate week info update method and moves calculation into renderer Reduces complexity of event management and improves code efficiency
This commit is contained in:
parent
f0cc9bb6ce
commit
284c85b2f8
3 changed files with 19 additions and 28 deletions
|
|
@ -47,10 +47,6 @@ export class NavigationManager {
|
|||
|
||||
|
||||
private setupEventListeners(): void {
|
||||
// Initial DOM update when calendar is initialized
|
||||
this.eventBus.on(CoreEvents.INITIALIZED, () => {
|
||||
this.updateWeekInfo();
|
||||
});
|
||||
|
||||
// Listen for filter changes and apply to pre-rendered grids
|
||||
this.eventBus.on(CoreEvents.FILTER_CHANGED, (e: Event) => {
|
||||
|
|
@ -239,29 +235,12 @@ export class NavigationManager {
|
|||
this.currentWeek = new Date(this.targetWeek);
|
||||
}
|
||||
|
||||
// Update week info and notify other managers
|
||||
this.updateWeekInfo();
|
||||
|
||||
// Emit period change event for ScrollManager
|
||||
// Emit navigation completed event
|
||||
this.eventBus.emit(CoreEvents.NAVIGATION_COMPLETED, {
|
||||
direction,
|
||||
currentDate: this.currentWeek
|
||||
newDate: this.currentWeek
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private updateWeekInfo(): void {
|
||||
const weekNumber = this.dateService.getWeekNumber(this.currentWeek);
|
||||
const weekEnd = this.dateService.addDays(this.currentWeek, 6);
|
||||
const dateRange = this.dateService.formatDateRange(this.currentWeek, weekEnd);
|
||||
|
||||
// Notify other managers about week info update - DOM manipulation should happen via events
|
||||
this.eventBus.emit(CoreEvents.PERIOD_INFO_UPDATE, {
|
||||
weekNumber,
|
||||
dateRange,
|
||||
weekStart: this.currentWeek,
|
||||
weekEnd
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue