From c2c7e1e8e7e57eaea9e0d00a5b0fa1826538db70 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Mon, 9 Sep 2024 14:36:15 +0900 Subject: [PATCH] fix: verify delayed prompt can still be displayed before showing --- src/view/segmentation.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/view/segmentation.js b/src/view/segmentation.js index 69b72a3c..3a372508 100644 --- a/src/view/segmentation.js +++ b/src/view/segmentation.js @@ -54,6 +54,12 @@ export const handleSegmentation = prompts => { setTimeout( unhide, delay ); } const unhide = () => { + // Conditions may have changed since the prompt was delayed. + // Verify whether the prompt can still be displayed. + const updatedMatchingSegment = getBestPrioritySegment( segments ); + if ( ! shouldPromptBeDisplayed( prompt, updatedMatchingSegment, ras, override ) ) { + return; + } // Prioritize RAS overlays. If there are any reinitiate the delay and return early. if ( ras?.overlays && ras.overlays.get().length ) { delayPrompt();