Various fixes

This commit is contained in:
Ilya Laktyushin 2022-11-24 02:36:11 +04:00
parent 0ba39ad01e
commit dea2cc2a7d
8 changed files with 29 additions and 14 deletions

View File

@ -8316,3 +8316,4 @@ Sorry for the inconvenience.";
"ChatList.EmptyTopicsDescription" = "Older messages from this group have been moved to \"General\"."; "ChatList.EmptyTopicsDescription" = "Older messages from this group have been moved to \"General\".";
"Stickers.EmojiPackInfoText" = "This message contains **%@** emoji."; "Stickers.EmojiPackInfoText" = "This message contains **%@** emoji.";
"PeerInfo.TopicIconInfoText" = "This topic's icon is from **%@**.";

View File

@ -191,7 +191,7 @@ private let phonebookUsernamePrefix = "https://t.me/" + phonebookUsernamePathPre
public extension DeviceContactUrlData { public extension DeviceContactUrlData {
convenience init(appProfile: PeerId) { convenience init(appProfile: PeerId) {
self.init(label: "Telegram", value: "\(phonebookUsernamePrefix)\(appProfile.id)") self.init(label: "Telegram", value: "\(phonebookUsernamePrefix)\(appProfile.id._internalGetInt64Value())")
} }
} }

View File

@ -2298,7 +2298,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
isClosed = threadInfo.isClosed isClosed = threadInfo.isClosed
} }
if let threadInfo, threadInfo.id == 1 { 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 { } else {
peerRevealOptions = forumThreadRevealOptions(strings: item.presentationData.strings, theme: item.presentationData.theme, isMuted: (currentMutedIconImage != nil), isClosed: isClosed, isEditing: item.editing, canOpenClose: canOpenClose, canDelete: canDelete) peerRevealOptions = forumThreadRevealOptions(strings: item.presentationData.strings, theme: item.presentationData.theme, isMuted: (currentMutedIconImage != nil), isClosed: isClosed, isEditing: item.editing, canOpenClose: canOpenClose, canDelete: canDelete)
} }

View File

@ -3,7 +3,7 @@ import UIKit
import AsyncDisplayKit import AsyncDisplayKit
import SwiftSignalKit 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 { guard let window = view.window else {
return false return false
} }

View File

@ -122,7 +122,7 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs
} }
var sameThread = true 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 sameThread = false
} }

View File

@ -97,15 +97,15 @@ private final class ChatTextInputMediaRecordingButtonPresenterControllerNode: Vi
} }
private final class ChatTextInputMediaRecordingButtonPresenter : NSObject, TGModernConversationInputMicButtonPresentation { private final class ChatTextInputMediaRecordingButtonPresenter : NSObject, TGModernConversationInputMicButtonPresentation {
private let account: Account? private let statusBarHost: StatusBarHost?
private let presentController: (ViewController) -> Void private let presentController: (ViewController) -> Void
let container: ChatTextInputMediaRecordingButtonPresenterContainer let container: ChatTextInputMediaRecordingButtonPresenterContainer
private var presentationController: ChatTextInputMediaRecordingButtonPresenterController? private var presentationController: ChatTextInputMediaRecordingButtonPresenterController?
private var timer: SwiftSignalKit.Timer? private var timer: SwiftSignalKit.Timer?
fileprivate weak var button: ChatTextInputMediaRecordingButton? fileprivate weak var button: ChatTextInputMediaRecordingButton?
init(account: Account, presentController: @escaping (ViewController) -> Void) { init(statusBarHost: StatusBarHost?, presentController: @escaping (ViewController) -> Void) {
self.account = account self.statusBarHost = statusBarHost
self.presentController = presentController self.presentController = presentController
self.container = ChatTextInputMediaRecordingButtonPresenterContainer() self.container = ChatTextInputMediaRecordingButtonPresenterContainer()
} }
@ -128,11 +128,19 @@ private final class ChatTextInputMediaRecordingButtonPresenter : NSObject, TGMod
} }
func present() { 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) keyboardWindow.addSubview(self.container)
self.timer = SwiftSignalKit.Timer(timeout: 0.05, repeat: true, completion: { [weak self] in 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 { } else {
self?.present() self?.present()
} }
@ -174,7 +182,7 @@ final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButto
private let strings: PresentationStrings private let strings: PresentationStrings
var mode: ChatTextInputMediaRecordingButtonMode = .audio var mode: ChatTextInputMediaRecordingButtonMode = .audio
var account: Account? var statusBarHost: StatusBarHost?
let presentController: (ViewController) -> Void let presentController: (ViewController) -> Void
var recordingDisabled: () -> Void = { } var recordingDisabled: () -> Void = { }
var beginRecording: () -> Void = { } var beginRecording: () -> Void = { }
@ -473,7 +481,7 @@ final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButto
} }
func micButtonPresenter() -> TGModernConversationInputMicButtonPresentation! { func micButtonPresenter() -> TGModernConversationInputMicButtonPresentation! {
let presenter = ChatTextInputMediaRecordingButtonPresenter(account: self.account!, presentController: self.presentController) let presenter = ChatTextInputMediaRecordingButtonPresenter(statusBarHost: self.statusBarHost, presentController: self.presentController)
presenter.button = self presenter.button = self
self.currentPresenter = presenter.view() self.currentPresenter = presenter.view()
return presenter return presenter

View File

@ -613,7 +613,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
override var context: AccountContext? { override var context: AccountContext? {
didSet { didSet {
self.actionButtons.micButton.account = self.context?.account self.actionButtons.micButton.statusBarHost = self.context?.sharedContext.mainWindow?.statusBarHost
} }
} }

View File

@ -3451,9 +3451,15 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
guard let strongSelf = self, let threadData = strongSelf.data?.threadData else { guard let strongSelf = self, let threadData = strongSelf.data?.threadData else {
return return
} }
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: strongSelf.context.currentAppConfiguration.with { $0 })
guard !premiumConfiguration.isPremiumDisabled else {
return
}
if let icon = threadData.info.icon, icon != 0 { if let icon = threadData.info.icon, icon != 0 {
let _ = (strongSelf.context.engine.stickers.resolveInlineStickers(fileIds: [icon]) 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 { if let file = files.first?.value {
var stickerPackReference: StickerPackReference? var stickerPackReference: StickerPackReference?
for attribute in file.attributes { for attribute in file.attributes {
@ -3467,7 +3473,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
let _ = (strongSelf.context.engine.stickers.loadedStickerPack(reference: stickerPackReference, forceActualized: false) let _ = (strongSelf.context.engine.stickers.loadedStickerPack(reference: stickerPackReference, forceActualized: false)
|> deliverOnMainQueue).start(next: { [weak self] stickerPack in |> deliverOnMainQueue).start(next: { [weak self] stickerPack in
if let strongSelf = self, case let .result(info, _, _) = stickerPack { 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 { if let strongSelf = self, action == .undo {
strongSelf.presentEmojiList(packReference: stickerPackReference) strongSelf.presentEmojiList(packReference: stickerPackReference)
} }