From a651bb589d22833939842a747f1fbfb42a7d7379 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 23 Mar 2025 18:24:16 +0400 Subject: [PATCH] Various fixes --- .../Sources/Node/ChatListNode.swift | 4 +-- .../Sources/Node/ChatListNoticeItem.swift | 2 +- .../Sources/ContactsPeerItem.swift | 14 +++++--- .../Sources/GiftOptionsScreen.swift | 2 +- .../TelegramUI/Sources/ChatController.swift | 9 ++++-- .../Sources/SharedAccountContext.swift | 2 +- .../WebAppMessageChatPreviewItem.swift | 4 +++ .../Sources/WebAppMessagePreviewScreen.swift | 32 +++++++++++++------ 8 files changed, 45 insertions(+), 24 deletions(-) diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index 8d4f30727a..062c6633f3 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -1441,7 +1441,6 @@ public final class ChatListNode: ListView { return } var didBeginSelecting = false - var count = 0 strongSelf.updateState { [weak self] state in var state = state if state.selectedPeerIds.contains(peer.id) { @@ -1457,10 +1456,8 @@ public final class ChatListNode: ListView { self?.reachedSelectionLimit?(Int32(state.selectedPeerIds.count)) } } - count = state.selectedPeerIds.count return state } - strongSelf.selectionCountChanged?(count) if didBeginSelecting { strongSelf.didBeginSelectingChats?() } @@ -3461,6 +3458,7 @@ public final class ChatListNode: ListView { if state != self.currentState { self.currentState = state self.statePromise.set(state) + self.selectionCountChanged?(state.selectedPeerIds.count) } } diff --git a/submodules/ChatListUI/Sources/Node/ChatListNoticeItem.swift b/submodules/ChatListUI/Sources/Node/ChatListNoticeItem.swift index 383079142f..a57e64a44e 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNoticeItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNoticeItem.swift @@ -165,7 +165,7 @@ final class ChatListNoticeItemNode: ItemListRevealOptionsItemNode { let sideInset: CGFloat = params.leftInset + 16.0 let rightInset: CGFloat = sideInset + 24.0 - var titleRightInset = rightInset + var titleRightInset = rightInset - 4.0 let verticalInset: CGFloat = 9.0 var spacing: CGFloat = 0.0 diff --git a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift index a1cd2004a2..83f08dc062 100644 --- a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift +++ b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift @@ -1094,6 +1094,15 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { additionalTitleInset += arrowButtonImage.size.width + 4.0 } + var actionButtonTitleLayoutAndApply: (TextNodeLayout, () -> TextNode)? + if let buttonAction = item.buttonAction { + actionButtonTitleLayoutAndApply = makeActionButtonTitleLayuout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: buttonAction.title, font: Font.semibold(15.0), textColor: item.presentationData.theme.list.itemCheckColors.foregroundColor, paragraphAlignment: .center), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.infinity), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + + if let (actionButtonTitleLayout, _) = actionButtonTitleLayoutAndApply { + additionalTitleInset += actionButtonTitleLayout.size.width + 32.0 + } + } + let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0.0, params.width - leftInset - rightInset - additionalTitleInset), height: CGFloat.infinity), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) var maxStatusWidth: CGFloat = params.width - leftInset - rightInset - badgeSize @@ -1123,11 +1132,6 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { statusHeightComponent = -1.0 + statusLayout.size.height } - var actionButtonTitleLayoutAndApply: (TextNodeLayout, () -> TextNode)? - if let buttonAction = item.buttonAction { - actionButtonTitleLayoutAndApply = makeActionButtonTitleLayuout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: buttonAction.title, font: Font.semibold(15.0), textColor: item.presentationData.theme.list.itemCheckColors.foregroundColor, paragraphAlignment: .center), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.infinity), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) - } - let nodeLayout = ListViewItemNodeLayout(contentSize: CGSize(width: params.width, height: verticalInset * 2.0 + titleLayout.size.height + statusHeightComponent), insets: UIEdgeInsets(top: firstWithHeader ? 29.0 : 0.0, left: 0.0, bottom: 0.0, right: 0.0)) let titleFrame: CGRect diff --git a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift index 8aacce7718..3941d0ea01 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift @@ -661,7 +661,7 @@ final class GiftOptionsScreenComponent: Component { } } ) - controller.present(alertController, in: .window(.root)) + controller.present(alertController, in: .current) dismissAlertImpl = { [weak alertController] in alertController?.dismissAnimated() diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index e38ac9e876..0f4b304a65 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -6376,6 +6376,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G isPremiumRequiredForMessaging = .single(false) } + let globalPrivacySettings = context.engine.data.get(TelegramEngine.EngineData.Item.Configuration.GlobalPrivacy()) + self.titleDisposable.set(nil) self.peerDisposable.set((combineLatest(queue: Queue.mainQueue(), peerView, @@ -6386,9 +6388,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G hasSearchTags, hasSavedChats, isPremiumRequiredForMessaging, - managingBot + managingBot, + globalPrivacySettings ) - |> deliverOnMainQueue).startStrict(next: { [weak self] peerView, messageAndTopic, savedMessagesPeer, onlineMemberCount, hasScheduledMessages, hasSearchTags, hasSavedChats, isPremiumRequiredForMessaging, managingBot in + |> deliverOnMainQueue).startStrict(next: { [weak self] peerView, messageAndTopic, savedMessagesPeer, onlineMemberCount, hasScheduledMessages, hasSearchTags, hasSavedChats, isPremiumRequiredForMessaging, managingBot, globalPrivacySettings in if let strongSelf = self { strongSelf.hasScheduledMessages = hasScheduledMessages @@ -6407,7 +6410,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G businessIntro = value } if cachedData.disallowedGifts != .All { - alwaysShowGiftButton = cachedData.flags.contains(.displayGiftButton) + alwaysShowGiftButton = globalPrivacySettings.displayGiftButton || cachedData.flags.contains(.displayGiftButton) } disallowedGifts = cachedData.disallowedGifts } else if let cachedData = peerView.cachedData as? CachedGroupData { diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index 7cb07ccc5e..c20e6b8ea8 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -3049,7 +3049,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { } } ) - controller.present(alertController, in: .window(.root)) + controller.present(alertController, in: .current) dismissAlertImpl = { [weak alertController] in alertController?.dismissAnimated() diff --git a/submodules/WebUI/Sources/WebAppMessageChatPreviewItem.swift b/submodules/WebUI/Sources/WebAppMessageChatPreviewItem.swift index 6cd73efef8..ae66455633 100644 --- a/submodules/WebUI/Sources/WebAppMessageChatPreviewItem.swift +++ b/submodules/WebUI/Sources/WebAppMessageChatPreviewItem.swift @@ -32,6 +32,7 @@ final class PeerNameColorChatPreviewItem: ListViewItem, ItemListItem, ListItemCo let text: String let entities: TextEntitiesMessageAttribute? let media: [Media] + let replyMarkup: ReplyMarkupMessageAttribute? let botAddress: String } @@ -202,6 +203,9 @@ final class PeerNameColorChatPreviewItemNode: ListViewItemNode { if let entities = messageItem.entities { attributes.append(entities) } + if let replyMarkup = messageItem.replyMarkup { + attributes.append(replyMarkup) + } attributes.append(InlineBotMessageAttribute(peerId: botPeerId, title: nil)) diff --git a/submodules/WebUI/Sources/WebAppMessagePreviewScreen.swift b/submodules/WebUI/Sources/WebAppMessagePreviewScreen.swift index 57c3f686f1..a65ddc15f8 100644 --- a/submodules/WebUI/Sources/WebAppMessagePreviewScreen.swift +++ b/submodules/WebUI/Sources/WebAppMessagePreviewScreen.swift @@ -129,11 +129,12 @@ private final class SheetContent: CombinedComponent { var text: String = "" var entities: TextEntitiesMessageAttribute? var media: [Media] = [] + var replyMarkup: ReplyMarkupMessageAttribute? switch component.preparedMessage.result { case let .internalReference(reference): switch reference.message { - case let .auto(textValue, entitiesValue, _): + case let .auto(textValue, entitiesValue, replyMarkupValue): text = textValue entities = entitiesValue if let file = reference.file { @@ -141,39 +142,49 @@ private final class SheetContent: CombinedComponent { } else if let image = reference.image { media = [image] } - case let .text(textValue, entitiesValue, disableUrlPreview, previewParameters, _): + replyMarkup = replyMarkupValue + case let .text(textValue, entitiesValue, disableUrlPreview, previewParameters, replyMarkupValue): text = textValue entities = entitiesValue let _ = disableUrlPreview let _ = previewParameters - case let .contact(contact, _): + replyMarkup = replyMarkupValue + case let .contact(contact, replyMarkupValue): media = [contact] - case let .mapLocation(map, _): + replyMarkup = replyMarkupValue + case let .mapLocation(map, replyMarkupValue): media = [map] - case let .invoice(invoice, _): + replyMarkup = replyMarkupValue + case let .invoice(invoice, replyMarkupValue): media = [invoice] + replyMarkup = replyMarkupValue default: break } case let .externalReference(reference): switch reference.message { - case let .auto(textValue, entitiesValue, _): + case let .auto(textValue, entitiesValue, replyMarkupValue): text = textValue entities = entitiesValue if let content = reference.content { media = [content] } - case let .text(textValue, entitiesValue, disableUrlPreview, previewParameters, _): + replyMarkup = replyMarkupValue + case let .text(textValue, entitiesValue, disableUrlPreview, previewParameters, replyMarkupValue): text = textValue entities = entitiesValue let _ = disableUrlPreview let _ = previewParameters - case let .contact(contact, _): + replyMarkup = replyMarkupValue + case let .contact(contact, replyMarkupValue): media = [contact] - case let .mapLocation(map, _): + replyMarkup = replyMarkupValue + case let .mapLocation(map, replyMarkupValue): media = [map] - case let .invoice(invoice, _): + replyMarkup = replyMarkupValue + case let .invoice(invoice, replyMarkupValue): media = [invoice] + replyMarkup = replyMarkupValue default: break } @@ -183,6 +194,7 @@ private final class SheetContent: CombinedComponent { text: text, entities: entities, media: media, + replyMarkup: replyMarkup, botAddress: component.botAddress )