Skip to content

fix(pihole): live pause countdown on blocking badge - #213

Merged
CallMeTechie merged 1 commit into
masterfrom
fix/pihole-pause-countdown
Jul 2, 2026
Merged

fix(pihole): live pause countdown on blocking badge#213
CallMeTechie merged 1 commit into
masterfrom
fix/pihole-pause-countdown

Conversation

@CallMeTechie

Copy link
Copy Markdown
Owner

Problem

On the /pihole page, clicking a "Blockierung steuern" pause button (Pause 30s/5m/30m) does nothing visible. The request itself is fine — POST /api/v1/pihole/blocking returns {"ok":true} (200) — but:

  1. Both theme badge renderers only render blocking.state (On/Off/Partial) and throw away blocking.timer, so a paused state never shows the intended countdown.
  2. The endpoint answers {ok:true} before the async server resync runs, so the client's immediate load() reads back the stale pre-toggle state → the badge doesn't move.

Fix (frontend only — the timer data already exists server-side)

  • Shared updateBlocking({state,timer}) + paintBlockingBadge(), used by both theme renderers.
  • blocking.timer → local deadline; a 1s ticker counts it down (Off · 0:29) and calls load() when it expires (Pi-hole auto-re-enables via its own timer).
  • Toggle updates the badge optimistically; the existing pihole SSE event then delivers ground truth — no immediate load() racing the resync.

Test

tests/pihole_pause_countdown_ui.test.js — asserts the countdown wiring (updateBlocking, ticker, optimistic toggle) and the zero-padded m:ss formula.

🤖 Generated with Claude Code

The 'Blockierung steuern' pause buttons sent POST /pihole/blocking (200
ok) but nothing changed on screen: the badge only rendered blocking.state
and ignored blocking.timer, and the endpoint answers before the async
resync, so the client read back the stale pre-toggle state.

Render the timer as a live countdown (e.g. 'Off · 0:29'): a shared
updateBlocking() turns blocking.timer into a local deadline, a 1s ticker
counts it down and reloads when it expires, and the toggle updates the
badge optimistically (SSE 'pihole' then delivers ground truth) instead of
racing an immediate load().
@CallMeTechie
CallMeTechie merged commit 03fc803 into master Jul 2, 2026
8 checks passed
@CallMeTechie
CallMeTechie deleted the fix/pihole-pause-countdown branch July 2, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant