diff --git a/submodules/CallListUI/BUILD b/submodules/CallListUI/BUILD index b10f67b243..6db1c1934a 100644 --- a/submodules/CallListUI/BUILD +++ b/submodules/CallListUI/BUILD @@ -26,6 +26,7 @@ swift_library( "//submodules/ChatListSearchItemHeader:ChatListSearchItemHeader", "//submodules/PeerOnlineMarkerNode:PeerOnlineMarkerNode", "//submodules/ContextUI:ContextUI", + "//submodules/TelegramBaseController:TelegramBaseController", ], visibility = [ "//visibility:public", diff --git a/submodules/CallListUI/Sources/CallListController.swift b/submodules/CallListUI/Sources/CallListController.swift index fec07a9481..1420a8bc21 100644 --- a/submodules/CallListUI/Sources/CallListController.swift +++ b/submodules/CallListUI/Sources/CallListController.swift @@ -14,6 +14,7 @@ import AlertUI import AppBundle import LocalizedPeerData import ContextUI +import TelegramBaseController public enum CallListControllerMode { case tab @@ -65,7 +66,7 @@ private final class DeleteAllButtonNode: ASDisplayNode { } } -public final class CallListController: ViewController { +public final class CallListController: TelegramBaseController { private var controllerNode: CallListControllerNode { return self.displayNode as! CallListControllerNode } @@ -98,7 +99,7 @@ public final class CallListController: ViewController { self.segmentedTitleView = ItemListControllerSegmentedTitleView(theme: self.presentationData.theme, segments: [self.presentationData.strings.Calls_All, self.presentationData.strings.Calls_Missed], selectedIndex: 0) - super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData)) + super.init(context: context, navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData), mediaAccessoryPanelVisibility: .none, locationBroadcastPanelSource: .none, groupCallPanelSource: .none) self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBarStyle.style @@ -199,6 +200,10 @@ public final class CallListController: ViewController { if let strongSelf = self { strongSelf.call(peerId, isVideo: isVideo) } + }, joinGroupCall: { [weak self] peerId, activeCall in + if let strongSelf = self { + strongSelf.joinGroupCall(peerId: peerId, invite: nil, activeCall: activeCall) + } }, openInfo: { [weak self] peerId, messages in if let strongSelf = self { let _ = (strongSelf.context.account.postbox.loadedPeerWithId(peerId) diff --git a/submodules/CallListUI/Sources/CallListControllerNode.swift b/submodules/CallListUI/Sources/CallListControllerNode.swift index 6b93e23a68..3e73269d38 100644 --- a/submodules/CallListUI/Sources/CallListControllerNode.swift +++ b/submodules/CallListUI/Sources/CallListControllerNode.swift @@ -199,6 +199,7 @@ final class CallListControllerNode: ASDisplayNode { private let emptyTextNode: ASTextNode private let call: (PeerId, Bool) -> Void + private let joinGroupCall: (PeerId, CachedChannelData.ActiveCall) -> Void private let openInfo: (PeerId, [Message]) -> Void private let emptyStateUpdated: (Bool) -> Void @@ -207,12 +208,13 @@ final class CallListControllerNode: ASDisplayNode { private let openGroupCallDisposable = MetaDisposable() - init(controller: CallListController, context: AccountContext, mode: CallListControllerMode, presentationData: PresentationData, call: @escaping (PeerId, Bool) -> Void, openInfo: @escaping (PeerId, [Message]) -> Void, emptyStateUpdated: @escaping (Bool) -> Void) { + init(controller: CallListController, context: AccountContext, mode: CallListControllerMode, presentationData: PresentationData, call: @escaping (PeerId, Bool) -> Void, joinGroupCall: @escaping (PeerId, CachedChannelData.ActiveCall) -> Void, openInfo: @escaping (PeerId, [Message]) -> Void, emptyStateUpdated: @escaping (Bool) -> Void) { self.controller = controller self.context = context self.mode = mode self.presentationData = presentationData self.call = call + self.joinGroupCall = joinGroupCall self.openInfo = openInfo self.emptyStateUpdated = emptyStateUpdated @@ -330,7 +332,13 @@ final class CallListControllerNode: ASDisplayNode { let account = strongSelf.context.account var signal: Signal = strongSelf.context.account.postbox.transaction { transaction -> CachedChannelData.ActiveCall? in - return (transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData)?.activeCall + let cachedData = transaction.getPeerCachedData(peerId: peerId) + if let cachedData = cachedData as? CachedChannelData { + return cachedData.activeCall + } else if let cachedData = cachedData as? CachedGroupData { + return cachedData.activeCall + } + return nil } |> mapToSignal { activeCall -> Signal in if let activeCall = activeCall { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 5a8ac7ecc5..1546986bea 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -1374,7 +1374,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode { } var removedPhotoResourceIds = Set() - func update(peer: Peer?, item: PeerInfoAvatarListItem?, theme: PresentationTheme, avatarSize: CGFloat, isExpanded: Bool) { + func update(peer: Peer?, item: PeerInfoAvatarListItem?, theme: PresentationTheme, avatarSize: CGFloat, isExpanded: Bool, isSettings: Bool) { if let peer = peer { let previousItem = self.item var item = item @@ -1434,7 +1434,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode { } } - self.containerNode.isGestureEnabled = true + self.containerNode.isGestureEnabled = !isSettings if let video = videoRepresentations.last, let peerReference = PeerReference(peer) { let videoFileReference = FileMediaReference.avatarList(peer: peerReference, media: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: 0), partialReference: nil, resource: video.representation.resource, previewRepresentations: representations.map { $0.representation }, videoThumbnails: [], immediateThumbnailData: immediateThumbnailData, mimeType: "video/mp4", size: nil, attributes: [.Animated, .Video(duration: 0, size: video.representation.dimensions, flags: [])])) @@ -1780,6 +1780,7 @@ final class PeerInfoEditingAvatarNode: ASDisplayNode { } final class PeerInfoAvatarListNode: ASDisplayNode { + private let isSettings: Bool let avatarContainerNode: PeerInfoAvatarTransformContainerNode let listContainerTransformNode: ASDisplayNode let listContainerNode: PeerInfoAvatarListContainerNode @@ -1791,7 +1792,9 @@ final class PeerInfoAvatarListNode: ASDisplayNode { var itemsUpdated: (([PeerInfoAvatarListItem]) -> Void)? - init(context: AccountContext, readyWhenGalleryLoads: Bool) { + init(context: AccountContext, readyWhenGalleryLoads: Bool, isSettings: Bool) { + self.isSettings = isSettings + self.avatarContainerNode = PeerInfoAvatarTransformContainerNode(context: context) self.listContainerTransformNode = ASDisplayNode() self.listContainerNode = PeerInfoAvatarListContainerNode(context: context) @@ -1840,7 +1843,7 @@ final class PeerInfoAvatarListNode: ASDisplayNode { strongSelf.item = items.first strongSelf.itemsUpdated?(items) if let (peer, theme, avatarSize, isExpanded) = strongSelf.arguments { - strongSelf.avatarContainerNode.update(peer: peer, item: strongSelf.item, theme: theme, avatarSize: avatarSize, isExpanded: isExpanded) + strongSelf.avatarContainerNode.update(peer: peer, item: strongSelf.item, theme: theme, avatarSize: avatarSize, isExpanded: isExpanded, isSettings: strongSelf.isSettings) } } } @@ -1848,7 +1851,7 @@ final class PeerInfoAvatarListNode: ASDisplayNode { func update(size: CGSize, avatarSize: CGFloat, isExpanded: Bool, peer: Peer?, theme: PresentationTheme, transition: ContainedViewLayoutTransition) { self.arguments = (peer, theme, avatarSize, isExpanded) - self.avatarContainerNode.update(peer: peer, item: self.item, theme: theme, avatarSize: avatarSize, isExpanded: isExpanded) + self.avatarContainerNode.update(peer: peer, item: self.item, theme: theme, avatarSize: avatarSize, isExpanded: isExpanded, isSettings: self.isSettings) } override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { @@ -2654,7 +2657,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { self.isSettings = isSettings self.videoCallsEnabled = VideoCallsConfiguration(appConfiguration: context.currentAppConfiguration.with { $0 }).areVideoCallsEnabled - self.avatarListNode = PeerInfoAvatarListNode(context: context, readyWhenGalleryLoads: avatarInitiallyExpanded) + self.avatarListNode = PeerInfoAvatarListNode(context: context, readyWhenGalleryLoads: avatarInitiallyExpanded, isSettings: isSettings) self.titleNodeContainer = ASDisplayNode() self.titleNodeRawContainer = ASDisplayNode() diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 623eff3cfe..60055f8f69 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -2773,18 +2773,18 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD } } else { screenData = peerInfoScreenData(context: context, peerId: peerId, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, isSettings: self.isSettings, ignoreGroupInCommon: ignoreGroupInCommon) - - var currentIsVideo = false - let item = self.headerNode.avatarListNode.listContainerNode.currentItemNode?.item - if let item = item, case let .image(image) = item { - currentIsVideo = !image.2.isEmpty - } - + self.headerNode.displayAvatarContextMenu = { [weak self] node, gesture in guard let strongSelf = self, let peer = strongSelf.data?.peer else { return } + var currentIsVideo = false + let item = strongSelf.headerNode.avatarListNode.listContainerNode.currentItemNode?.item + if let item = item, case let .image(image) = item { + currentIsVideo = !image.2.isEmpty + } + let items: [ContextMenuItem] = [ .action(ContextMenuActionItem(text: currentIsVideo ? strongSelf.presentationData.strings.PeerInfo_ReportProfileVideo : strongSelf.presentationData.strings.PeerInfo_ReportProfilePhoto, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Report"), color: theme.actionSheet.primaryTextColor)