diff --git a/web-client/iron-remote-desktop/src/iron-remote-desktop.svelte b/web-client/iron-remote-desktop/src/iron-remote-desktop.svelte index 4cdeff0b..b21b46f3 100644 --- a/web-client/iron-remote-desktop/src/iron-remote-desktop.svelte +++ b/web-client/iron-remote-desktop/src/iron-remote-desktop.svelte @@ -71,6 +71,8 @@ let lastSentClipboardData: ClipboardData | null = null; let lastClipboardMonitorLoopError: Error | null = null; + let componentDestroyed = false; + /* Firefox-specific BEGIN */ // See `ffRemoteClipboardData` variable docs below @@ -185,12 +187,11 @@ // Called periodically to monitor clipboard changes async function onMonitorClipboard() { - if (!document.hasFocus()) { - setTimeout(onMonitorClipboard, CLIPBOARD_MONITORING_INTERVAL); - return; - } - try { + if (!document.hasFocus()) { + return; + } + var value = await navigator.clipboard.read(); // Clipboard is empty @@ -291,7 +292,9 @@ lastClipboardMonitorLoopError = err; } } finally { - setTimeout(onMonitorClipboard, CLIPBOARD_MONITORING_INTERVAL); + if (!componentDestroyed) { + setTimeout(onMonitorClipboard, CLIPBOARD_MONITORING_INTERVAL); + } } } @@ -723,6 +726,7 @@ onDestroy(() => { window.removeEventListener('resize', resizeHandler); + componentDestroyed = true; });