Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix timeout leak in copy-to-clipboard handler

rcourtmanad645b2ef67b
diff --git a/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx b/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx
index 9a15c3e94d..577765828d 100644
--- a/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx
+++ b/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx
@@ -94,10 +94,15 @@ export const AgentIntegrationsPanel: Component = () => {
() => surfaceContractEntries().length > 0 || hasManifestInventory(),
);
+ let copySnippetTimer: ReturnType<typeof setTimeout> | undefined;
const handleCopySnippet = (snippet: string) => {
setCopied(snippet);
- window.setTimeout(() => setCopied(null), 2000);
+ if (copySnippetTimer) clearTimeout(copySnippetTimer);
+ copySnippetTimer = setTimeout(() => setCopied(null), 2000);
};
+ onCleanup(() => {
+ if (copySnippetTimer) clearTimeout(copySnippetTimer);
+ });
const readRouteHash = () => (typeof window === 'undefined' ? '' : window.location.hash);