Refactor plugin setup and avoid dangling resources

This commit is contained in:
Andras Schmelczer 2025-11-22 12:38:34 +00:00
parent a1a4610109
commit fbf03c41e0
3 changed files with 139 additions and 113 deletions

View file

@ -22,7 +22,7 @@ export class EditorStatusDisplayManager {
}, EditorStatusDisplayManager.UPDATE_INTERVAL_IN_MS);
}
public stop(): void {
public dispose(): void {
clearInterval(this.intervalId);
}

View file

@ -108,6 +108,7 @@ export class HistoryView extends ItemView {
this.historyContainer = container.createDiv({ cls: "logs-container" });
await this.updateView();
this.clearTimer();
this.timer = setInterval(
() =>
void this.updateView().catch((error: unknown) => {
@ -120,8 +121,13 @@ export class HistoryView extends ItemView {
}
public async onClose(): Promise<void> {
this.clearTimer();
}
private clearTimer(): void {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
}