Removes unnecessary destroy methods
This commit is contained in:
parent
4e5077364e
commit
a1e1c5d185
19 changed files with 34 additions and 214 deletions
|
|
@ -10,7 +10,6 @@ import { CoreEvents } from '../constants/CoreEvents';
|
|||
export class ViewManager {
|
||||
private eventBus: IEventBus;
|
||||
private currentView: CalendarView = 'week';
|
||||
private eventCleanup: (() => void)[] = [];
|
||||
private buttonListeners: Map<Element, EventListener> = new Map();
|
||||
|
||||
// Cached DOM elements for performance
|
||||
|
|
@ -39,20 +38,16 @@ export class ViewManager {
|
|||
* Setup event bus listeners with proper cleanup tracking
|
||||
*/
|
||||
private setupEventBusListeners(): void {
|
||||
this.eventCleanup.push(
|
||||
this.eventBus.on(CoreEvents.INITIALIZED, () => {
|
||||
this.initializeView();
|
||||
})
|
||||
);
|
||||
this.eventBus.on(CoreEvents.INITIALIZED, () => {
|
||||
this.initializeView();
|
||||
});
|
||||
|
||||
// Remove redundant VIEW_CHANGED listener that causes circular calls
|
||||
// changeView is called directly from button handlers
|
||||
|
||||
this.eventCleanup.push(
|
||||
this.eventBus.on(CoreEvents.DATE_CHANGED, () => {
|
||||
this.refreshCurrentView();
|
||||
})
|
||||
);
|
||||
this.eventBus.on(CoreEvents.DATE_CHANGED, () => {
|
||||
this.refreshCurrentView();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -222,23 +217,4 @@ export class ViewManager {
|
|||
this.refreshCurrentView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up all resources and cached elements
|
||||
*/
|
||||
public destroy(): void {
|
||||
// Clean up event bus listeners
|
||||
this.eventCleanup.forEach(cleanup => cleanup());
|
||||
this.eventCleanup = [];
|
||||
|
||||
// Clean up button listeners
|
||||
this.buttonListeners.forEach((handler, button) => {
|
||||
button.removeEventListener('click', handler);
|
||||
});
|
||||
this.buttonListeners.clear();
|
||||
|
||||
// Clear cached elements
|
||||
this.cachedViewButtons = null;
|
||||
this.cachedWorkweekButtons = null;
|
||||
this.lastButtonCacheTime = 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue