fix(calls): incoming-call ringtone respects quiet hours, DND, Focus Assist and snooze
CI / Build & Quality Checks (push) Canceled after 11s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s

The "should we make noise" predicate used for message sounds is extracted
into useNotificationsQuiet() (unit-tested) and applied to the ringtone in
both the full-screen incoming-call overlay and the compact in-call banner.
The overlay/banner still show so the call can be answered; only the audio
is skipped. Join/media paths untouched.

Fixes #28

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
2026-09-15 22:43:17 -04:00
co-authored by Claude Opus 5
parent 4cdd221eff
commit 3dead4b3e1
4 changed files with 130 additions and 42 deletions
+58
View File
@@ -0,0 +1,58 @@
import { useAtomValue } from 'jotai';
import { focusAssistActiveAtom } from '../state/focusAssist';
import { manualDndAtom } from '../state/manualDnd';
import { isSnoozeActive, notificationSnoozeUntilAtom } from '../state/notificationSnooze';
import { isWithinTimeWindow } from '../utils/timeWindow';
import { useSetting } from '../state/hooks/settings';
import { settingsAtom } from '../state/settings';
export type NotificationsQuietInputs = {
focusAssistActive: boolean;
manualDnd: boolean;
snoozeUntil: number;
quietHoursEnabled: boolean;
quietHoursStart: string;
quietHoursEnd: string;
now?: Date;
};
// Gitea #28 — pure "should we make noise right now?" predicate, extracted from
// the gate that `ClientNonUIFeatures` already applies to message/invite sounds
// (Focus Assist, manual tray DND, the snooze, and the quiet-hours window) so the
// incoming-call ringtone (and anything else) can honour the same rules.
export function isNotificationsQuiet({
focusAssistActive,
manualDnd,
snoozeUntil,
quietHoursEnabled,
quietHoursStart,
quietHoursEnd,
now,
}: NotificationsQuietInputs): boolean {
return (
focusAssistActive ||
manualDnd ||
isSnoozeActive(snoozeUntil, now?.getTime()) ||
(quietHoursEnabled && isWithinTimeWindow(quietHoursStart, quietHoursEnd, now))
);
}
// Live-atoms/settings-backed version of `isNotificationsQuiet` for use in
// components.
export function useNotificationsQuiet(): boolean {
const focusAssistActive = useAtomValue(focusAssistActiveAtom);
const manualDnd = useAtomValue(manualDndAtom);
const snoozeUntil = useAtomValue(notificationSnoozeUntilAtom);
const [quietHoursEnabled] = useSetting(settingsAtom, 'quietHoursEnabled');
const [quietHoursStart] = useSetting(settingsAtom, 'quietHoursStart');
const [quietHoursEnd] = useSetting(settingsAtom, 'quietHoursEnd');
return isNotificationsQuiet({
focusAssistActive,
manualDnd,
snoozeUntil,
quietHoursEnabled,
quietHoursStart,
quietHoursEnd,
});
}