Commit 1e399596 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

fix: prevent call options from being hidden

Fix race condition when buttons were hidden after pausing call.

Change-Id: I5f38427b5bb19de3ead46cc5b0158716a942f6b3
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 19c4ce68
...@@ -46,14 +46,14 @@ class ButtonsContainerViewModel { ...@@ -46,14 +46,14 @@ class ButtonsContainerViewModel {
private func checkCallOptions() { private func checkCallOptions() {
let callIsActive: Observable<Bool> = { let callIsActive: Observable<Bool> = {
self.callService.currentCall.filter({ call in self.callService.currentCall.filter({ [unowned self] call in
return call.state == .current && call.callId == self.callID return call.state == .current && call.callId == self.callID
}).map({_ in }).map({_ in
return true return true
}) })
}() }()
callIsActive callIsActive
.subscribe(onNext: { active in .subscribe(onNext: { [unowned self] active in
if !active { if !active {
return return
} }
...@@ -71,7 +71,7 @@ class ButtonsContainerViewModel { ...@@ -71,7 +71,7 @@ class ButtonsContainerViewModel {
!hide !hide
}) })
}() }()
speakerIsAvailable.subscribe(onNext: { available in speakerIsAvailable.subscribe(onNext: { [unowned self] available in
if available { if available {
self.avalaibleCallOptions.onNext(.optionsWithSpeakerphone) self.avalaibleCallOptions.onNext(.optionsWithSpeakerphone)
return return
......
...@@ -168,7 +168,7 @@ ...@@ -168,7 +168,7 @@
<constraint firstItem="DMu-Or-dd7" firstAttribute="centerY" secondItem="ZVy-nB-bKJ" secondAttribute="centerY" id="yFh-zq-lXh"/> <constraint firstItem="DMu-Or-dd7" firstAttribute="centerY" secondItem="ZVy-nB-bKJ" secondAttribute="centerY" id="yFh-zq-lXh"/>
</constraints> </constraints>
</view> </view>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LK6-u0-eLU" customClass="ButtonsContainerView" customModule="Ring" customModuleProvider="target"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LK6-u0-eLU" customClass="ButtonsContainerView" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="0.0" y="517" width="375" height="150"/> <rect key="frame" x="0.0" y="517" width="375" height="150"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints> <constraints>
......
...@@ -79,7 +79,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased { ...@@ -79,7 +79,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
} }
func animateCallCircle() { func animateCallCircle() {
self.log.debug("animate pulse")
self.callPulse.alpha = 0.5 self.callPulse.alpha = 0.5
self.callPulse.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) self.callPulse.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
UIView.animate(withDuration: 1.5, animations: { UIView.animate(withDuration: 1.5, animations: {
...@@ -261,10 +260,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased { ...@@ -261,10 +260,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
} }
@objc func screenTapped() { @objc func screenTapped() {
let callState = self.viewModel.call?.state
if callState == .connecting || callState == .ringing {
return
}
self.viewModel.respondOnTap() self.viewModel.respondOnTap()
} }
......
...@@ -146,12 +146,19 @@ class CallViewModel: Stateable, ViewModel { ...@@ -146,12 +146,19 @@ class CallViewModel: Stateable, ViewModel {
}) })
}() }()
lazy var shouldRespondOnTap: Observable<Bool> = {
return self.callService.currentCall
.filter({ [weak self] call in
return call.callId == self?.call?.callId
}).map({ call in
return call.state == .current
})
}()
lazy var showCallOptions: Observable<Bool> = { lazy var showCallOptions: Observable<Bool> = {
return Observable.combineLatest(self.screenTapped.asObservable(), callPaused) { (tapped, paused) in return Observable.combineLatest(self.screenTapped.asObservable(),
if self.isAudioOnly { shouldRespondOnTap) { [unowned self] (tapped, shouldRespond) in
return false if tapped && shouldRespond && !self.isAudioOnly {
}
if tapped && !paused {
return true return true
} }
return false return false
...@@ -161,7 +168,8 @@ class CallViewModel: Stateable, ViewModel { ...@@ -161,7 +168,8 @@ class CallViewModel: Stateable, ViewModel {
lazy var showCancelOption: Observable<Bool> = { lazy var showCancelOption: Observable<Bool> = {
return self.callService.currentCall return self.callService.currentCall
.filter({ [weak self] call in .filter({ [weak self] call in
return call.callId == self?.call?.callId return call.callId == self?.call?.callId &&
(call.state == .connecting || call.state == .ringing || call.state == .current)
}).map({ call in }).map({ call in
return call.state == .connecting || call.state == .ringing return call.state == .connecting || call.state == .ringing
}) })
...@@ -183,7 +191,7 @@ class CallViewModel: Stateable, ViewModel { ...@@ -183,7 +191,7 @@ class CallViewModel: Stateable, ViewModel {
}() }()
lazy var videoMuted: Observable<Bool> = { lazy var videoMuted: Observable<Bool> = {
return self.callService.currentCall.filter({ call in return self.callService.currentCall.filter({ [unowned self] call in
call.callId == self.call?.callId && call.callId == self.call?.callId &&
call.state == .current call.state == .current
}).map({call in }).map({call in
...@@ -226,7 +234,7 @@ class CallViewModel: Stateable, ViewModel { ...@@ -226,7 +234,7 @@ class CallViewModel: Stateable, ViewModel {
}() }()
lazy var audioMuted: Observable<Bool> = { lazy var audioMuted: Observable<Bool> = {
return self.callService.currentCall.filter({ call in return self.callService.currentCall.filter({ [unowned self] call in
call.callId == self.call?.callId && call.callId == self.call?.callId &&
call.state == .current call.state == .current
}).map({call in }).map({call in
...@@ -247,7 +255,7 @@ class CallViewModel: Stateable, ViewModel { ...@@ -247,7 +255,7 @@ class CallViewModel: Stateable, ViewModel {
}() }()
lazy var callPaused: Observable<Bool> = { lazy var callPaused: Observable<Bool> = {
return self.callService.currentCall.filter({ call in return self.callService.currentCall.filter({ [unowned self] call in
call.callId == self.call?.callId && call.callId == self.call?.callId &&
(call.state == .hold || (call.state == .hold ||
call.state == .unhold || call.state == .unhold ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment