diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index ec71e5ff31..ef5cd03b33 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -464,6 +464,7 @@ public protocol PresentationCallManager: AnyObject { var currentCallSignal: Signal { get } var currentGroupCallSignal: Signal { 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 diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 0712e07349..72b4af34ec 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -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 = "" } diff --git a/submodules/ChatListUI/Sources/ChatListControllerNode.swift b/submodules/ChatListUI/Sources/ChatListControllerNode.swift index cd0a9fd1b4..4b0bfb3d22 100644 --- a/submodules/ChatListUI/Sources/ChatListControllerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListControllerNode.swift @@ -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 diff --git a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift index 1855341f7c..0cf186c698 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift @@ -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(nil) public var currentCallSignal: Signal { return self.currentCallPromise.get()