Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit ef4c87e

Browse files
committed
fix: simplify code for hiding form
1 parent 1a0a865 commit ef4c87e

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

windows-rdp/devolutions-patch.js

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -408,38 +408,15 @@ function hideFormForInitialSubmission() {
408408
rootNode.style.setProperty(opacityVariableName, "1");
409409
};
410410

411-
/** @type {number | undefined} */
412-
let intervalId = undefined;
413-
const pollingTimeoutMs = 5_000;
414-
let pollAttempts = 0;
415-
416-
const checkIfSafeToHideForm = () => {
417-
/** @type {HTMLFormElement | null} */
418-
const form = document.querySelector("web-client-form > form");
419-
if (form === null) {
420-
pollAttempts++;
421-
const elapsedTime = pollAttempts * SCREEN_POLL_INTERVAL_MS;
422-
423-
if (elapsedTime >= pollingTimeoutMs) {
424-
restoreOpacity();
425-
window.clearInterval(intervalId);
426-
}
427-
428-
return;
429-
}
430-
431-
// If this file gets more complicated, it might make sense to set up the
432-
// timeout and event listener so that if one triggers, it cancels the other,
433-
// but having restoreOpacity run more than once is a no-op for right now.
434-
// Not a big deal if these don't get cleaned up.
435-
window.setTimeout(restoreOpacity, 5_000);
436-
form.addEventListener("submit", restoreOpacity, { once: true });
437-
};
411+
// If this file gets more complicated, it might make sense to set up the
412+
// timeout and event listener so that if one triggers, it cancels the other,
413+
// but having restoreOpacity run more than once is a no-op for right now.
414+
// Not a big deal if these don't get cleaned up.
438415

439-
intervalId = window.setInterval(
440-
checkIfSafeToHideForm,
441-
SCREEN_POLL_INTERVAL_MS,
442-
);
416+
/** @type {HTMLFormElement | null} */
417+
const form = document.querySelector("web-client-form > form");
418+
form?.addEventListener("submit", restoreOpacity, { once: true });
419+
window.setTimeout(restoreOpacity, 5_000);
443420
}
444421

445422
function setupFormOverrides() {

0 commit comments

Comments
 (0)