From 53b762dab07fa9d2c752582686bd84d5b5f2d04f Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 15 Dec 2020 20:22:47 +0400 Subject: [PATCH] UI fixes --- .../Sources/Node/ChatListItem.swift | 2 +- .../ChannelMembersSearchControllerNode.swift | 10 +++++++ .../Sources/PresentationGroupCall.swift | 28 ++++++++++++++----- .../Sources/VoiceChatController.swift | 19 +++++++++---- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index d989df2a68..dda4cb7325 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -1319,7 +1319,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { } badgeSize = max(badgeSize, reorderInset) - let (authorLayout, authorApply) = authorLayout(TextNodeLayoutArguments(attributedString: hideAuthor ? nil : authorAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: rawContentWidth - badgeSize, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets(top: 2.0, left: 1.0, bottom: 2.0, right: 1.0))) + let (authorLayout, authorApply) = authorLayout(TextNodeLayoutArguments(attributedString: (hideAuthor && !hasDraft) ? nil : authorAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: rawContentWidth - badgeSize, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets(top: 2.0, left: 1.0, bottom: 2.0, right: 1.0))) var textCutout: TextNodeCutout? if !textLeftCutout.isZero { diff --git a/submodules/PeerInfoUI/Sources/ChannelMembersSearchControllerNode.swift b/submodules/PeerInfoUI/Sources/ChannelMembersSearchControllerNode.swift index 70dd623548..6722f996b2 100644 --- a/submodules/PeerInfoUI/Sources/ChannelMembersSearchControllerNode.swift +++ b/submodules/PeerInfoUI/Sources/ChannelMembersSearchControllerNode.swift @@ -263,6 +263,16 @@ class ChannelMembersSearchControllerNode: ASDisplayNode { } var entries: [ChannelMembersSearchEntry] = [] + if case .inviteToCall = mode, !filters.contains(where: { filter in + if case .excludeNonMembers = filter { + return true + } else { + return false + } + }) { + entries.append(.copyInviteLink) + } + var index = 0 for participant in participants.participants { guard let peer = peerView.peers[participant.peerId] else { diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index 3430b1924e..1d805f9554 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -1114,13 +1114,27 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { self._canBeRemoved.set(.single(true)) if self.didConnectOnce { - let toneRenderer = PresentationCallToneRenderer(tone: .groupLeft) - self.toneRenderer = toneRenderer - toneRenderer.setAudioSessionActive(self.isAudioSessionActive) - - Queue.mainQueue().after(1.0, { - self.wasRemoved.set(.single(true)) - }) + if let callManager = self.accountContext.sharedContext.callManager { + let _ = (callManager.currentGroupCallSignal + |> take(1) + |> deliverOnMainQueue).start(next: { [weak self] call in + guard let strongSelf = self else { + return + } + if let call = call, call !== strongSelf { + strongSelf.wasRemoved.set(.single(true)) + return + } + + let toneRenderer = PresentationCallToneRenderer(tone: .groupLeft) + strongSelf.toneRenderer = toneRenderer + toneRenderer.setAudioSessionActive(strongSelf.isAudioSessionActive) + + Queue.mainQueue().after(1.0, { + strongSelf.wasRemoved.set(.single(true)) + }) + }) + } } } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index a66eed1ac5..878cac44fd 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -575,7 +575,7 @@ public final class VoiceChatController: ViewController { filters.append(.excludeNonMembers) } } else if let groupPeer = groupPeer as? TelegramGroup { - if !groupPeer.hasBannedPermission(.banAddMembers) { + if groupPeer.hasBannedPermission(.banAddMembers) { filters.append(.excludeNonMembers) } } @@ -984,11 +984,20 @@ public final class VoiceChatController: ViewController { strongSelf.accountPeer = accountPeer strongSelf.updateMembers(muteState: strongSelf.effectiveMuteState, callMembers: strongSelf.currentCallMembers ?? [], invitedPeers: strongSelf.currentInvitedPeers ?? [], speakingPeers: strongSelf.currentSpeakingPeers ?? Set()) - if let peer = peerViewMainPeer(view), let channel = peer as? TelegramChannel { - let addressName = channel.addressName ?? "" - if channel.flags.contains(.isCreator) || channel.hasPermission(.inviteMembers) { - if addressName.isEmpty { + if let peer = peerViewMainPeer(view) { + if let channel = peer as? TelegramChannel { + let addressName = channel.addressName ?? "" + if channel.flags.contains(.isCreator) || channel.hasPermission(.inviteMembers) { + if addressName.isEmpty { + let _ = ensuredExistingPeerExportedInvitation(account: strongSelf.context.account, peerId: call.peerId).start() + } + } + } else if let group = peer as? TelegramGroup { + switch group.role { + case .creator, .admin: let _ = ensuredExistingPeerExportedInvitation(account: strongSelf.context.account, peerId: call.peerId).start() + default: + break } } }