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 {
private func checkCallOptions() {
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
}).map({_ in
return true
})
}()
callIsActive
.subscribe(onNext: { active in
.subscribe(onNext: { [unowned self] active in
if !active {
return
}
......@@ -71,7 +71,7 @@ class ButtonsContainerViewModel {
!hide
})
}()
speakerIsAvailable.subscribe(onNext: { available in
speakerIsAvailable.subscribe(onNext: { [unowned self] available in
if available {
self.avalaibleCallOptions.onNext(.optionsWithSpeakerphone)
return
......
......@@ -168,7 +168,7 @@
<constraint firstItem="DMu-Or-dd7" firstAttribute="centerY" secondItem="ZVy-nB-bKJ" secondAttribute="centerY" id="yFh-zq-lXh"/>
</constraints>
</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"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
......
......@@ -79,7 +79,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
}
func animateCallCircle() {
self.log.debug("animate pulse")
self.callPulse.alpha = 0.5
self.callPulse.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
UIView.animate(withDuration: 1.5, animations: {
......@@ -261,10 +260,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
}
@objc func screenTapped() {
let callState = self.viewModel.call?.state
if callState == .connecting || callState == .ringing {
return
}
self.viewModel.respondOnTap()
}
......
......@@ -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> = {
return Observable.combineLatest(self.screenTapped.asObservable(), callPaused) { (tapped, paused) in
if self.isAudioOnly {
return false
}
if tapped && !paused {
return Observable.combineLatest(self.screenTapped.asObservable(),
shouldRespondOnTap) { [unowned self] (tapped, shouldRespond) in
if tapped && shouldRespond && !self.isAudioOnly {
return true
}
return false
......@@ -161,7 +168,8 @@ class CallViewModel: Stateable, ViewModel {
lazy var showCancelOption: Observable<Bool> = {
return self.callService.currentCall
.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
return call.state == .connecting || call.state == .ringing
})
......@@ -183,7 +191,7 @@ class CallViewModel: Stateable, ViewModel {
}()
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.state == .current
}).map({call in
......@@ -226,7 +234,7 @@ class CallViewModel: Stateable, ViewModel {
}()
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.state == .current
}).map({call in
......@@ -247,7 +255,7 @@ class CallViewModel: Stateable, ViewModel {
}()
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.state == .hold ||
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