fix linked device answering/ending call issues

This commit is contained in:
Ryan Zhao 2021-12-06 16:02:54 +11:00
parent 8443818020
commit 4658e76d46
2 changed files with 14 additions and 9 deletions

View File

@ -240,13 +240,17 @@ public final class SessionCall: NSObject, WebRTCSessionDelegate {
shouldMarkAsRead = true
} else {
switch mode {
case .local: shouldMarkAsRead = true
case .remote: break
case .unanswered: break
case .answeredElsewhere: shouldMarkAsRead = true
}
if messageToUpdate.callState == .incoming {
messageToUpdate.updateCallInfoMessage(.missed, using: transaction)
case .local:
shouldMarkAsRead = true
fallthrough
case .remote:
fallthrough
case .unanswered:
if messageToUpdate.callState == .incoming {
messageToUpdate.updateCallInfoMessage(.missed, using: transaction)
}
case .answeredElsewhere:
shouldMarkAsRead = true
}
}
if shouldMarkAsRead {

View File

@ -269,11 +269,12 @@ extension MessageReceiver {
public static func handleCallMessage(_ message: CallMessage, using transaction: Any) {
let transaction = transaction as! YapDatabaseReadWriteTransaction
// Ignore call messages from threads without outgoing messages
guard let sender = message.sender, let thread = TSContactThread.fetch(for: sender, using: transaction), thread.hasOutgoingInteraction(with: transaction) else { return }
switch message.kind! {
case .preOffer:
print("[Calls] Received pre-offer message.")
// It is enough just ignoring the pre offers, other call messages
// for this call would be dropped because of no Session call instance
guard let sender = message.sender, let thread = TSContactThread.fetch(for: sender, using: transaction), thread.hasOutgoingInteraction(with: transaction) else { return }
handleNewCallOfferMessageIfNeeded?(message, transaction)
case .offer:
print("[Calls] Received offer message.")