From 0797df19b97b6bf2fd7999012aea5f74cdaf7d8c Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 17 Jan 2017 19:31:25 -0500 Subject: [PATCH] Only update label on timer The rest of the UI only changes on Call.state change. // FREEBIE --- .../view controllers/CallViewController.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Signal/src/view controllers/CallViewController.swift b/Signal/src/view controllers/CallViewController.swift index b667b769b..c78a7d482 100644 --- a/Signal/src/view controllers/CallViewController.swift +++ b/Signal/src/view controllers/CallViewController.swift @@ -476,6 +476,8 @@ class CallViewController: UIViewController, CallDelegate { } func localizedTextForCallState(_ callState: CallState) -> String { + assert(Thread.isMainThread) + switch callState { case .idle, .remoteHangup, .localHangup: return NSLocalizedString("IN_CALL_TERMINATED", comment: "Call setup status label") @@ -517,11 +519,14 @@ class CallViewController: UIViewController, CallDelegate { } } - func updateCallUI(callState: CallState) { - let textForState = localizedTextForCallState(callState) - Logger.info("\(TAG) new call status: \(callState) aka \"\(textForState)\"") + func updateCallStatusLabel(callState: CallState) { + assert(Thread.isMainThread) + 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 let isRinging = callState == .localRinging @@ -533,7 +538,7 @@ class CallViewController: UIViewController, CallDelegate { // Dismiss Handling switch callState { 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) { self.dismiss(animated: true) } @@ -560,7 +565,7 @@ class CallViewController: UIViewController, CallDelegate { } func updateCallDuration(timer: Timer?) { - updateCallUI(callState: call.state) + updateCallStatusLabel(callState: call.state) } // MARK: - Actions