From dea2cc2a7d8f61b5130669807a9b527f53f74d5f Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 24 Nov 2022 02:36:11 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 1 + .../Sources/DeviceContactData.swift | 2 +- .../Sources/Node/ChatListItem.swift | 2 +- .../GlobalOverlayPresentationContext.swift | 2 +- .../TelegramUI/Sources/ChatMessageItem.swift | 2 +- .../ChatTextInputMediaRecordingButton.swift | 22 +++++++++++++------ .../Sources/ChatTextInputPanelNode.swift | 2 +- .../Sources/PeerInfo/PeerInfoScreen.swift | 10 +++++++-- 8 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 9d46cc713d..afcfc75bc9 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -8316,3 +8316,4 @@ Sorry for the inconvenience."; "ChatList.EmptyTopicsDescription" = "Older messages from this group have been moved to \"General\"."; "Stickers.EmojiPackInfoText" = "This message contains **%@** emoji."; +"PeerInfo.TopicIconInfoText" = "This topic's icon is from **%@**."; diff --git a/submodules/AccountContext/Sources/DeviceContactData.swift b/submodules/AccountContext/Sources/DeviceContactData.swift index 3a230a184f..ebc1509642 100644 --- a/submodules/AccountContext/Sources/DeviceContactData.swift +++ b/submodules/AccountContext/Sources/DeviceContactData.swift @@ -191,7 +191,7 @@ private let phonebookUsernamePrefix = "https://t.me/" + phonebookUsernamePathPre public extension DeviceContactUrlData { convenience init(appProfile: PeerId) { - self.init(label: "Telegram", value: "\(phonebookUsernamePrefix)\(appProfile.id)") + self.init(label: "Telegram", value: "\(phonebookUsernamePrefix)\(appProfile.id._internalGetInt64Value())") } } diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 6cc1639b43..670e9563e2 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -2298,7 +2298,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { isClosed = threadInfo.isClosed } if let threadInfo, threadInfo.id == 1 { - peerRevealOptions = forumGeneralRevealOptions(strings: item.presentationData.strings, theme: item.presentationData.theme, isMuted: (currentMutedIconImage != nil), isClosed: isClosed, isEditing: item.editing, canOpenClose: canOpenClose, canHide: channel.flags.contains(.isCreator) || channel.hasPermission(.pinMessages), hiddenByDefault: threadInfo.isHidden) + peerRevealOptions = forumGeneralRevealOptions(strings: item.presentationData.strings, theme: item.presentationData.theme, isMuted: (currentMutedIconImage != nil), isClosed: isClosed, isEditing: item.editing, canOpenClose: canOpenClose, canHide: channel.flags.contains(.isCreator) || channel.hasPermission(.manageTopics), hiddenByDefault: threadInfo.isHidden) } else { peerRevealOptions = forumThreadRevealOptions(strings: item.presentationData.strings, theme: item.presentationData.theme, isMuted: (currentMutedIconImage != nil), isClosed: isClosed, isEditing: item.editing, canOpenClose: canOpenClose, canDelete: canDelete) } diff --git a/submodules/Display/Source/GlobalOverlayPresentationContext.swift b/submodules/Display/Source/GlobalOverlayPresentationContext.swift index 041e6d8617..8ebc83f1a8 100644 --- a/submodules/Display/Source/GlobalOverlayPresentationContext.swift +++ b/submodules/Display/Source/GlobalOverlayPresentationContext.swift @@ -3,7 +3,7 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit -func isViewVisibleInHierarchy(_ view: UIView, _ initial: Bool = true) -> Bool { +public func isViewVisibleInHierarchy(_ view: UIView, _ initial: Bool = true) -> Bool { guard let window = view.window else { return false } diff --git a/submodules/TelegramUI/Sources/ChatMessageItem.swift b/submodules/TelegramUI/Sources/ChatMessageItem.swift index b64875f020..04c8afb817 100644 --- a/submodules/TelegramUI/Sources/ChatMessageItem.swift +++ b/submodules/TelegramUI/Sources/ChatMessageItem.swift @@ -122,7 +122,7 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs } var sameThread = true - if lhs.threadId != rhs.threadId { + if let lhsPeer = lhs.peers[lhs.id.peerId], let rhsPeer = rhs.peers[rhs.id.peerId], arePeersEqual(lhsPeer, rhsPeer), let channel = lhsPeer as? TelegramChannel, channel.flags.contains(.isForum), lhs.threadId != rhs.threadId { sameThread = false } diff --git a/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift b/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift index 62327618b4..5963ac7fef 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift @@ -97,15 +97,15 @@ private final class ChatTextInputMediaRecordingButtonPresenterControllerNode: Vi } private final class ChatTextInputMediaRecordingButtonPresenter : NSObject, TGModernConversationInputMicButtonPresentation { - private let account: Account? + private let statusBarHost: StatusBarHost? private let presentController: (ViewController) -> Void let container: ChatTextInputMediaRecordingButtonPresenterContainer private var presentationController: ChatTextInputMediaRecordingButtonPresenterController? private var timer: SwiftSignalKit.Timer? fileprivate weak var button: ChatTextInputMediaRecordingButton? - init(account: Account, presentController: @escaping (ViewController) -> Void) { - self.account = account + init(statusBarHost: StatusBarHost?, presentController: @escaping (ViewController) -> Void) { + self.statusBarHost = statusBarHost self.presentController = presentController self.container = ChatTextInputMediaRecordingButtonPresenterContainer() } @@ -128,11 +128,19 @@ private final class ChatTextInputMediaRecordingButtonPresenter : NSObject, TGMod } func present() { - if let keyboardWindow = LegacyComponentsGlobals.provider().applicationKeyboardWindow(), !keyboardWindow.isHidden { + let windowIsVisible: (UIWindow) -> Bool = { window in + print(window.alpha) + print(window.isHidden) + print(window.frame) + print(window.subviews) + return !window.frame.height.isZero + } + + if let statusBarHost = self.statusBarHost, let keyboardWindow = statusBarHost.keyboardWindow, let keyboardView = statusBarHost.keyboardView, !keyboardView.frame.height.isZero, isViewVisibleInHierarchy(keyboardView) { keyboardWindow.addSubview(self.container) self.timer = SwiftSignalKit.Timer(timeout: 0.05, repeat: true, completion: { [weak self] in - if let keyboardWindow = LegacyComponentsGlobals.provider().applicationKeyboardWindow(), !keyboardWindow.isHidden { + if let keyboardWindow = LegacyComponentsGlobals.provider().applicationKeyboardWindow(), windowIsVisible(keyboardWindow) { } else { self?.present() } @@ -174,7 +182,7 @@ final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButto private let strings: PresentationStrings var mode: ChatTextInputMediaRecordingButtonMode = .audio - var account: Account? + var statusBarHost: StatusBarHost? let presentController: (ViewController) -> Void var recordingDisabled: () -> Void = { } var beginRecording: () -> Void = { } @@ -473,7 +481,7 @@ final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButto } func micButtonPresenter() -> TGModernConversationInputMicButtonPresentation! { - let presenter = ChatTextInputMediaRecordingButtonPresenter(account: self.account!, presentController: self.presentController) + let presenter = ChatTextInputMediaRecordingButtonPresenter(statusBarHost: self.statusBarHost, presentController: self.presentController) presenter.button = self self.currentPresenter = presenter.view() return presenter diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 2f57f5bce9..51dd0ff546 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -613,7 +613,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { override var context: AccountContext? { didSet { - self.actionButtons.micButton.account = self.context?.account + self.actionButtons.micButton.statusBarHost = self.context?.sharedContext.mainWindow?.statusBarHost } } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 5aedf640bc..483ecb0448 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -3451,9 +3451,15 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate guard let strongSelf = self, let threadData = strongSelf.data?.threadData else { return } + + let premiumConfiguration = PremiumConfiguration.with(appConfiguration: strongSelf.context.currentAppConfiguration.with { $0 }) + guard !premiumConfiguration.isPremiumDisabled else { + return + } + if let icon = threadData.info.icon, icon != 0 { let _ = (strongSelf.context.engine.stickers.resolveInlineStickers(fileIds: [icon]) - |> deliverOnMainQueue).start(next: { [weak self] files in + |> deliverOnMainQueue).start(next: { [weak self] files in if let file = files.first?.value { var stickerPackReference: StickerPackReference? for attribute in file.attributes { @@ -3467,7 +3473,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate let _ = (strongSelf.context.engine.stickers.loadedStickerPack(reference: stickerPackReference, forceActualized: false) |> deliverOnMainQueue).start(next: { [weak self] stickerPack in if let strongSelf = self, case let .result(info, _, _) = stickerPack { - strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .sticker(context: strongSelf.context, file: file, title: nil, text: strongSelf.presentationData.strings.Stickers_EmojiPackInfoText(info.title).string, undoText: strongSelf.presentationData.strings.Stickers_PremiumPackView, customAction: nil), elevatedLayout: false, action: { [weak self] action in + strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .sticker(context: strongSelf.context, file: file, title: nil, text: strongSelf.presentationData.strings.PeerInfo_TopicIconInfoText(info.title).string, undoText: strongSelf.presentationData.strings.Stickers_PremiumPackView, customAction: nil), elevatedLayout: false, action: { [weak self] action in if let strongSelf = self, action == .undo { strongSelf.presentEmojiList(packReference: stickerPackReference) }