Only update label on timer

The rest of the UI only changes on Call.state change.

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent 7b33cbb933
commit 0797df19b9

@ -476,6 +476,8 @@ class CallViewController: UIViewController, CallDelegate {
} }
func localizedTextForCallState(_ callState: CallState) -> String { func localizedTextForCallState(_ callState: CallState) -> String {
assert(Thread.isMainThread)
switch callState { switch callState {
case .idle, .remoteHangup, .localHangup: case .idle, .remoteHangup, .localHangup:
return NSLocalizedString("IN_CALL_TERMINATED", comment: "Call setup status label") return NSLocalizedString("IN_CALL_TERMINATED", comment: "Call setup status label")
@ -517,11 +519,14 @@ class CallViewController: UIViewController, CallDelegate {
} }
} }
func updateCallUI(callState: CallState) { func updateCallStatusLabel(callState: CallState) {
let textForState = localizedTextForCallState(callState) assert(Thread.isMainThread)
Logger.info("\(TAG) new call status: \(callState) aka \"\(textForState)\"") self.callStatusLabel.text = localizedTextForCallState(callState)
}
self.callStatusLabel.text = textForState func updateCallUI(callState: CallState) {
assert(Thread.isMainThread)
updateCallStatusLabel(callState: callState)
// Show Incoming vs. Ongoing call controls // Show Incoming vs. Ongoing call controls
let isRinging = callState == .localRinging let isRinging = callState == .localRinging
@ -533,7 +538,7 @@ class CallViewController: UIViewController, CallDelegate {
// Dismiss Handling // Dismiss Handling
switch callState { switch callState {
case .remoteHangup, .remoteBusy, .localFailure: case .remoteHangup, .remoteBusy, .localFailure:
Logger.debug("\(TAG) dismissing after delay because new state is \(textForState)") Logger.debug("\(TAG) dismissing after delay because new state is \(callState)")
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
self.dismiss(animated: true) self.dismiss(animated: true)
} }
@ -560,7 +565,7 @@ class CallViewController: UIViewController, CallDelegate {
} }
func updateCallDuration(timer: Timer?) { func updateCallDuration(timer: Timer?) {
updateCallUI(callState: call.state) updateCallStatusLabel(callState: call.state)
} }
// MARK: - Actions // MARK: - Actions

Loading…
Cancel
Save