Log Viewer: Fixes continuous polling (closes #20274) (#20310)

* LogViewer: Fixes continuous polling (closes #20274)

* Update src/Umbraco.Web.UI.Client/src/packages/log-viewer/workspace/logviewer-workspace.context.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Lee Kelleher
2025-09-30 06:31:00 +01:00
committed by GitHub
parent 65393ff3d9
commit 418043bf59

View File

@@ -124,6 +124,7 @@ export class UmbLogViewerWorkspaceContext extends UmbContextBase implements UmbW
override hostDisconnected(): void {
super.hostDisconnected();
window.removeEventListener('changestate', this.onChangeState);
this.stopPolling();
}
onChangeState = () => {
@@ -320,7 +321,7 @@ export class UmbLogViewerWorkspaceContext extends UmbContextBase implements UmbW
return;
}
clearInterval(this.#intervalID as number);
this.stopPolling();
}
setPollingInterval(interval: UmbPoolingInterval) {
@@ -332,6 +333,13 @@ export class UmbLogViewerWorkspaceContext extends UmbContextBase implements UmbW
const newDirection = direction === DirectionModel.ASCENDING ? DirectionModel.DESCENDING : DirectionModel.ASCENDING;
this.#sortingDirection.setValue(newDirection);
}
stopPolling() {
if (this.#intervalID) {
clearInterval(this.#intervalID);
this.#intervalID = null;
}
}
}
export { UmbLogViewerWorkspaceContext as api };