dont ring on call end

This commit is contained in:
7w1 committed 2026-06-27 22:18:27 -05:00
1 parent 621f7fb564
commit eb1e953797
3 files changed
+31 -3

No files matched your search

@@ -66,6 +66,7 @@ describe('evaluateOutgoingRingbackFallback', () => {
activeCallRoomId: '!room:example.org',
outgoingRingbackAllowed: true,
declinedRoomId: null,
hasCallBeenActive: false,
getRoom: () => ({ roomId: '!room:example.org' }) as never,
getSessionDescription: () => EMPTY_SESSION,
};
@@ -115,4 +116,18 @@ describe('evaluateOutgoingRingbackFallback', () => {
);
expect(action.kind).toBe('stop');
});
it('stops ringback if call has been active previously', () => {
const action = evaluateOutgoingRingbackFallback(
{ ringRoomId: null, ringStartedAt: null },
NOW,
{
...baseContext,
hasCallBeenActive: true,
isOutgoingPending: () => true,
isCallActive: () => false,
}
);
expect(action.kind).toBe('stop');
});
});
@@ -58,6 +58,7 @@ export type OutgoingRingbackContext = {
activeCallRoomId: string | undefined;
outgoingRingbackAllowed: boolean;
declinedRoomId: string | null;
hasCallBeenActive: boolean;
getRoom: (roomId: string) => Room | null | undefined;
getSessionDescription: (room: Room) => SessionDescription;
isOutgoingPending?: typeof isOutgoingCallPending;
@@ -97,7 +98,7 @@ export const evaluateOutgoingRingbackFallback = (
const pendingOutgoing = isOutgoingPending(context.myUserId, outgoingRoom, sessionDescription);
const activeCall = isActive(context.myUserId, outgoingRoom, sessionDescription);
if (!pendingOutgoing || activeCall) {
if (!pendingOutgoing || activeCall || context.hasCallBeenActive) {
return stop();
}
+14 -2
View File
@@ -37,7 +37,7 @@ import { callRingtoneVolumeToGain, canPlayCallAudio } from '$features/call/callR
import { dismissSystemCallNotifications } from '$features/call/callNotificationBridge';
import { resolveCallToneSources } from '$features/call/callToneSources';
import { isIncomingCallSuppressed } from '$features/call/callIncomingIngress';
import { getRemoteRtcMemberUserIds } from '$features/call/callMembershipState';
import { getRemoteRtcMemberUserIds, isCallActive } from '$features/call/callMembershipState';
import { useMatrixClient } from './useMatrixClient';
import { createDebugLogger } from '../utils/debugLogger';
@@ -85,6 +85,7 @@ export function useIncomingCallSignaling() {
const outgoingStartRef = useRef<number | null>(null);
const activeOutgoingNotificationIdRef = useRef<string | null>(null);
const seenDeclineEventIdsRef = useRef<Set<string>>(new Set());
const hasCallBeenActiveRef = useRef<boolean>(false);
type SignalingHandlerRefs = {
callEmbed: typeof callEmbed;
@@ -113,6 +114,7 @@ export function useIncomingCallSignaling() {
outgoingDeclinesRef.current.clear();
activeOutgoingNotificationIdRef.current = null;
seenDeclineEventIdsRef.current.clear();
hasCallBeenActiveRef.current = false;
}, [callEmbed]);
useEffect(() => {
@@ -559,6 +561,15 @@ export function useIncomingCallSignaling() {
};
const evaluateOutgoingFallback = () => {
const activeCallRoomId = handlers().callEmbed?.roomId;
const outgoingRoom = activeCallRoomId ? mx.getRoom(activeCallRoomId) : null;
if (outgoingRoom) {
const session = mx.matrixRTC.getRoomSession(outgoingRoom).sessionDescription;
if (isCallActive(myUserId, outgoingRoom, session)) {
hasCallBeenActiveRef.current = true;
}
}
const ringAction = evaluateOutgoingRingbackFallback(
{
ringRoomId: outgoingRingRoomIdRef.current,
@@ -567,9 +578,10 @@ export function useIncomingCallSignaling() {
Date.now(),
{
...fallbackContext,
activeCallRoomId: handlers().callEmbed?.roomId,
activeCallRoomId,
outgoingRingbackAllowed: handlers().outgoingRingbackAllowed,
declinedRoomId: declinedOutgoingRoomIdRef.current,
hasCallBeenActive: hasCallBeenActiveRef.current,
}
);