From dcde323740f411e72b6d95521d528adef512c90f Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 11 Apr 2025 17:16:36 +0400 Subject: [PATCH] Conference --- .../Sources/ContactSelectionController.swift | 10 ++++++++-- .../CallListUI/Sources/CallListControllerNode.swift | 2 +- .../TelegramCallsUI/Sources/CallController.swift | 1 + .../TelegramCallsUI/Sources/VideoChatScreen.swift | 9 +++++++++ .../StoryItemSetContainerViewSendMessage.swift | 2 +- submodules/TelegramUI/Sources/ChatController.swift | 2 +- .../Sources/ChatControllerOpenAttachmentMenu.swift | 4 ++-- .../Sources/ContactSelectionController.swift | 12 +++++++----- submodules/TelegramUI/Sources/OpenResolvedUrl.swift | 5 +++++ 9 files changed, 35 insertions(+), 12 deletions(-) diff --git a/submodules/AccountContext/Sources/ContactSelectionController.swift b/submodules/AccountContext/Sources/ContactSelectionController.swift index 191e464c78..4b1ae89cca 100644 --- a/submodules/AccountContext/Sources/ContactSelectionController.swift +++ b/submodules/AccountContext/Sources/ContactSelectionController.swift @@ -99,6 +99,12 @@ public enum ContactListPeer: Equatable { } public final class ContactSelectionControllerParams { + public enum MultipleSelectionMode { + case disabled + case possible + case always + } + public let context: AccountContext public let updatedPresentationData: (initial: PresentationData, signal: Signal)? public let mode: ContactSelectionControllerMode @@ -107,7 +113,7 @@ public final class ContactSelectionControllerParams { public let options: Signal<[ContactListAdditionalOption], NoError> public let displayDeviceContacts: Bool public let displayCallIcons: Bool - public let multipleSelection: Bool + public let multipleSelection: MultipleSelectionMode public let requirePhoneNumbers: Bool public let allowChannelsInSearch: Bool public let confirmation: (ContactListPeer) -> Signal @@ -124,7 +130,7 @@ public final class ContactSelectionControllerParams { options: Signal<[ContactListAdditionalOption], NoError> = .single([]), displayDeviceContacts: Bool = false, displayCallIcons: Bool = false, - multipleSelection: Bool = false, + multipleSelection: MultipleSelectionMode = .disabled, requirePhoneNumbers: Bool = false, allowChannelsInSearch: Bool = false, confirmation: @escaping (ContactListPeer) -> Signal = { _ in .single(true) }, diff --git a/submodules/CallListUI/Sources/CallListControllerNode.swift b/submodules/CallListUI/Sources/CallListControllerNode.swift index dfb1a324e2..cd9c6c87be 100644 --- a/submodules/CallListUI/Sources/CallListControllerNode.swift +++ b/submodules/CallListUI/Sources/CallListControllerNode.swift @@ -525,7 +525,7 @@ final class CallListControllerNode: ASDisplayNode { |> mapToQueue { (updateAndType, state, groupCalls, showCallsTab, currentGroupCallPeerId) -> Signal in let (update, type) = updateAndType - let processedView = CallListNodeView(originalView: update.view, filteredEntries: callListNodeEntriesForView(view: update.view, displayOpenNewCall: mode == .tab, groupCalls: groupCalls, state: state, showSettings: showSettings, showCallsTab: showCallsTab, isRecentCalls: type == .all, currentGroupCallPeerId: currentGroupCallPeerId), presentationData: state.presentationData) + let processedView = CallListNodeView(originalView: update.view, filteredEntries: callListNodeEntriesForView(view: update.view, displayOpenNewCall: mode == .tab && type == .all, groupCalls: groupCalls, state: state, showSettings: showSettings, showCallsTab: showCallsTab, isRecentCalls: type == .all, currentGroupCallPeerId: currentGroupCallPeerId), presentationData: state.presentationData) let previous = previousView.swap(processedView) let previousType = previousType.swap(type) diff --git a/submodules/TelegramCallsUI/Sources/CallController.swift b/submodules/TelegramCallsUI/Sources/CallController.swift index 37fa2064c5..c7dd71d3fc 100644 --- a/submodules/TelegramCallsUI/Sources/CallController.swift +++ b/submodules/TelegramCallsUI/Sources/CallController.swift @@ -517,6 +517,7 @@ public final class CallController: ViewController { }, options: .single(options), displayCallIcons: true, + multipleSelection: .disabled, confirmation: { peer in switch peer { case let .peer(peer, _, _): diff --git a/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift b/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift index cc82d746a5..906d5277ad 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift @@ -2706,6 +2706,15 @@ final class VideoChatScreenComponent: Component { } else if let expandedParticipantsVideoState = self.expandedParticipantsVideoState, !expandedParticipantsVideoState.isUIHidden { displayVideoControlButton = false } + if case .audio = videoControlButtonContent { + if let (availableOutputs, _) = self.audioOutputState { + if availableOutputs.count <= 0 { + displayVideoControlButton = false + } + } else { + displayVideoControlButton = false + } + } let videoControlButtonSize = self.videoControlButton.update( transition: transition, diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index 3f256ea534..2979941dea 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -1722,7 +1722,7 @@ final class StoryItemSetContainerSendMessage { case .contact: let theme = component.theme let updatedPresentationData: (initial: PresentationData, signal: Signal) = (component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: theme), component.context.sharedContext.presentationData |> map { $0.withUpdated(theme: theme) }) - let contactsController = component.context.sharedContext.makeContactSelectionController(ContactSelectionControllerParams(context: component.context, updatedPresentationData: updatedPresentationData, title: { $0.Contacts_Title }, displayDeviceContacts: true, multipleSelection: true)) + let contactsController = component.context.sharedContext.makeContactSelectionController(ContactSelectionControllerParams(context: component.context, updatedPresentationData: updatedPresentationData, title: { $0.Contacts_Title }, displayDeviceContacts: true, multipleSelection: .always)) contactsController.presentScheduleTimePicker = { [weak self, weak view] completion in guard let self, let view else { return diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index c89712de75..41f9fae58f 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2898,7 +2898,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } - if let currentGroupCallController = self.context.sharedContext as? VoiceChatController, case let .group(groupCall) = currentGroupCallController.call, let currentCallId = groupCall.callId, currentCallId == conferenceCall.callId { + if let currentGroupCallController = self.context.sharedContext.currentGroupCallController as? VoiceChatController, case let .group(groupCall) = currentGroupCallController.call, let currentCallId = groupCall.callId, currentCallId == conferenceCall.callId { self.context.sharedContext.navigateToCurrentCall() return } diff --git a/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift b/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift index 7f6a694b9b..94670977dc 100644 --- a/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift +++ b/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift @@ -424,7 +424,7 @@ extension ChatControllerImpl { let _ = currentLocationController.swap(controller) }) case .contact: - let contactsController = ContactSelectionControllerImpl(ContactSelectionControllerParams(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: { $0.Contacts_Title }, displayDeviceContacts: true, multipleSelection: true, requirePhoneNumbers: true)) + let contactsController = ContactSelectionControllerImpl(ContactSelectionControllerParams(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: { $0.Contacts_Title }, displayDeviceContacts: true, multipleSelection: .always, requirePhoneNumbers: true)) contactsController.presentScheduleTimePicker = { [weak self] completion in if let strongSelf = self { strongSelf.presentScheduleTimePicker(completion: completion) @@ -1620,7 +1620,7 @@ extension ChatControllerImpl { } func presentContactPicker() { - let contactsController = ContactSelectionControllerImpl(ContactSelectionControllerParams(context: self.context, updatedPresentationData: self.updatedPresentationData, title: { $0.Contacts_Title }, displayDeviceContacts: true, multipleSelection: true)) + let contactsController = ContactSelectionControllerImpl(ContactSelectionControllerParams(context: self.context, updatedPresentationData: self.updatedPresentationData, title: { $0.Contacts_Title }, displayDeviceContacts: true, multipleSelection: .always)) contactsController.navigationPresentation = .modal self.chatDisplayNode.dismissInput() self.effectiveNavigationController?.pushViewController(contactsController) diff --git a/submodules/TelegramUI/Sources/ContactSelectionController.swift b/submodules/TelegramUI/Sources/ContactSelectionController.swift index e8b191c343..a0946cb004 100644 --- a/submodules/TelegramUI/Sources/ContactSelectionController.swift +++ b/submodules/TelegramUI/Sources/ContactSelectionController.swift @@ -40,7 +40,7 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController private let options: Signal<[ContactListAdditionalOption], NoError> private let displayDeviceContacts: Bool private let displayCallIcons: Bool - private let multipleSelection: Bool + private let multipleSelection: ContactSelectionControllerParams.MultipleSelectionMode private let requirePhoneNumbers: Bool private let allowChannelsInSearch: Bool @@ -153,15 +153,17 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController } }) - if !params.multipleSelection { + if self.multipleSelection != .always { self.searchContentNode = NavigationBarSearchContentNode(theme: self.presentationData.theme, placeholder: self.presentationData.strings.Common_Search, activate: { [weak self] in self?.activateSearch() }) self.navigationBar?.setContentNode(self.searchContentNode, animated: false) } - if params.multipleSelection { + if self.multipleSelection == .always { self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.beginSearch)) + } else if self.multipleSelection == .possible { + self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Select, style: .plain, target: self, action: #selector(self.beginSelection)) } self.getCurrentSendMessageContextMediaPreview = { [weak self] in @@ -220,7 +222,7 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController } override func loadDisplayNode() { - self.displayNode = ContactSelectionControllerNode(context: self.context, mode: self.mode, presentationData: self.presentationData, options: self.options, displayDeviceContacts: self.displayDeviceContacts, displayCallIcons: self.displayCallIcons, multipleSelection: self.multipleSelection, requirePhoneNumbers: self.requirePhoneNumbers, allowChannelsInSearch: self.allowChannelsInSearch, isPeerEnabled: self.isPeerEnabled) + self.displayNode = ContactSelectionControllerNode(context: self.context, mode: self.mode, presentationData: self.presentationData, options: self.options, displayDeviceContacts: self.displayDeviceContacts, displayCallIcons: self.displayCallIcons, multipleSelection: self.multipleSelection == .always, requirePhoneNumbers: self.requirePhoneNumbers, allowChannelsInSearch: self.allowChannelsInSearch, isPeerEnabled: self.isPeerEnabled) self._ready.set(self.contactsNode.contactListNode.ready) self.contactsNode.navigationBar = self.navigationBar @@ -335,7 +337,7 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController if let searchContentNode = self.searchContentNode as? NavigationBarSearchContentNode { self.contactsNode.activateSearch(placeholderNode: searchContentNode.placeholderNode) self.setDisplayNavigationBar(false, transition: .animated(duration: 0.5, curve: .spring)) - } else if self.multipleSelection { + } else if self.multipleSelection == .always { let contentNode = ContactsSearchNavigationContentNode(presentationData: self.presentationData, dismissSearch: { [weak self] in if let strongSelf = self, let navigationBar = strongSelf.navigationBar, let searchContentNode = strongSelf.searchContentNode as? ContactsSearchNavigationContentNode { searchContentNode.deactivate() diff --git a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift index b313960db0..10a241d5ee 100644 --- a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift @@ -394,6 +394,11 @@ func openResolvedUrlImpl( let _ = (signal |> deliverOnMainQueue).startStandalone(next: { [weak navigationController] resolvedCallLink in + if let currentGroupCallController = context.sharedContext.currentGroupCallController as? VoiceChatController, case let .group(groupCall) = currentGroupCallController.call, let currentCallId = groupCall.callId, currentCallId == resolvedCallLink.id { + context.sharedContext.navigateToCurrentCall() + return + } + navigationController?.pushViewController(context.sharedContext.makeJoinSubjectScreen(context: context, mode: JoinSubjectScreenMode.groupCall(JoinSubjectScreenMode.GroupCall( id: resolvedCallLink.id, accessHash: resolvedCallLink.accessHash,