fix call issues

pull/1061/head
Ryan ZHAO 7 months ago
parent 3c3fbec6b4
commit c4ac8bbe46

@ -296,10 +296,10 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
func endSessionCall() { func endSessionCall() {
guard !hasEnded else { return } guard !hasEnded else { return }
let sessionId: String = self.sessionId
webRTCSession.hangUp() webRTCSession.hangUp()
dependencies[singleton: .appReadiness].runNowOrWhenAppDidBecomeReady { [webRTCSession, sessionId] in
webRTCSession.endCall(with: sessionId) webRTCSession.endCall(with: sessionId)
}
hasEnded = true hasEnded = true
} }

@ -230,7 +230,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
else { return } else { return }
if if
let conversationVC: ConversationVC = (presentingVC as? TopBannerController)?.wrappedViewController() as? ConversationVC, let conversationVC: ConversationVC = presentingVC as? ConversationVC,
conversationVC.viewModel.threadData.threadId == call.sessionId conversationVC.viewModel.threadData.threadId == call.sessionId
{ {
let callVC = CallVC(for: call, using: dependencies) let callVC = CallVC(for: call, using: dependencies)
@ -301,7 +301,9 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
dependencies[defaults: .appGroup, key: .lastCallPreOffer] = nil dependencies[defaults: .appGroup, key: .lastCallPreOffer] = nil
if dependencies[singleton: .appContext].isNotInForeground { if dependencies[singleton: .appContext].isNotInForeground {
dependencies[singleton: .appReadiness].runNowOrWhenAppDidBecomeReady { [dependencies] in
dependencies[singleton: .currentUserPoller].stop() dependencies[singleton: .currentUserPoller].stop()
}
Log.flush() Log.flush()
} }
} }

@ -365,7 +365,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
public func endCall(with sessionId: String) { public func endCall(with sessionId: String) {
return dependencies[singleton: .storage] return dependencies[singleton: .storage]
.writePublisher { [dependencies] db -> Network.PreparedRequest<Void> in .writePublisher { [dependencies, uuid] db -> Network.PreparedRequest<Void> in
guard let thread: SessionThread = try SessionThread.fetchOne(db, id: sessionId) else { guard let thread: SessionThread = try SessionThread.fetchOne(db, id: sessionId) else {
throw WebRTCSessionError.noThread throw WebRTCSessionError.noThread
} }
@ -376,7 +376,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
.preparedSend( .preparedSend(
db, db,
message: CallMessage( message: CallMessage(
uuid: self.uuid, uuid: uuid,
kind: .endCall, kind: .endCall,
sdps: [] sdps: []
) )

@ -295,12 +295,10 @@ public class PushRegistrationManager: NSObject, PKPushRegistryDelegate {
dependencies[singleton: .jobRunner].appDidBecomeActive() dependencies[singleton: .jobRunner].appDidBecomeActive()
dependencies[singleton: .appReadiness].runNowOrWhenAppDidBecomeReady { dependencies[singleton: .appReadiness].runNowOrWhenAppDidBecomeReady { [dependencies] in
}
// NOTE: Just start 1-1 poller so that it won't wait for polling group messages // NOTE: Just start 1-1 poller so that it won't wait for polling group messages
dependencies[singleton: .currentUserPoller].startIfNeeded(forceStartInBackground: true) dependencies[singleton: .currentUserPoller].startIfNeeded(forceStartInBackground: true)
}
call.reportIncomingCallIfNeeded { error in call.reportIncomingCallIfNeeded { error in
if let error = error { if let error = error {

Loading…
Cancel
Save