Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-11-29 01:52:12 +04:00
parent e74ff75e9f
commit e98d60353d
7 changed files with 124 additions and 113 deletions

View File

@ -211,6 +211,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.wrappingScrollNode = ASScrollNode() self.wrappingScrollNode = ASScrollNode()
self.wrappingScrollNode.view.alwaysBounceVertical = true self.wrappingScrollNode.view.alwaysBounceVertical = true
self.wrappingScrollNode.view.delaysContentTouches = false self.wrappingScrollNode.view.delaysContentTouches = false
self.wrappingScrollNode.view.showsVerticalScrollIndicator = false
self.wrappingScrollNode.view.canCancelContentTouches = true self.wrappingScrollNode.view.canCancelContentTouches = true
self.dimNode = ASDisplayNode() self.dimNode = ASDisplayNode()
@ -269,6 +270,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.terminateButton = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(backgroundColor: self.presentationData.theme.list.itemBlocksBackgroundColor, foregroundColor: self.presentationData.theme.list.itemDestructiveColor), font: .regular, height: 44.0, cornerRadius: 11.0, gloss: false) self.terminateButton = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(backgroundColor: self.presentationData.theme.list.itemBlocksBackgroundColor, foregroundColor: self.presentationData.theme.list.itemDestructiveColor), font: .regular, height: 44.0, cornerRadius: 11.0, gloss: false)
var hasSecretChats = false var hasSecretChats = false
var hasIncomingCalls = false
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
let title: String let title: String
@ -341,8 +343,11 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.secretChatsSwitchNode.isOn = session.flags.contains(.acceptsSecretChats) self.secretChatsSwitchNode.isOn = session.flags.contains(.acceptsSecretChats)
self.incomingCallsSwitchNode.isOn = session.flags.contains(.acceptsIncomingCalls) self.incomingCallsSwitchNode.isOn = session.flags.contains(.acceptsIncomingCalls)
if !session.flags.contains(.passwordPending) && ![2040, 2496].contains(session.apiId) { if !session.flags.contains(.passwordPending) {
hasSecretChats = true hasIncomingCalls = true
if ![2040, 2496].contains(session.apiId) {
hasSecretChats = true
}
} }
case let .website(website, peer): case let .website(website, peer):
self.terminateButton.title = self.presentationData.strings.AuthSessions_View_Logout self.terminateButton.title = self.presentationData.strings.AuthSessions_View_Logout
@ -399,7 +404,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.locationTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_Location, font: Font.regular(17.0), textColor: textColor) self.locationTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_Location, font: Font.regular(17.0), textColor: textColor)
self.locationValueNode.attributedText = NSAttributedString(string: location, font: Font.regular(17.0), textColor: secondaryTextColor) self.locationValueNode.attributedText = NSAttributedString(string: location, font: Font.regular(17.0), textColor: secondaryTextColor)
self.locationInfoNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_LocationInfo, font: Font.regular(13.0), textColor: secondaryTextColor) self.locationInfoNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_LocationInfo, font: Font.regular(13.0), textColor: secondaryTextColor)
self.locationInfoNode.maximumNumberOfLines = 3 self.locationInfoNode.maximumNumberOfLines = 4
self.acceptBackgroundNode = ASDisplayNode() self.acceptBackgroundNode = ASDisplayNode()
self.acceptBackgroundNode.clipsToBounds = true self.acceptBackgroundNode.clipsToBounds = true
@ -454,26 +459,28 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.animationNode.flatMap { self.contentContainerNode.addSubnode($0) } self.animationNode.flatMap { self.contentContainerNode.addSubnode($0) }
self.avatarNode.flatMap { self.contentContainerNode.addSubnode($0) } self.avatarNode.flatMap { self.contentContainerNode.addSubnode($0) }
self.contentContainerNode.addSubnode(self.acceptBackgroundNode) if hasIncomingCalls {
self.contentContainerNode.addSubnode(self.acceptHeaderNode) self.contentContainerNode.addSubnode(self.acceptBackgroundNode)
if hasSecretChats { self.contentContainerNode.addSubnode(self.acceptHeaderNode)
self.contentContainerNode.addSubnode(self.secretChatsTitleNode) if hasSecretChats {
self.contentContainerNode.addSubnode(self.secretChatsSwitchNode) self.contentContainerNode.addSubnode(self.secretChatsTitleNode)
self.contentContainerNode.addSubnode(self.secretChatsSwitchNode)
self.secretChatsSwitchNode.valueUpdated = { [weak self] value in self.secretChatsSwitchNode.valueUpdated = { [weak self] value in
if let strongSelf = self { if let strongSelf = self {
strongSelf.updateAcceptSecretChats?(value) strongSelf.updateAcceptSecretChats?(value)
}
} }
self.contentContainerNode.addSubnode(self.acceptSeparatorNode)
} }
self.contentContainerNode.addSubnode(self.incomingCallsTitleNode)
self.contentContainerNode.addSubnode(self.incomingCallsSwitchNode)
self.contentContainerNode.addSubnode(self.acceptSeparatorNode) self.incomingCallsSwitchNode.valueUpdated = { [weak self] value in
} if let strongSelf = self {
self.contentContainerNode.addSubnode(self.incomingCallsTitleNode) strongSelf.updateAcceptIncomingCalls?(value)
self.contentContainerNode.addSubnode(self.incomingCallsSwitchNode) }
self.incomingCallsSwitchNode.valueUpdated = { [weak self] value in
if let strongSelf = self {
strongSelf.updateAcceptIncomingCalls?(value)
} }
} }
@ -779,7 +786,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
} }
transition.updateFrame(node: self.acceptBackgroundNode, frame: secretFrame) transition.updateFrame(node: self.acceptBackgroundNode, frame: secretFrame)
let secretChatsHeaderTextSize = self.acceptHeaderNode.updateLayout(CGSize(width: secretFrame.width - inset * 2.0 - locationTitleTextSize.width - 10.0, height: fieldItemHeight)) let secretChatsHeaderTextSize = self.acceptHeaderNode.updateLayout(CGSize(width: secretFrame.width - inset * 2.0, height: fieldItemHeight))
let secretChatsHeaderTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.minY - secretChatsHeaderTextSize.height - 6.0), size: secretChatsHeaderTextSize) let secretChatsHeaderTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.minY - secretChatsHeaderTextSize.height - 6.0), size: secretChatsHeaderTextSize)
transition.updateFrame(node: self.acceptHeaderNode, frame: secretChatsHeaderTextFrame) transition.updateFrame(node: self.acceptHeaderNode, frame: secretChatsHeaderTextFrame)
@ -813,7 +820,9 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.incomingCallsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.maxY - fieldItemHeight + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize) self.incomingCallsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.maxY - fieldItemHeight + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize)
} }
contentHeight += secretFrame.maxY - locationInfoTextFrame.maxY if let _ = self.acceptBackgroundNode.supernode {
contentHeight += secretFrame.maxY - locationInfoTextFrame.maxY
}
contentHeight += 40.0 contentHeight += 40.0
let isCurrent: Bool let isCurrent: Bool
@ -823,7 +832,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
isCurrent = false isCurrent = false
} }
if isCurrent || (layout.size.width > layout.size.height && layout.metrics.widthClass == .compact) { if isCurrent {
contentHeight -= 68.0 contentHeight -= 68.0
self.terminateButton.isHidden = true self.terminateButton.isHidden = true
} else { } else {
@ -831,9 +840,12 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
} }
let sideInset = floor((layout.size.width - width) / 2.0) let sideInset = floor((layout.size.width - width) / 2.0)
let contentContainerFrame = CGRect(origin: CGPoint(x: sideInset, y: layout.size.height - contentHeight), size: CGSize(width: width, height: contentHeight)) let scrollContentHeight = max(layout.size.height, contentHeight)
let contentContainerFrame = CGRect(origin: CGPoint(x: sideInset, y: max(layout.statusBarHeight ?? 20.0, layout.size.height - contentHeight)), size: CGSize(width: width, height: contentHeight))
let contentFrame = contentContainerFrame let contentFrame = contentContainerFrame
self.wrappingScrollNode.view.contentSize = CGSize(width: layout.size.width, height: scrollContentHeight)
var backgroundFrame = CGRect(origin: CGPoint(x: contentFrame.minX, y: contentFrame.minY), size: CGSize(width: width, height: contentFrame.height + 2000.0)) var backgroundFrame = CGRect(origin: CGPoint(x: contentFrame.minX, y: contentFrame.minY), size: CGSize(width: width, height: contentFrame.height + 2000.0))
if backgroundFrame.minY < contentFrame.minY { if backgroundFrame.minY < contentFrame.minY {
backgroundFrame.origin.y = contentFrame.minY backgroundFrame.origin.y = contentFrame.minY

View File

@ -370,7 +370,9 @@ public final class PendingMessageManager {
continue continue
} }
messageContext.activityType = uploadActivityTypeForMessage(message) if message.author?.id == strongSelf.accountPeerId {
messageContext.activityType = uploadActivityTypeForMessage(message)
}
messageContext.threadId = message.threadId messageContext.threadId = message.threadId
strongSelf.collectUploadingInfo(messageContext: messageContext, message: message) strongSelf.collectUploadingInfo(messageContext: messageContext, message: message)
} }

View File

@ -10905,7 +10905,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
} }
if let sendAsPeerId = self.presentationInterfaceState.currentSendAsPeerId { if let sendAsPeerId = self.presentationInterfaceState.currentSendAsPeerId {
attributes.append(SendAsMessageAttribute(peerId: sendAsPeerId)) if attributes.first(where: { $0 is SendAsMessageAttribute }) == nil {
attributes.append(SendAsMessageAttribute(peerId: sendAsPeerId))
}
} }
return attributes return attributes
} }

View File

@ -949,6 +949,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
var effectiveAuthor: Peer? var effectiveAuthor: Peer?
var ignoreForward = false var ignoreForward = false
var displayAuthorInfo: Bool var displayAuthorInfo: Bool
var ignoreNameHiding = false
let avatarInset: CGFloat let avatarInset: CGFloat
var hasAvatar = false var hasAvatar = false
@ -995,6 +996,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
if let author = firstMessage.author, author is TelegramChannel, !incoming { if let author = firstMessage.author, author is TelegramChannel, !incoming {
allowAuthor = true allowAuthor = true
ignoreNameHiding = true
} }
displayAuthorInfo = !mergedTop.merged && allowAuthor && peerId.isGroupOrChannel && effectiveAuthor != nil displayAuthorInfo = !mergedTop.merged && allowAuthor && peerId.isGroupOrChannel && effectiveAuthor != nil
@ -1370,7 +1372,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
initialDisplayHeader = false initialDisplayHeader = false
} else { } else {
if inlineBotNameString == nil && (ignoreForward || firstMessage.forwardInfo == nil) && replyMessage == nil { if inlineBotNameString == nil && (ignoreForward || firstMessage.forwardInfo == nil) && replyMessage == nil {
if let first = contentPropertiesAndLayouts.first, first.1.hidesSimpleAuthorHeader { if let first = contentPropertiesAndLayouts.first, first.1.hidesSimpleAuthorHeader && !ignoreNameHiding {
if let author = firstMessage.author as? TelegramChannel, case .group = author.info, author.id == firstMessage.id.peerId, !incoming { if let author = firstMessage.author as? TelegramChannel, case .group = author.info, author.id == firstMessage.id.peerId, !incoming {
} else { } else {
initialDisplayHeader = false initialDisplayHeader = false

View File

@ -1042,43 +1042,33 @@ func peerInfoHeaderButtons(peer: Peer?, cachedData: CachedPeerData?, isOpenedFro
result.append(.more) result.append(.more)
} }
} else if let channel = peer as? TelegramChannel { } else if let channel = peer as? TelegramChannel {
var displayLeave = !channel.flags.contains(.isCreator) let hasVoiceChat = channel.flags.contains(.hasVoiceChat)
var canViewStats = false let canStartVoiceChat = !hasVoiceChat && (channel.flags.contains(.isCreator) || channel.hasPermission(.manageCalls))
var hasDiscussion = false let canManage = channel.flags.contains(.isCreator) || channel.adminRights != nil
var hasVoiceChat = false
var displayMore = true let hasDiscussion: Bool
var canStartVoiceChat = false
if let cachedChannelData = cachedData as? CachedChannelData {
canViewStats = cachedChannelData.flags.contains(.canViewStats)
}
if channel.flags.contains(.hasVoiceChat) {
hasVoiceChat = true
}
if channel.flags.contains(.isCreator) {
displayMore = true
}
switch channel.info { switch channel.info {
case let .broadcast(info): case let .broadcast(info):
if !channel.flags.contains(.isCreator) { hasDiscussion = info.flags.contains(.hasDiscussionGroup)
displayLeave = true case .group:
} hasDiscussion = false
if info.flags.contains(.hasDiscussionGroup) {
hasDiscussion = true
}
case .group:
if channel.flags.contains(.hasVoiceChat) {
hasVoiceChat = true
}
}
if !hasVoiceChat && (channel.flags.contains(.isCreator) || channel.hasPermission(.manageCalls)) {
canStartVoiceChat = true
} }
let canLeave: Bool
switch channel.participationStatus { switch channel.participationStatus {
case .member: case .member:
break canLeave = true
default: default:
displayLeave = false canLeave = false
} }
let canViewStats: Bool
if let cachedChannelData = cachedData as? CachedChannelData {
canViewStats = cachedChannelData.flags.contains(.canViewStats)
} else {
canViewStats = false
}
if hasVoiceChat || canStartVoiceChat { if hasVoiceChat || canStartVoiceChat {
result.append(.voiceChat) result.append(.voiceChat)
} }
@ -1086,42 +1076,57 @@ func peerInfoHeaderButtons(peer: Peer?, cachedData: CachedPeerData?, isOpenedFro
if hasDiscussion { if hasDiscussion {
result.append(.discussion) result.append(.discussion)
} }
if isExpanded && hasDiscussion { result.append(.search)
} else { if canLeave {
result.append(.search)
}
if displayLeave && result.count < 4 {
result.append(.leave) result.append(.leave)
} }
var canReport = true var canReport = true
if channel.isVerified || channel.adminRights != nil || channel.flags.contains(.isCreator) { if channel.isVerified || channel.adminRights != nil || channel.flags.contains(.isCreator) {
canReport = false canReport = false
} }
if !canReport && !canViewStats {
displayMore = false var hasMore = false
} if canReport || canViewStats {
if displayMore { hasMore = true
result.append(.more) result.append(.more)
} }
} else if let group = peer as? TelegramGroup {
var hasVoiceChat = false
var canStartVoiceChat = false
if group.flags.contains(.hasVoiceChat) { if hasDiscussion && isExpanded && result.count >= 5 {
hasVoiceChat = true result.removeAll(where: { $0 == .search })
if !hasMore {
hasMore = true
result.append(.more)
}
} }
if canLeave && isExpanded && (canManage || result.count >= 5) {
result.removeAll(where: { $0 == .leave })
if !hasMore {
hasMore = true
result.append(.more)
}
}
} else if let group = peer as? TelegramGroup {
let hasVoiceChat = group.flags.contains(.hasVoiceChat)
let canStartVoiceChat: Bool
if !hasVoiceChat { if !hasVoiceChat {
if case .creator = group.role { if case .creator = group.role {
canStartVoiceChat = true canStartVoiceChat = true
} else if case let .admin(rights, _) = group.role, rights.rights.contains(.canManageCalls) { } else if case let .admin(rights, _) = group.role, rights.rights.contains(.canManageCalls) {
canStartVoiceChat = true canStartVoiceChat = true
} else {
canStartVoiceChat = false
} }
} else {
canStartVoiceChat = false
} }
result.append(.mute)
if hasVoiceChat || canStartVoiceChat { if hasVoiceChat || canStartVoiceChat {
result.append(.voiceChat) result.append(.voiceChat)
} }
result.append(.mute)
result.append(.search) result.append(.search)
result.append(.more) result.append(.more)
} }

View File

@ -1119,8 +1119,11 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
let ItemDiscussionGroup = 3 let ItemDiscussionGroup = 3
let ItemSignMessages = 4 let ItemSignMessages = 4
let ItemSignMessagesHelp = 5 let ItemSignMessagesHelp = 5
let ItemDeleteChannel = 5
if channel.flags.contains(.isCreator) { let isCreator = channel.flags.contains(.isCreator)
if isCreator {
let linkText: String let linkText: String
if let _ = channel.username { if let _ = channel.username {
linkText = presentationData.strings.Channel_Setup_TypePublic linkText = presentationData.strings.Channel_Setup_TypePublic
@ -1132,7 +1135,7 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
})) }))
} }
if (channel.flags.contains(.isCreator) && (channel.username?.isEmpty ?? true)) || (!channel.flags.contains(.isCreator) && channel.adminRights?.rights.contains(.canInviteUsers) == true) { if (isCreator && (channel.username?.isEmpty ?? true)) || (!channel.flags.contains(.isCreator) && channel.adminRights?.rights.contains(.canInviteUsers) == true) {
let invitesText: String let invitesText: String
if let count = data.invitations?.count, count > 0 { if let count = data.invitations?.count, count > 0 {
invitesText = "\(count)" invitesText = "\(count)"
@ -1144,7 +1147,7 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
})) }))
} }
if channel.flags.contains(.isCreator) || (channel.adminRights?.rights.contains(.canChangeInfo) == true) { if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
let discussionGroupTitle: String let discussionGroupTitle: String
if let _ = data.cachedData as? CachedChannelData { if let _ = data.cachedData as? CachedChannelData {
if let peer = data.linkedDiscussionPeer { if let peer = data.linkedDiscussionPeer {
@ -1165,7 +1168,7 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
})) }))
} }
if channel.flags.contains(.isCreator) || (channel.adminRights != nil && channel.hasPermission(.sendMessages)) { if isCreator || (channel.adminRights != nil && channel.hasPermission(.sendMessages)) {
let messagesShouldHaveSignatures: Bool let messagesShouldHaveSignatures: Bool
switch channel.info { switch channel.info {
case let .broadcast(info): case let .broadcast(info):
@ -1178,6 +1181,12 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
})) }))
items[.peerSettings]!.append(PeerInfoScreenCommentItem(id: ItemSignMessagesHelp, text: presentationData.strings.Channel_SignMessages_Help)) items[.peerSettings]!.append(PeerInfoScreenCommentItem(id: ItemSignMessagesHelp, text: presentationData.strings.Channel_SignMessages_Help))
} }
if isCreator {
items[.peerActions]!.append(PeerInfoScreenActionItem(id: ItemDeleteChannel, text: presentationData.strings.ChannelInfo_DeleteChannel, color: .destructive, icon: nil, alignment: .natural, action: {
interaction.openDeletePeer()
}))
}
case .group: case .group:
let ItemUsername = 101 let ItemUsername = 101
let ItemInviteLinks = 102 let ItemInviteLinks = 102
@ -3702,56 +3711,30 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
switch channel.info { switch channel.info {
case .broadcast: case .broadcast:
if channel.flags.contains(.isCreator) { if case .member = channel.participationStatus, !headerButtons.contains(.leave) {
if !items.isEmpty { if !items.isEmpty {
items.append(.separator) items.append(.separator)
} }
items.append(.action(ContextMenuActionItem(text: presentationData.strings.ChannelInfo_DeleteChannel, textColor: .destructive, icon: { theme in items.append(.action(ContextMenuActionItem(text: presentationData.strings.Channel_LeaveChannel, textColor: .destructive, icon: { theme in
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor) generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Logout"), color: theme.contextMenu.destructiveColor)
}, action: { [weak self] _, f in }, action: { [weak self] _, f in
f(.dismissWithoutContent) f(.dismissWithoutContent)
self?.openDeletePeer() self?.openLeavePeer()
}))) })))
} else {
if case .member = channel.participationStatus, !headerButtons.contains(.leave) {
if !items.isEmpty {
items.append(.separator)
}
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Channel_LeaveChannel, textColor: .destructive, icon: { theme in
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Logout"), color: theme.contextMenu.destructiveColor)
}, action: { [weak self] _, f in
f(.dismissWithoutContent)
self?.openLeavePeer()
})))
}
} }
case .group: case .group:
if channel.flags.contains(.isCreator) { if case .member = channel.participationStatus, !headerButtons.contains(.leave) {
if !items.isEmpty { if !items.isEmpty {
items.append(.separator) items.append(.separator)
} }
items.append(.action(ContextMenuActionItem(text: presentationData.strings.ChannelInfo_DeleteGroup, textColor: .destructive, icon: { theme in items.append(.action(ContextMenuActionItem(text: presentationData.strings.Group_LeaveGroup, textColor: .destructive, icon: { theme in
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor) generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Logout"), color: theme.contextMenu.destructiveColor)
}, action: { [weak self] _, f in }, action: { [weak self] _, f in
f(.dismissWithoutContent) f(.dismissWithoutContent)
self?.openDeletePeer() self?.openLeavePeer()
}))) })))
} else {
if case .member = channel.participationStatus, !headerButtons.contains(.leave) {
if !items.isEmpty {
items.append(.separator)
}
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Group_LeaveGroup, textColor: .destructive, icon: { theme in
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Logout"), color: theme.contextMenu.destructiveColor)
}, action: { [weak self] _, f in
f(.dismissWithoutContent)
self?.openLeavePeer()
})))
}
} }
} }
} else if let group = peer as? TelegramGroup { } else if let group = peer as? TelegramGroup {

View File

@ -196,7 +196,7 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
self.loadTextInputNode() self.loadTextInputNode()
} }
if let textInputNode = self.textInputNode, let _ = self.presentationInterfaceState { if let textInputNode = self.textInputNode, let _ = self.presentationInterfaceState, !self.skipUpdate {
self.updatingInputState = true self.updatingInputState = true
var textColor: UIColor = .black var textColor: UIColor = .black
@ -693,6 +693,7 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
return false return false
} }
private var skipUpdate = false
@objc func editableTextNodeDidUpdateText(_ editableTextNode: ASEditableTextNode) { @objc func editableTextNodeDidUpdateText(_ editableTextNode: ASEditableTextNode) {
if let textInputNode = self.textInputNode, let presentationInterfaceState = self.presentationInterfaceState { if let textInputNode = self.textInputNode, let presentationInterfaceState = self.presentationInterfaceState {
let baseFontSize = max(minInputFontSize, presentationInterfaceState.fontSize.baseDisplaySize) let baseFontSize = max(minInputFontSize, presentationInterfaceState.fontSize.baseDisplaySize)
@ -701,6 +702,8 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
let inputTextState = self.inputTextState let inputTextState = self.inputTextState
self.skipUpdate = true
self.interfaceInteraction?.updateTextInputStateAndMode({ _, inputMode in return (inputTextState, inputMode) }) self.interfaceInteraction?.updateTextInputStateAndMode({ _, inputMode in return (inputTextState, inputMode) })
self.interfaceInteraction?.updateInputLanguage({ _ in return textInputNode.textInputMode.primaryLanguage }) self.interfaceInteraction?.updateInputLanguage({ _ in return textInputNode.textInputMode.primaryLanguage })
if self.isCaption, let presentationInterfaceState = self.presentationInterfaceState { if self.isCaption, let presentationInterfaceState = self.presentationInterfaceState {
@ -712,6 +715,8 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
self.updateTextNodeText(animated: true) self.updateTextNodeText(animated: true)
self.updateCounterTextNode(transition: .immediate) self.updateCounterTextNode(transition: .immediate)
self.skipUpdate = false
} }
} }