Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 06a775b41a
commit dea37b422b

@ -25,7 +25,6 @@
#import <PastelogKit/Pastelog.h> #import <PastelogKit/Pastelog.h>
#import <PromiseKit/AnyPromise.h> #import <PromiseKit/AnyPromise.h>
#import <SignalServiceKit/OWSDisappearingMessagesJob.h> #import <SignalServiceKit/OWSDisappearingMessagesJob.h>
#import <SignalServiceKit/OWSDispatch.h>
#import <SignalServiceKit/OWSIncomingMessageReadObserver.h> #import <SignalServiceKit/OWSIncomingMessageReadObserver.h>
#import <SignalServiceKit/OWSMessageSender.h> #import <SignalServiceKit/OWSMessageSender.h>
#import <SignalServiceKit/TSAccountManager.h> #import <SignalServiceKit/TSAccountManager.h>

@ -52,12 +52,6 @@ import Foundation
ensureIsEnabled(call: call) ensureIsEnabled(call: call)
} }
internal func callRecordDidChange(call: SignalCall, callRecord: TSCall?) {
AssertIsOnMainThread()
// Do nothing.
}
private func ensureIsEnabled(call: SignalCall) { private func ensureIsEnabled(call: SignalCall) {
// Auto-enable speakerphone when local video is enabled. // Auto-enable speakerphone when local video is enabled.
if call.hasLocalVideo { if call.hasLocalVideo {

@ -388,14 +388,17 @@ protocol CallServiceObserver: class {
*/ */
public func handleMissedCall(_ call: SignalCall, thread: TSContactThread) { public func handleMissedCall(_ call: SignalCall, thread: TSContactThread) {
AssertIsOnMainThread() AssertIsOnMainThread()
// Insert missed call record // Insert missed call record
if call.callRecord == nil { if let callRecord = call.callRecord {
if (callRecord.callType == RPRecentCallTypeIncoming) {
callRecord.updateCallType(RPRecentCallTypeMissed)
}
} else {
call.callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), call.callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(),
withCallNumber: thread.contactIdentifier(), withCallNumber: thread.contactIdentifier(),
callType: RPRecentCallTypeMissed, callType: RPRecentCallTypeMissed,
in: thread) in: thread)
} else if (call.callRecord!.callType == RPRecentCallTypeIncoming) {
call.callRecord!.updateCallType(RPRecentCallTypeMissed)
} }
assert(call.callRecord != nil) assert(call.callRecord != nil)
@ -1150,7 +1153,6 @@ protocol CallServiceObserver: class {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.info("\(self.TAG) \(#function): \(state)") Logger.info("\(self.TAG) \(#function): \(state)")
updateIsVideoEnabled() updateIsVideoEnabled()
updateCallRecordType(call: call)
} }
internal func hasLocalVideoDidChange(call: SignalCall, hasLocalVideo: Bool) { internal func hasLocalVideoDidChange(call: SignalCall, hasLocalVideo: Bool) {
@ -1169,33 +1171,6 @@ protocol CallServiceObserver: class {
// Do nothing // Do nothing
} }
internal func callRecordDidChange(call: SignalCall, callRecord: TSCall?) {
AssertIsOnMainThread()
updateCallRecordType(call: call)
}
internal func updateCallRecordType(call: SignalCall?) {
AssertIsOnMainThread()
guard call != nil else {
return
}
guard call!.callRecord != nil else {
return
}
// Mark incomplete calls as completed if call has connected.
if call!.state == .connected &&
call!.callRecord!.callType == RPRecentCallTypeOutgoingIncomplete {
call!.callRecord!.updateCallType(RPRecentCallTypeOutgoing)
}
if call!.state == .connected &&
call!.callRecord!.callType == RPRecentCallTypeIncomingIncomplete {
call!.callRecord!.updateCallType(RPRecentCallTypeIncoming)
}
}
// MARK: - Video // MARK: - Video
private func shouldHaveLocalVideoTrack() -> Bool { private func shouldHaveLocalVideoTrack() -> Bool {

@ -27,7 +27,6 @@ protocol CallObserver: class {
func hasLocalVideoDidChange(call: SignalCall, hasLocalVideo: Bool) func hasLocalVideoDidChange(call: SignalCall, hasLocalVideo: Bool)
func muteDidChange(call: SignalCall, isMuted: Bool) func muteDidChange(call: SignalCall, isMuted: Bool)
func speakerphoneDidChange(call: SignalCall, isEnabled: Bool) func speakerphoneDidChange(call: SignalCall, isEnabled: Bool)
func callRecordDidChange(call: SignalCall, callRecord: TSCall?)
} }
/** /**
@ -55,9 +54,7 @@ protocol CallObserver: class {
AssertIsOnMainThread() AssertIsOnMainThread()
assert(oldValue == nil) assert(oldValue == nil)
for observer in observers { updateCallRecordType()
observer.value?.callRecordDidChange(call: self, callRecord: callRecord)
}
} }
} }
@ -85,6 +82,8 @@ protocol CallObserver: class {
connectedDate = nil connectedDate = nil
} }
updateCallRecordType()
for observer in observers { for observer in observers {
observer.value?.stateDidChange(call: self, state: state) observer.value?.stateDidChange(call: self, state: state)
} }
@ -164,6 +163,24 @@ protocol CallObserver: class {
observers = [] observers = []
} }
private func updateCallRecordType() {
AssertIsOnMainThread()
guard let callRecord = self.callRecord else {
return
}
// Mark incomplete calls as completed if call has connected.
if state == .connected &&
callRecord.callType == RPRecentCallTypeOutgoingIncomplete {
callRecord.updateCallType(RPRecentCallTypeOutgoing)
}
if state == .connected &&
callRecord.callType == RPRecentCallTypeIncomingIncomplete {
callRecord.updateCallType(RPRecentCallTypeIncoming)
}
}
// MARK: Equatable // MARK: Equatable
static func == (lhs: SignalCall, rhs: SignalCall) -> Bool { static func == (lhs: SignalCall, rhs: SignalCall) -> Bool {

@ -733,12 +733,6 @@ class CallViewController: UIViewController, CallObserver, CallServiceObserver, R
self.updateCallUI(callState: call.state) self.updateCallUI(callState: call.state)
} }
internal func callRecordDidChange(call: SignalCall, callRecord: TSCall?) {
AssertIsOnMainThread()
// Do nothing.
}
// MARK: - Video // MARK: - Video
internal func updateLocalVideoTrack(localVideoTrack: RTCVideoTrack?) { internal func updateLocalVideoTrack(localVideoTrack: RTCVideoTrack?) {

Loading…
Cancel
Save