Skip to content

Commit

Permalink
fix: verify delayed prompt can still be displayed before showing (#1344)
Browse files Browse the repository at this point in the history
This PR adds a check to delayed prompts to ensure readers still match the segment before unhiding.
  • Loading branch information
chickenn00dle authored Sep 9, 2024
1 parent 0eb17ff commit 235f36b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/view/segmentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 235f36b

Please sign in to comment.