Refactors event handling and grid rendering

Improves calendar performance and data flow by streamlining event emissions and grid rendering logic.

- Replaces generic CONFIG_UPDATE events with REFRESH_REQUESTED
  for more specific refresh triggers.
- Removes redundant grid re-renders on DATE_CHANGED and
  WEEK_CHANGED events, delegating navigation to NavigationManager.
- Introduces VIEW_CHANGED and DATE_CHANGED events for calendar
  mode and date selection, respectively.
- NavigationManager now handles date validation.
- Moves rendering logic from NavigationManager to NavigationRenderer.
- Syncs scroll position based on PERIOD_CHANGED instead of
  NAVIGATION_ANIMATION_COMPLETE.

This change optimizes the calendar's responsiveness and reduces
unnecessary re-renders, leading to a smoother user experience.
This commit is contained in:
Janus Knudsen 2025-08-20 21:38:54 +02:00
parent 4b4dbdc0d6
commit 83c0ce801c
9 changed files with 59 additions and 47 deletions

View file

@ -215,7 +215,7 @@ export class CalendarConfig {
// Update computed values handled in specific update methods
// Emit config update event
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.REFRESH_REQUESTED, {
key,
value,
oldValue
@ -292,7 +292,7 @@ export class CalendarConfig {
}
// Emit grid settings update event
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.REFRESH_REQUESTED, {
key: 'gridSettings',
value: this.gridSettings,
oldValue: this.gridSettings
@ -320,7 +320,7 @@ export class CalendarConfig {
this.dateViewSettings = { ...this.dateViewSettings, ...updates };
// Emit date view settings update event
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.REFRESH_REQUESTED, {
key: 'dateViewSettings',
value: this.dateViewSettings,
oldValue: this.dateViewSettings
@ -355,7 +355,7 @@ export class CalendarConfig {
this.resourceViewSettings = { ...this.resourceViewSettings, ...updates };
// Emit resource view settings update event
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.REFRESH_REQUESTED, {
key: 'resourceViewSettings',
value: this.resourceViewSettings,
oldValue: this.resourceViewSettings
@ -409,7 +409,7 @@ export class CalendarConfig {
this.calendarMode = mode;
// Emit calendar mode change event
eventBus.emit(CoreEvents.CALENDAR_TYPE_CHANGED, {
eventBus.emit(CoreEvents.VIEW_CHANGED, {
oldType: oldMode,
newType: mode
});
@ -429,7 +429,7 @@ export class CalendarConfig {
this.selectedDate = date;
// Emit date change event
eventBus.emit(CoreEvents.SELECTED_DATE_CHANGED, {
eventBus.emit(CoreEvents.DATE_CHANGED, {
date: date
});
}