From 9decf67b7ae284e58b6c3c71cd9ee8b1e19d8c34 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Mon, 31 Mar 2025 13:39:43 +1100 Subject: [PATCH] fix an issue where reconnecting label is displayed incorrectly --- Session/Calls/Call Management/SessionCall.swift | 7 +++---- .../Call Management/SessionCallManager+CXProvider.swift | 2 +- Session/Conversations/ConversationVC+Interaction.swift | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Session/Calls/Call Management/SessionCall.swift b/Session/Calls/Call Management/SessionCall.swift index c973039a2..51f6fa4e6 100644 --- a/Session/Calls/Call Management/SessionCall.swift +++ b/Session/Calls/Call Management/SessionCall.swift @@ -25,7 +25,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { public let mode: CallMode let contactName: String var audioMode: AudioMode - let isOutgoing: Bool var remoteSDP: RTCSessionDescription? = nil { didSet { if hasStartedConnecting, let sdp = remoteSDP { @@ -155,7 +154,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { // MARK: - Initialization - init(for sessionId: String, contactName: String, uuid: String, mode: CallMode, outgoing: Bool = false, using dependencies: Dependencies) { + init(for sessionId: String, contactName: String, uuid: String, mode: CallMode, using dependencies: Dependencies) { self.dependencies = dependencies self.sessionId = sessionId self.contactName = contactName @@ -164,7 +163,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { self.mode = mode self.audioMode = .earpiece self.webRTCSession = WebRTCSession.current ?? WebRTCSession(for: sessionId, with: uuid, using: dependencies) - self.isOutgoing = outgoing self.currentConnectionStep = (mode == .offer ? OfferStep.initializing : AnswerStep.receivedOffer) self.connectionStepsRecord = [Bool](repeating: false, count: (mode == .answer ? 5 : 6)) WebRTCSession.current = self.webRTCSession @@ -466,13 +464,14 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { } public func reconnectIfNeeded() { + guard !self.hasEnded else { return } setupTimeoutTimer() hasStartedReconnecting?() - guard isOutgoing else { return } tryToReconnect() } private func tryToReconnect() { + guard self.mode == .offer else { return } reconnectTimer?.invalidate() // Register a callback to get the current network status then remove it immediately as we only diff --git a/Session/Calls/Call Management/SessionCallManager+CXProvider.swift b/Session/Calls/Call Management/SessionCallManager+CXProvider.swift index 6eed668fd..d945b438c 100644 --- a/Session/Calls/Call Management/SessionCallManager+CXProvider.swift +++ b/Session/Calls/Call Management/SessionCallManager+CXProvider.swift @@ -78,7 +78,7 @@ extension SessionCallManager: CXProviderDelegate { guard let call: SessionCall = (self.currentCall as? SessionCall) else { return } call.webRTCSession.audioSessionDidActivate(audioSession) - if call.isOutgoing && !call.hasConnected { CallRingTonePlayer.shared.startPlayingRingTone() } + if call.mode == .offer && !call.hasConnected { CallRingTonePlayer.shared.startPlayingRingTone() } } public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) { diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index d3a3adcb5..3953c5bb2 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -186,7 +186,6 @@ extension ConversationVC: contactName: self.viewModel.threadData.displayName, uuid: UUID().uuidString.lowercased(), mode: .offer, - outgoing: true, using: dependencies ) })