Commit 0d191c56 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

conversation: cleanup

- safe access in subscriptions
- show call button only for active calls (current or on hold)

Change-Id: I4f202fcb48c128747c730ec3a14871a340308865
parent 96982ae8
......@@ -519,29 +519,28 @@ class ConversationViewController: UIViewController,
self.viewModel.showCallButton
.observeOn(MainScheduler.instance)
.startWith(self.viewModel.haveCurrentCall())
.subscribe(onNext: { [unowned self] show in
.subscribe(onNext: { [weak self] show in
if show {
// let deadlineTime = DispatchTime.now() + .seconds(3)
DispatchQueue.main.async {
if self.viewModel.currentCallId.value.isEmpty {
if self?.viewModel.currentCallId.value.isEmpty ?? true {
return
}
self.currentCallButton.isHidden = false
self.currentCallLabel.isHidden = false
self.currentCallLabel.blink()
self.callButtonHeightConstraint.constant = 60
self?.currentCallButton.isHidden = false
self?.currentCallLabel.isHidden = false
self?.currentCallLabel.blink()
self?.callButtonHeightConstraint.constant = 60
}
return
}
self.currentCallButton.isHidden = true
self.currentCallLabel.isHidden = true
self.callButtonHeightConstraint.constant = 0
self.currentCallLabel.layer.removeAllAnimations()
self?.currentCallButton.isHidden = true
self?.currentCallLabel.isHidden = true
self?.callButtonHeightConstraint.constant = 0
self?.currentCallLabel.layer.removeAllAnimations()
}).disposed(by: disposeBag)
currentCallButton.rx.tap
.throttle(0.5, scheduler: MainScheduler.instance)
.subscribe(onNext: { [unowned self] in
self.viewModel.openCall()
.subscribe(onNext: { [weak self] in
self?.viewModel.openCall()
})
.disposed(by: self.disposeBag)
}
......
......@@ -470,9 +470,6 @@ class ConversationViewModel: Stateable, ViewModel {
func callIsValid (call: CallModel) -> Bool {
return call.stateValue == CallState.hold.rawValue ||
call.stateValue == CallState.unhold.rawValue ||
call.stateValue == CallState.incoming.rawValue ||
call.stateValue == CallState.connecting.rawValue ||
call.stateValue == CallState.ringing.rawValue ||
call.stateValue == CallState.current.rawValue
}
......
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