mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Reflect reconnecting state in calls
This commit is contained in:
@@ -16,6 +16,7 @@ public enum PresentationCallState: Equatable {
|
||||
case requesting(Bool)
|
||||
case connecting(Data?)
|
||||
case active(Double, Int32?, Data)
|
||||
case reconnecting(Double, Int32?, Data)
|
||||
case terminating
|
||||
case terminated(CallId?, CallSessionTerminationReason?, Bool)
|
||||
}
|
||||
|
||||
@@ -232,10 +232,18 @@ final class CallControllerNode: ASDisplayNode {
|
||||
text += "\n\(self.statusNode.subtitle)"
|
||||
}
|
||||
statusValue = .text(text)
|
||||
case let .active(timestamp, reception, keyVisualHash):
|
||||
case .active(let timestamp, let reception, let keyVisualHash), .reconnecting(let timestamp, let reception, let keyVisualHash):
|
||||
let strings = self.presentationData.strings
|
||||
var isReconnecting = false
|
||||
if case .reconnecting = callState {
|
||||
isReconnecting = true
|
||||
}
|
||||
statusValue = .timer({ value in
|
||||
if isReconnecting {
|
||||
return strings.Call_StatusConnecting
|
||||
} else {
|
||||
return strings.Call_StatusOngoing(value).0
|
||||
}
|
||||
}, timestamp)
|
||||
if self.keyTextData?.0 != keyVisualHash {
|
||||
let text = stringForEmojiHashOfData(keyVisualHash, 4)!
|
||||
|
||||
@@ -461,6 +461,15 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
self.activeTimestamp = timestamp
|
||||
}
|
||||
presentationState = .active(timestamp, reception, keyVisualHash)
|
||||
case .reconnecting:
|
||||
let timestamp: Double
|
||||
if let activeTimestamp = self.activeTimestamp {
|
||||
timestamp = activeTimestamp
|
||||
} else {
|
||||
timestamp = CFAbsoluteTimeGetCurrent()
|
||||
self.activeTimestamp = timestamp
|
||||
}
|
||||
presentationState = .reconnecting(timestamp, reception, keyVisualHash)
|
||||
}
|
||||
} else {
|
||||
presentationState = .connecting(keyVisualHash)
|
||||
@@ -520,7 +529,7 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
}
|
||||
if let presentationState = presentationState {
|
||||
self.statePromise.set(presentationState)
|
||||
self.updateTone(presentationState, previous: previous)
|
||||
self.updateTone(presentationState, callContextState: callContextState, previous: previous)
|
||||
}
|
||||
|
||||
if !self.shouldPresentCallRating {
|
||||
@@ -530,9 +539,11 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
}
|
||||
}
|
||||
|
||||
private func updateTone(_ state: PresentationCallState, previous: CallSession?) {
|
||||
private func updateTone(_ state: PresentationCallState, callContextState: OngoingCallContextState?, previous: CallSession?) {
|
||||
var tone: PresentationCallTone?
|
||||
if let previous = previous {
|
||||
if let callContextState = callContextState, case .reconnecting = callContextState {
|
||||
tone = .connecting
|
||||
} else if let previous = previous {
|
||||
switch previous.state {
|
||||
case .accepting, .active, .dropping, .requesting:
|
||||
switch state {
|
||||
|
||||
@@ -598,7 +598,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
resolvedText = .inProgress(nil)
|
||||
case .terminated:
|
||||
resolvedText = .none
|
||||
case let .active(timestamp, _, _):
|
||||
case .active(let timestamp, _, _), .reconnecting(let timestamp, _, _):
|
||||
resolvedText = .inProgress(timestamp)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -74,6 +74,7 @@ private let setupLogs: Bool = {
|
||||
public enum OngoingCallContextState {
|
||||
case initializing
|
||||
case connected
|
||||
case reconnecting
|
||||
case failed
|
||||
}
|
||||
|
||||
@@ -151,6 +152,8 @@ public final class OngoingCallContext {
|
||||
return .connected
|
||||
case .failed:
|
||||
return .failed
|
||||
case .reconnecting:
|
||||
return .reconnecting
|
||||
default:
|
||||
return .failed
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
typedef NS_ENUM(int32_t, OngoingCallState) {
|
||||
OngoingCallStateInitializing,
|
||||
OngoingCallStateConnected,
|
||||
OngoingCallStateFailed
|
||||
OngoingCallStateFailed,
|
||||
OngoingCallStateReconnecting
|
||||
};
|
||||
|
||||
typedef NS_ENUM(int32_t, OngoingCallNetworkType) {
|
||||
|
||||
@@ -374,6 +374,9 @@ static int callControllerDataSavingForType(OngoingCallDataSaving type) {
|
||||
case tgvoip::STATE_FAILED:
|
||||
callState = OngoingCallStateFailed;
|
||||
break;
|
||||
case tgvoip::STATE_RECONNECTING:
|
||||
callState = OngoingCallStateReconnecting;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user