From ad4bee99be9fcaa90b135046e039b5bd47153ea5 Mon Sep 17 00:00:00 2001 From: mzspicoli Date: Wed, 2 Sep 2026 07:27:30 +0200 Subject: [PATCH] Timer flash: blink the real theme instead of a black/white overlay, skip it while the app is backgrounded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The completion alert (Settings → "Flash screen when timer ends") laid an opaque black/white rectangle over the whole screen, so the app's own UI flickered into view between pulses. It now flips document.documentElement's data-theme (light/dark) three times and settles back on whatever theme the user actually had — same duration, no overlay, no rectangle. Fully dark -> light, dark, light; fully light -> dark, light, dark; either way it lands back where it started. Separately: the rest/work timers reuse their tick on 'visibilitychange' to stay accurate after the tab is throttled in the background. That reuse had a side effect — reopening the app (or the tab regaining focus) after the countdown had already finished while hidden replayed the completion beep, vibration, flash and toast, even though nothing was actually watching when it ended. Now those perceptible effects only fire if the countdown reaches zero while the app is genuinely visible; finishing hidden only sends the existing push notification, and reopening later stays silent. --- frontend/src/components/TimerFlash.jsx | 20 ++++++++++++++--- frontend/src/index.css | 13 ----------- frontend/src/store/useUI.js | 29 +++++++++++++++++++----- frontend/src/store/useUI.test.js | 31 ++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/TimerFlash.jsx b/frontend/src/components/TimerFlash.jsx index f620237..42efa31 100644 --- a/frontend/src/components/TimerFlash.jsx +++ b/frontend/src/components/TimerFlash.jsx @@ -1,8 +1,22 @@ +import { useEffect } from 'react' import { useUI } from '../store/useUI.js' -// A new key restarts the CSS sequence even when two timers finish close together. -// The layer never catches taps and ends transparent, so it can safely stay mounted. +// Flips the app's real light/dark theme on and off twice (~2.4s) instead of laying an +// opaque black/white rectangle over the screen — the alert reads as the app itself +// blinking, and it always settles back on whatever theme the user actually had. export default function TimerFlash() { const id = useUI(s => s.timerFlashId) - return id ?