Dwell timers no longer stall on phones: a focused ad frame or a touch device counts as an active tab (Brian Holland 2026-10-09: no timer, no close on the welcome tour and verified ads on mobile)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-09 08:44:27 -05:00
parent 75339757e5
commit f53bd67d30
4 changed files with 9 additions and 5 deletions
+4 -2
View File
@@ -3,6 +3,8 @@
(async function () {
// back-office shell: no marketing nav here; rehearsal notice lives in the top bar
const $ = IAP.$;
// dwell timers pause when the tab is away; a focused ad frame or a touch device counts as active (phones never report hasFocus reliably)
const tabActive = () => document.visibilityState === 'visible' && (document.hasFocus() || !!(document.activeElement && document.activeElement.tagName === 'IFRAME') || (window.matchMedia && window.matchMedia('(pointer: coarse)').matches));
try {
const c = await IAP.getConfig();
if (c.rehearsal && $('boRehearsal')) {
@@ -2281,7 +2283,7 @@
refresh();
// countdown pauses off-tab; the server separately enforces the dwell on its own clock
ibTimer = setInterval(() => {
if (document.visibilityState !== 'visible' || !document.hasFocus()) return;
if (!tabActive()) return;
left -= 1;
if (left > 0) { refresh(); return; }
clearInterval(ibTimer);
@@ -2849,7 +2851,7 @@
$('ggTimer').textContent = left + 's';
await new Promise(done => {
const t = setInterval(() => {
if (document.visibilityState !== 'visible' || !document.hasFocus()) return;
if (!tabActive()) return;
left -= 1;
$('ggTimer').textContent = Math.max(0, left) + 's';
if (left <= 0) { clearInterval(t); done(); }