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
+5 -38
View File
@@ -12,10 +12,7 @@ import {
Thread,
ThreadEvent,
} from 'matrix-js-sdk';
import { focusAssistActiveAtom } from '../../state/focusAssist';
import { manualDndAtom } from '../../state/manualDnd';
import { isSnoozeActive, notificationSnoozeUntilAtom } from '../../state/notificationSnooze';
import { isWithinTimeWindow } from '../../utils/timeWindow';
import { useNotificationsQuiet } from '../../hooks/useNotificationsQuiet';
import { roomToUnreadAtom } from '../../state/room/roomToUnread';
import NotificationSound from '../../../../public/sound/notification.ogg';
import InviteSound from '../../../../public/sound/invite.ogg';
@@ -153,12 +150,7 @@ function InviteNotifications() {
const navigate = useNavigate();
const [showNotifications] = useSetting(settingsAtom, 'showNotifications');
const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds');
const [quietHoursEnabled] = useSetting(settingsAtom, 'quietHoursEnabled');
const focusAssistActive = useAtomValue(focusAssistActiveAtom);
const manualDnd = useAtomValue(manualDndAtom);
const snoozeUntil = useAtomValue(notificationSnoozeUntilAtom);
const [quietHoursStart] = useSetting(settingsAtom, 'quietHoursStart');
const [quietHoursEnd] = useSetting(settingsAtom, 'quietHoursEnd');
const quietActive = useNotificationsQuiet();
const [inviteSoundId] = useSetting(settingsAtom, 'inviteSoundId');
const setToast = useSetAtom(toastQueueAtom);
@@ -253,11 +245,6 @@ function InviteNotifications() {
knownInviteIdsRef.current = currentIds;
if (newCount <= 0) return;
const quietActive =
focusAssistActive ||
manualDnd ||
isSnoozeActive(snoozeUntil) ||
(quietHoursEnabled && isWithinTimeWindow(quietHoursStart, quietHoursEnd));
if (quietActive) return;
if (showNotifications && notificationPermission('granted')) {
@@ -272,12 +259,7 @@ function InviteNotifications() {
notificationSound,
notify,
playSound,
quietHoursEnabled,
quietHoursStart,
quietHoursEnd,
focusAssistActive,
manualDnd,
snoozeUntil,
quietActive,
inviteSoundId,
]);
@@ -390,12 +372,7 @@ function MessageNotifications() {
const useAuthentication = useMediaAuthentication();
const [showNotifications] = useSetting(settingsAtom, 'showNotifications');
const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds');
const [quietHoursEnabled] = useSetting(settingsAtom, 'quietHoursEnabled');
const focusAssistActive = useAtomValue(focusAssistActiveAtom);
const manualDnd = useAtomValue(manualDndAtom);
const snoozeUntil = useAtomValue(notificationSnoozeUntilAtom);
const [quietHoursStart] = useSetting(settingsAtom, 'quietHoursStart');
const [quietHoursEnd] = useSetting(settingsAtom, 'quietHoursEnd');
const quietActive = useNotificationsQuiet();
const [messageSoundId] = useSetting(settingsAtom, 'messageSoundId');
const setToast = useSetAtom(toastQueueAtom);
const mDirects = useAtomValue(mDirectAtom);
@@ -543,11 +520,6 @@ function MessageNotifications() {
lastNotifiedEventRef.current.set(dedupeKey, eventId);
const quietActive =
focusAssistActive ||
manualDnd ||
isSnoozeActive(snoozeUntil) ||
(quietHoursEnabled && isWithinTimeWindow(quietHoursStart, quietHoursEnd));
if (quietActive) return;
if (showNotifications && notificationPermission('granted')) {
@@ -578,12 +550,7 @@ function MessageNotifications() {
showNotifications,
notificationSound,
useAuthentication,
quietHoursEnabled,
quietHoursStart,
quietHoursEnd,
focusAssistActive,
manualDnd,
snoozeUntil,
quietActive,
messageSoundId,
],
);