Voice Chat Fixes

This commit is contained in:
Ilya Laktyushin
2021-04-08 00:29:24 +03:00
parent 8fab0d8d3a
commit 53da3e1e46
27 changed files with 133 additions and 70 deletions

View File

@@ -2438,8 +2438,12 @@ public final class VoiceChatController: ViewController {
@objc func dimTapGesture(_ recognizer: UITapGestureRecognizer) {
if case .ended = recognizer.state {
self.controller?.dismiss(closing: false)
self.controller?.dismissAllTooltips()
if self.isScheduling {
self.dismissScheduled()
} else {
self.controller?.dismiss(closing: false)
self.controller?.dismissAllTooltips()
}
}
}
@@ -2594,7 +2598,7 @@ public final class VoiceChatController: ViewController {
self.call.startScheduled()
self.transitionToCall()
} else {
self.call.toggleScheduledSubscription(!callState.subscribedToScheduled)
}
}
default:
@@ -2670,8 +2674,6 @@ public final class VoiceChatController: ViewController {
|> deliverOnMainQueue).start(next: { [weak self] inviteLinks in
if let inviteLinks = inviteLinks {
self?.presentShare(inviteLinks)
} else {
self?.presentShare(GroupCallInviteLinks(listenerLink: "a", speakerLink: nil))
}
})
return
@@ -3199,16 +3201,20 @@ public final class VoiceChatController: ViewController {
let actionButtonSubtitle: String
var actionButtonEnabled = true
if let callState = self.callState, !self.isScheduling {
var isScheduled = callState.scheduleTimestamp != nil
if isScheduled {
if callState.scheduleTimestamp != nil {
self.ignoreNextConnecting = true
if callState.canManageCall {
actionButtonState = .scheduled(state: .start)
actionButtonTitle = self.presentationData.strings.VoiceChat_StartNow
actionButtonSubtitle = ""
} else {
actionButtonState = .scheduled(state: .subscribe)
actionButtonTitle = self.presentationData.strings.VoiceChat_SetReminder
if callState.subscribedToScheduled {
actionButtonState = .scheduled(state: .unsubscribe)
actionButtonTitle = self.presentationData.strings.VoiceChat_CancelReminder
} else {
actionButtonState = .scheduled(state: .subscribe)
actionButtonTitle = self.presentationData.strings.VoiceChat_SetReminder
}
actionButtonSubtitle = ""
}
} else {
@@ -3681,6 +3687,7 @@ public final class VoiceChatController: ViewController {
@objc func panGesture(_ recognizer: UIPanGestureRecognizer) {
let contentOffset = self.listNode.visibleContentOffset()
let isScheduling = self.isScheduling || self.callState?.scheduleTimestamp != nil
switch recognizer.state {
case .began:
let topInset: CGFloat
@@ -3696,7 +3703,7 @@ public final class VoiceChatController: ViewController {
self.controller?.dismissAllTooltips()
case .changed:
var translation = recognizer.translation(in: self.contentContainer.view).y
if (self.isScheduling || self.callState?.scheduleTimestamp != nil) && translation < 0.0 {
if isScheduling && translation < 0.0 {
return
}
var topInset: CGFloat = 0.0
@@ -3802,7 +3809,7 @@ public final class VoiceChatController: ViewController {
self.controller?.dismiss(closing: false, manual: true)
}
dismissing = true
} else if !self.isScheduling && (velocity.y < -300.0 || offset < topInset / 2.0) {
} else if !isScheduling && (velocity.y < -300.0 || offset < topInset / 2.0) {
if velocity.y > -1500.0 && !self.isFullscreen {
DispatchQueue.main.async {
self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: ListViewScrollToItem(index: 0, position: .top(0.0), animated: true, curve: .Default(duration: nil), directionHint: .Up), updateSizeAndInsets: nil, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in })
@@ -3819,7 +3826,7 @@ public final class VoiceChatController: ViewController {
self.updateFloatingHeaderOffset(offset: self.currentContentOffset ?? 0.0, transition: .animated(duration: 0.3, curve: .easeInOut), completion: {
self.animatingExpansion = false
})
} else if !self.isScheduling {
} else if !isScheduling {
self.updateIsFullscreen(false)
self.animatingExpansion = true
self.listNode.scroller.setContentOffset(CGPoint(), animated: false)