|  |  |  | @ -32,7 +32,7 @@ import { approveConvoAndSendResponse } from '../../../interactions/conversationI | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | export type InputItem = { deviceId: string; label: string }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | export const callTimeoutMs = 30000; | 
		
	
		
			
				|  |  |  |  | export const callTimeoutMs = 60000; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | /** | 
		
	
		
			
				|  |  |  |  |  * This uuid is set only once we accepted a call or started one. | 
		
	
	
		
			
				
					|  |  |  | @ -41,6 +41,8 @@ let currentCallUUID: string | undefined; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | let currentCallStartTimestamp: number | undefined; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | let weAreCallerOnCurrentCall: boolean | undefined; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | const rejectedCallUUIDS: Set<string> = new Set(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | export type CallManagerOptionsType = { | 
		
	
	
		
			
				
					|  |  |  | @ -498,6 +500,7 @@ export async function USER_callRecipient(recipient: string) { | 
		
	
		
			
				|  |  |  |  |   window.log.info('Sending preOffer message to ', ed25519Str(recipient)); | 
		
	
		
			
				|  |  |  |  |   const calledConvo = getConversationController().get(recipient); | 
		
	
		
			
				|  |  |  |  |   calledConvo.set('active_at', Date.now()); // addSingleOutgoingMessage does the commit for us on the convo
 | 
		
	
		
			
				|  |  |  |  |   weAreCallerOnCurrentCall = true; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   await calledConvo?.addSingleOutgoingMessage({ | 
		
	
		
			
				|  |  |  |  |     sent_at: now, | 
		
	
	
		
			
				
					|  |  |  | @ -619,6 +622,7 @@ function handleConnectionStateChanged(pubkey: string) { | 
		
	
		
			
				|  |  |  |  | function closeVideoCall() { | 
		
	
		
			
				|  |  |  |  |   window.log.info('closingVideoCall '); | 
		
	
		
			
				|  |  |  |  |   currentCallStartTimestamp = undefined; | 
		
	
		
			
				|  |  |  |  |   weAreCallerOnCurrentCall = undefined; | 
		
	
		
			
				|  |  |  |  |   if (peerConnection) { | 
		
	
		
			
				|  |  |  |  |     peerConnection.ontrack = null; | 
		
	
		
			
				|  |  |  |  |     peerConnection.onicecandidate = null; | 
		
	
	
		
			
				
					|  |  |  | @ -747,11 +751,18 @@ function createOrGetPeerConnection(withPubkey: string) { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if (peerConnection && peerConnection?.iceConnectionState === 'disconnected') { | 
		
	
		
			
				|  |  |  |  |       //this will trigger a negotation event with iceRestart set to true in the createOffer options set
 | 
		
	
		
			
				|  |  |  |  |       global.setTimeout(() => { | 
		
	
		
			
				|  |  |  |  |       global.setTimeout(async () => { | 
		
	
		
			
				|  |  |  |  |         window.log.info('onconnectionstatechange disconnected: restartIce()'); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if (peerConnection?.iceConnectionState === 'disconnected') { | 
		
	
		
			
				|  |  |  |  |         if ( | 
		
	
		
			
				|  |  |  |  |           peerConnection?.iceConnectionState === 'disconnected' && | 
		
	
		
			
				|  |  |  |  |           withPubkey?.length && | 
		
	
		
			
				|  |  |  |  |           weAreCallerOnCurrentCall === true | 
		
	
		
			
				|  |  |  |  |         ) { | 
		
	
		
			
				|  |  |  |  |           // we are the caller and the connection got dropped out, we need to send a new offer with iceRestart set to true.
 | 
		
	
		
			
				|  |  |  |  |           // the recipient will get that new offer and send us a response back if he still online
 | 
		
	
		
			
				|  |  |  |  |           (peerConnection as any).restartIce(); | 
		
	
		
			
				|  |  |  |  |           await createOfferAndSendIt(withPubkey); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |       }, 2000); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
	
		
			
				
					|  |  |  | 
 |