diff --git a/src/app/components/IncomingCallModal.tsx b/src/app/components/IncomingCallModal.tsx index b1d1d3705..a7ab56ff4 100644 --- a/src/app/components/IncomingCallModal.tsx +++ b/src/app/components/IncomingCallModal.tsx @@ -212,7 +212,7 @@ export function IncomingCallInternal({ room, incomingCall, onClose }: IncomingCa if (evt.key === 'Escape') { evt.preventDefault(); evt.stopPropagation(); - void handleDeclineOrIgnore(); + handleDeclineOrIgnore(); return; } if (evt.key === 'Enter' && canAnswer) { diff --git a/src/app/features/call/CallView.tsx b/src/app/features/call/CallView.tsx index 49d727700..5298a89b3 100644 --- a/src/app/features/call/CallView.tsx +++ b/src/app/features/call/CallView.tsx @@ -183,6 +183,12 @@ export function CallView({ resizable }: CallViewProps) { const room = useRoom(); const screenSize = useScreenSizeContext(); const isMobile = screenSize === ScreenSize.Mobile; + const desktopMinCallHeight = 620; + const desktopMaxCallHeight = Math.round(window.innerHeight * 0.8); + const desktopDefaultCallHeight = Math.min( + Math.max(desktopMinCallHeight, Math.round(window.innerHeight * 0.72)), + desktopMaxCallHeight + ); const callViewRef = useRef(null); const callContainerRef = useRef(null); @@ -193,7 +199,7 @@ export function CallView({ resizable }: CallViewProps) { const currentJoined = callEmbed?.roomId === room.roomId && callJoined; - const [height, setHeight] = useState(isMobile ? 240 : 380); + const [height, setHeight] = useState(isMobile ? 240 : desktopDefaultCallHeight); const [isDragging, setIsDragging] = useState(false); const isResizing = useRef(false); const previousBodyUserSelect = useRef(null); @@ -202,9 +208,11 @@ export function CallView({ resizable }: CallViewProps) { (clientY: number) => { if (!isResizing.current || !callViewRef.current) return; const { top } = callViewRef.current.getBoundingClientRect(); - setHeight(Math.max(isMobile ? 120 : 150, Math.min(clientY - top, window.innerHeight * 0.8))); + const maxHeight = window.innerHeight * 0.8; + const minHeight = isMobile ? 120 : Math.min(desktopMinCallHeight, maxHeight); + setHeight(Math.max(minHeight, Math.min(clientY - top, maxHeight))); }, - [isMobile] + [isMobile, desktopMinCallHeight] ); const handleMouseMove = useCallback((e: MouseEvent) => handleMove(e.clientY), [handleMove]); diff --git a/src/app/features/call/callRingtoneStorage.ts b/src/app/features/call/callRingtoneStorage.ts index b0a9605fd..f4c0bafe6 100644 --- a/src/app/features/call/callRingtoneStorage.ts +++ b/src/app/features/call/callRingtoneStorage.ts @@ -73,8 +73,10 @@ async function clearCustomCallAudio(key: string): Promise { }); } -export const putCustomCallRingtone = (file: File, durationMs: number): Promise => - putCustomCallAudio(CUSTOM_RINGTONE_KEY, file, durationMs); +export const putCustomCallRingtone = ( + file: File, + durationMs: number +): Promise => putCustomCallAudio(CUSTOM_RINGTONE_KEY, file, durationMs); export const getCustomCallRingtone = (): Promise => getCustomCallAudio(CUSTOM_RINGTONE_KEY); @@ -82,8 +84,10 @@ export const getCustomCallRingtone = (): Promise export const clearCustomCallRingtone = (): Promise => clearCustomCallAudio(CUSTOM_RINGTONE_KEY); -export const putCustomCallRingback = (file: File, durationMs: number): Promise => - putCustomCallAudio(CUSTOM_RINGBACK_KEY, file, durationMs); +export const putCustomCallRingback = ( + file: File, + durationMs: number +): Promise => putCustomCallAudio(CUSTOM_RINGBACK_KEY, file, durationMs); export const getCustomCallRingback = (): Promise => getCustomCallAudio(CUSTOM_RINGBACK_KEY); diff --git a/src/app/hooks/useCallSignaling.ts b/src/app/hooks/useCallSignaling.ts index 0d5f14ba1..a3d69c9a1 100644 --- a/src/app/hooks/useCallSignaling.ts +++ b/src/app/hooks/useCallSignaling.ts @@ -29,10 +29,7 @@ import { resolveOutgoingRingbackToneUrl, } from '$features/call/callRingtone'; import { dismissSystemCallNotifications } from '$features/call/callNotificationBridge'; -import { - getCustomCallRingback, - getCustomCallRingtone, -} from '$features/call/callRingtoneStorage'; +import { getCustomCallRingback, getCustomCallRingtone } from '$features/call/callRingtoneStorage'; import { useMatrixClient } from './useMatrixClient'; import { createDebugLogger } from '../utils/debugLogger'; @@ -473,7 +470,11 @@ export function useIncomingCallSignaling() { } const session = mx.matrixRTC.getRoomSession(outgoingRoom); - const pendingOutgoing = isOutgoingCallPending(myUserId, outgoingRoom, session.sessionDescription); + const pendingOutgoing = isOutgoingCallPending( + myUserId, + outgoingRoom, + session.sessionDescription + ); const activeCall = isCallActive(myUserId, outgoingRoom, session.sessionDescription); if (!pendingOutgoing || activeCall) { diff --git a/src/app/plugins/call/CallControl.ts b/src/app/plugins/call/CallControl.ts index 43071bf0b..834d18674 100644 --- a/src/app/plugins/call/CallControl.ts +++ b/src/app/plugins/call/CallControl.ts @@ -166,7 +166,7 @@ export class CallControl extends EventEmitter implements CallControlState { const callDocument = this.iframe.contentDocument ?? this.iframe.contentWindow?.document; const shouldMute = this.outputOverrideMuted || !sound; if (callDocument) { - callDocument.querySelectorAll('audio, video').forEach((el) => { + callDocument.querySelectorAll('audio, video').forEach((el) => { el.muted = shouldMute; if (shouldMute) el.volume = 0; }); @@ -188,7 +188,12 @@ export class CallControl extends EventEmitter implements CallControlState { const originalCtor = scopedWindow[key]; if (typeof originalCtor !== 'function') return; - const originalResume = originalCtor.prototype.resume; + const resumeDescriptor = Object.getOwnPropertyDescriptor(originalCtor.prototype, 'resume'); + const originalResumeImpl = resumeDescriptor?.value as + | ((this: AudioContext) => Promise) + | undefined; + if (typeof originalResumeImpl !== 'function') return; + const originalResume = (context: AudioContext): Promise => originalResumeImpl.call(context); const trackedContexts = this.trackedAudioContexts; const isOverrideMuted = () => this.outputOverrideMuted; originalCtor.prototype.resume = function patchedResume(this: AudioContext) { @@ -196,10 +201,10 @@ export class CallControl extends EventEmitter implements CallControlState { if (isOverrideMuted()) { return Promise.resolve(); } - return originalResume.call(this); + return originalResume(this); }; this.audioPatchRestores.push(() => { - originalCtor.prototype.resume = originalResume; + originalCtor.prototype.resume = originalResumeImpl; }); const wrappedCtor = function patchedAudioContext( diff --git a/src/sw.ts b/src/sw.ts index 2e0f30f67..ac3b9720b 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -720,9 +720,11 @@ self.addEventListener('fetch', (event: FetchEvent) => { if (method !== 'GET') return; if (isElementCallRingtoneRequest(url)) { + const silentWavBytes = createSilentWavBytes(); + const silentWavBuffer = new Uint8Array(silentWavBytes).buffer; event.respondWith( Promise.resolve( - new Response(createSilentWavBytes(), { + new Response(silentWavBuffer, { status: 200, headers: { 'Content-Type': 'audio/wav',