mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Disable camera while on a call
This commit is contained in:
parent
352d71a921
commit
4f5504ecab
@ -464,6 +464,7 @@ public protocol PresentationCallManager: AnyObject {
|
||||
var currentCallSignal: Signal<PresentationCall?, NoError> { get }
|
||||
var currentGroupCallSignal: Signal<PresentationGroupCall?, NoError> { get }
|
||||
var hasActiveCall: Bool { get }
|
||||
var hasActiveGroupCall: Bool { get }
|
||||
|
||||
func requestCall(context: AccountContext, peerId: EnginePeer.Id, isVideo: Bool, endCurrentIfAny: Bool) -> RequestCallResult
|
||||
func joinGroupCall(context: AccountContext, peerId: EnginePeer.Id, invite: String?, requestJoinAsPeerId: ((@escaping (EnginePeer.Id?) -> Void) -> Void)?, initialCall: EngineGroupCallDescription, endCurrentIfAny: Bool) -> JoinGroupCallManagerResult
|
||||
|
@ -2537,6 +2537,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
fileprivate func openStoryCamera(fromList: Bool) {
|
||||
var reachedCountLimit = false
|
||||
var premiumNeeded = false
|
||||
var hasActiveCall = false
|
||||
var hasActiveGroupCall = false
|
||||
|
||||
let storiesCountLimit = self.context.userLimits.maxExpiringStoriesCount
|
||||
if let rawStorySubscriptions = self.rawStorySubscriptions, let accountItem = rawStorySubscriptions.accountItem {
|
||||
@ -2556,7 +2558,15 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
break
|
||||
}
|
||||
|
||||
if reachedCountLimit || premiumNeeded {
|
||||
if let callManager = self.context.sharedContext.callManager {
|
||||
if callManager.hasActiveGroupCall {
|
||||
hasActiveGroupCall = true
|
||||
} else if callManager.hasActiveCall {
|
||||
hasActiveCall = true
|
||||
}
|
||||
}
|
||||
|
||||
if reachedCountLimit || premiumNeeded || hasActiveCall || hasActiveGroupCall {
|
||||
if let componentView = self.chatListHeaderView() {
|
||||
var sourceFrame: CGRect?
|
||||
if fromList {
|
||||
@ -2577,6 +2587,10 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
text = "Posting stories is currently available only\nto subscribers of [Telegram Premium]()."
|
||||
} else if reachedCountLimit {
|
||||
text = "You can't post more than **\(storiesCountLimit)** stories in **24 hours**."
|
||||
} else if hasActiveCall {
|
||||
text = "You can't post stories during a call."
|
||||
} else if hasActiveGroupCall {
|
||||
text = "You can't post stories during a voice chat."
|
||||
} else {
|
||||
text = ""
|
||||
}
|
||||
|
@ -1164,24 +1164,24 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
|
||||
self.applyItemNodeAsCurrent(id: .all, itemNode: itemNode)
|
||||
|
||||
let panRecognizer = InteractiveTransitionGestureRecognizer(target: self, action: #selector(self.panGesture(_:)), allowedDirections: { [weak self] _ in
|
||||
guard let strongSelf = self, strongSelf.availableFilters.count > 1 || strongSelf.controller?.isStoryPostingAvailable == true else {
|
||||
guard let self, self.availableFilters.count > 1 || (self.controller?.isStoryPostingAvailable == true && !(self.context.sharedContext.callManager?.hasActiveCall ?? false)) else {
|
||||
return []
|
||||
}
|
||||
guard case .chatList(.root) = strongSelf.location else {
|
||||
guard case .chatList(.root) = self.location else {
|
||||
return []
|
||||
}
|
||||
switch strongSelf.currentItemNode.visibleContentOffset() {
|
||||
switch self.currentItemNode.visibleContentOffset() {
|
||||
case let .known(value):
|
||||
if value < -strongSelf.currentItemNode.tempTopInset {
|
||||
if value < -self.currentItemNode.tempTopInset {
|
||||
return []
|
||||
}
|
||||
case .none, .unknown:
|
||||
break
|
||||
}
|
||||
if !strongSelf.currentItemNode.isNavigationInAFinalState {
|
||||
if !self.currentItemNode.isNavigationInAFinalState {
|
||||
return []
|
||||
}
|
||||
if strongSelf.availableFilters.count > 1 {
|
||||
if self.availableFilters.count > 1 {
|
||||
return [.leftCenter, .rightCenter]
|
||||
} else {
|
||||
return [.rightEdge]
|
||||
@ -1262,7 +1262,7 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
|
||||
return bandingStart + (1.0 - (1.0 / ((bandedOffset * coefficient / range) + 1.0))) * range
|
||||
}
|
||||
|
||||
if case .compact = layout.metrics.widthClass, self.controller?.isStoryPostingAvailable == true {
|
||||
if case .compact = layout.metrics.widthClass, self.controller?.isStoryPostingAvailable == true && !(self.context.sharedContext.callManager?.hasActiveCall ?? false) {
|
||||
let cameraIsAlreadyOpened = self.controller?.hasStoryCameraTransition ?? false
|
||||
if selectedIndex <= 0 && translation.x > 0.0 {
|
||||
transitionFraction = 0.0
|
||||
|
@ -86,6 +86,10 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
||||
return self.currentCall != nil || self.currentGroupCall != nil
|
||||
}
|
||||
|
||||
public var hasActiveGroupCall: Bool {
|
||||
return self.currentGroupCall != nil
|
||||
}
|
||||
|
||||
private let currentCallPromise = Promise<PresentationCall?>(nil)
|
||||
public var currentCallSignal: Signal<PresentationCall?, NoError> {
|
||||
return self.currentCallPromise.get()
|
||||
|
Loading…
x
Reference in New Issue
Block a user