Skip to content

Extract the shared quiet-hours alert dance into one helper#131

Merged
almothafar merged 1 commit into
masterfrom
refactor/quiet-hours-alert-helper
Jul 12, 2026
Merged

Extract the shared quiet-hours alert dance into one helper#131
almothafar merged 1 commit into
masterfrom
refactor/quiet-hours-alert-helper

Conversation

@almothafar

Copy link
Copy Markdown
Owner

Stacked on #121. Base is feat/109-fast-drain-alert; merge that first. This diff shows only the refactor.

⚠️ Merge-order note (learned the hard way on #121): if #121 is squash-merged, this branch will show phantom conflicts afterwards. The fix is one command, not a re-review: git rebase --onto origin/master <old-#121-tip> refactor/quiet-hours-alert-helper — or ping the session and I'll do it. A regular merge (or "rebase and merge") of #121 avoids the issue entirely.

What

Review finding #4 from the #121 pass: sendTemperatureNotification and sendFastDrainNotification were the second and third near-identical copies of the quiet-hours alert sequence — permission check, channel creation, silent-channel rerouting outside the notification window (#111), the builder boilerplate, and the window-gated alarm sound.

Both now delegate to a single private sendQuietHoursAwareAlert(context, AlertSpec); the AlertSpec record carries the per-alert channel/id/icon/strings (parameter-count reduction in the style of the existing NotificationConfig).

Why

Three copies of the quiet-hours dance meant the next #111-style fix had to be applied three times or alerts would silently diverge in behaviour. Now it has one home.

Behaviour

No functional change — same channels, notification IDs, icons, strings, critical-alert sound preference, and quiet-hours gating as before. Only the log line on missing notification permission is unified (now parameterised by alert name).

Testing

Pure refactor of Android-facing code; covered by the existing suite (NotificationServiceTest exercises the pure quiet-hours helpers that are unchanged). CI's testDebugUnitTest + lint validate the build.

🤖 Generated with Claude Code

https://claude.ai/code/session_012LC6Qt7Nr8MpJHXuszizNF


Generated by Claude Code

sendTemperatureNotification and sendFastDrainNotification were the
second and third copies of the same sequence: permission check, channel
creation, quiet-hours rerouting to the silent channel, the notification
builder boilerplate, and the window-gated alarm sound. A quiet-hours
fix (like #111) would have had to be applied to each copy separately.

Both now delegate to sendQuietHoursAwareAlert(context, AlertSpec), which
is the single home of that behaviour. No functional change: same
channels, ids, icons, strings, sound preference and gating as before.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012LC6Qt7Nr8MpJHXuszizNF
Base automatically changed from feat/109-fast-drain-alert to master July 12, 2026 08:46
@almothafar almothafar merged commit 367c258 into master Jul 12, 2026
1 check passed
@almothafar almothafar deleted the refactor/quiet-hours-alert-helper branch July 12, 2026 08: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.

2 participants