diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index a4d279a4db..cebb7c9e12 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -6674,7 +6674,7 @@ Sorry for the inconvenience."; "Notification.YouChangedTheme" = "You changed chat theme to %@"; "Notification.YouDisabledTheme" = "You disabled chat theme"; -"Notification.ChannelChangedTheme" = "Channel theme changed to %2$@"; +"Notification.ChannelChangedTheme" = "Channel theme changed to %1$@"; "Notification.ChannelDisabledTheme" = "Channel theme disabled"; "Appstore.Cloud" = "**Cloud-based**\nUnlimited storage for chats,\nmedia and documents."; diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 9f8147d3a0..d65080fcef 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -11583,21 +11583,27 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let strongSelf = self { strongSelf.updateChatPresentationInterfaceState(animated: false, interactive: true, { $0.updatedInterfaceState({ $0.withoutSelectionState() }) }) - let ready = Promise() - - strongSelf.controllerNavigationDisposable.set((ready.get() - |> SwiftSignalKit.filter { $0 } - |> take(1) - |> deliverOnMainQueue).start(next: { _ in - if let strongController = controller { - strongController.dismiss() - } - })) - + let navigationController: NavigationController? if let parentController = strongSelf.parentController { - (parentController.navigationController as? NavigationController)?.replaceTopController(ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(peerId)), animated: false, ready: ready) + navigationController = (parentController.navigationController as? NavigationController) } else { - strongSelf.effectiveNavigationController?.replaceTopController(ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(peerId)), animated: false, ready: ready) + navigationController = strongSelf.effectiveNavigationController + } + + if let navigationController = navigationController { + let chatController = ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(peerId)) + var viewControllers = navigationController.viewControllers + viewControllers.insert(chatController, at: viewControllers.count - 1) + navigationController.setViewControllers(viewControllers, animated: false) + + strongSelf.controllerNavigationDisposable.set((chatController.ready.get() + |> SwiftSignalKit.filter { $0 } + |> take(1) + |> deliverOnMainQueue).start(next: { _ in + if let strongController = controller { + strongController.dismiss() + } + })) } } }) @@ -11705,16 +11711,22 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G |> deliverOnMainQueue).start(completed: { if let strongSelf = self { strongSelf.updateChatPresentationInterfaceState(animated: false, interactive: true, { $0.updatedInterfaceState({ $0.withoutSelectionState() }) }) - - let ready = Promise() - - strongSelf.controllerNavigationDisposable.set((ready.get() |> filter { $0 } |> take(1) |> deliverOnMainQueue).start(next: { _ in - if let strongController = controller { - strongController.dismiss() - } - })) - - strongSelf.effectiveNavigationController?.replaceTopController(ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(peerId)), animated: false, ready: ready) + + if let navigationController = strongSelf.effectiveNavigationController { + let chatController = ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(peerId)) + var viewControllers = navigationController.viewControllers + viewControllers.insert(chatController, at: viewControllers.count - 1) + navigationController.setViewControllers(viewControllers, animated: false) + + strongSelf.controllerNavigationDisposable.set((chatController.ready.get() + |> filter { $0 } + |> take(1) + |> deliverOnMainQueue).start(next: { _ in + if let strongController = controller { + strongController.dismiss() + } + })) + } } }) } diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index 293b049bf9..8ed486740c 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -2472,7 +2472,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { let isSelected = (self.controllerInteraction.selectionState?.selectedIds.contains(message.id) ?? false) if state.selecting != isSelected { let messageIds = messages.filter { message -> Bool in - for media in messages { + for media in message.media { if media is TelegramMediaAction { return false } diff --git a/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift index ac42e4899d..b2223bde64 100644 --- a/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/EditAccessoryPanelNode.swift @@ -68,6 +68,8 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { var strings: PresentationStrings var nameDisplayOrder: PresentationPersonNameOrder + private var validLayout: (size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState)? + init(context: AccountContext, messageId: MessageId, theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, dateTimeFormat: PresentationDateTimeFormat) { self.context = context self.messageId = messageId @@ -296,7 +298,9 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { }) |> then(updateImageSignal)) } - self.setNeedsLayout() + if let (size, inset, interfaceState) = self.validLayout { + self.updateState(size: size, inset: inset, interfaceState: interfaceState) + } } override func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) { @@ -316,7 +320,9 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(15.0), textColor: self.theme.chat.inputPanel.primaryTextColor) } - self.setNeedsLayout() + if let (size, inset, interfaceState) = self.validLayout { + self.updateState(size: size, inset: inset, interfaceState: interfaceState) + } } } @@ -325,6 +331,8 @@ final class EditAccessoryPanelNode: AccessoryPanelNode { } override func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { + self.validLayout = (size, inset, interfaceState) + let editMediaReference = interfaceState.editMessageState?.mediaReference var updatedEditMedia = false if let currentEditMediaReference = self.currentEditMediaReference, let editMediaReference = editMediaReference { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 8352545820..f3a76fa9b6 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -5805,14 +5805,21 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD if let strongSelf = self { strongSelf.headerNode.navigationButtonContainer.performAction?(.selectionDone) - let ready = Promise() - strongSelf.activeActionDisposable.set((ready.get() |> filter { $0 } |> take(1) |> deliverOnMainQueue).start(next: { _ in - if let peerSelectionController = peerSelectionController { - peerSelectionController.dismiss() - } - })) - - (strongSelf.controller?.navigationController as? NavigationController)?.replaceTopController(ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(peerId)), animated: false, ready: ready) + if let navigationController = strongSelf.controller?.navigationController as? NavigationController { + let chatController = ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(peerId)) + var viewControllers = navigationController.viewControllers + viewControllers.insert(chatController, at: viewControllers.count - 1) + navigationController.setViewControllers(viewControllers, animated: false) + + strongSelf.activeActionDisposable.set((chatController.ready.get() + |> filter { $0 } + |> take(1) + |> deliverOnMainQueue).start(next: { _ in + if let peerSelectionController = peerSelectionController { + peerSelectionController.dismiss() + } + })) + } } }) } diff --git a/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift index 92f7ccd10b..46fde181c5 100644 --- a/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/ReplyAccessoryPanelNode.swift @@ -30,6 +30,8 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode { var theme: PresentationTheme var strings: PresentationStrings + private var validLayout: (size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState)? + init(context: AccountContext, messageId: MessageId, theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, dateTimeFormat: PresentationDateTimeFormat) { self.messageId = messageId @@ -204,7 +206,9 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode { strongSelf.imageNode.setSignal(updateImageSignal) } - strongSelf.setNeedsLayout() + if let (size, inset, interfaceState) = strongSelf.validLayout { + strongSelf.updateState(size: size, inset: inset, interfaceState: interfaceState) + } } })) } @@ -236,7 +240,9 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode { self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(15.0), textColor: self.theme.chat.inputPanel.primaryTextColor) } - self.setNeedsLayout() + if let (size, inset, interfaceState) = self.validLayout { + self.updateState(size: size, inset: inset, interfaceState: interfaceState) + } } } @@ -245,7 +251,9 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode { } override func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { - let bounds = self.bounds + self.validLayout = (size, inset, interfaceState) + + let bounds = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 45.0)) let leftInset: CGFloat = 55.0 let textLineInset: CGFloat = 10.0 let rightInset: CGFloat = 55.0 diff --git a/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift index bb861781c6..e1d0d8a267 100644 --- a/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift @@ -27,6 +27,8 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { var theme: PresentationTheme var strings: PresentationStrings + private var validLayout: (size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState)? + init(context: AccountContext, url: String, webpage: TelegramMediaWebpage, theme: PresentationTheme, strings: PresentationStrings) { self.url = url self.webpage = webpage @@ -92,7 +94,9 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { self.updateWebpage() - self.setNeedsLayout() + if let (size, inset, interfaceState) = self.validLayout { + self.updateState(size: size, inset: inset, interfaceState: interfaceState) + } } } @@ -143,7 +147,9 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { self.titleString = NSAttributedString(string: authorName, font: Font.medium(15.0), textColor: self.theme.chat.inputPanel.panelControlAccentColor) self.textString = NSAttributedString(string: text, font: Font.regular(15.0), textColor: self.theme.chat.inputPanel.primaryTextColor) - self.setNeedsLayout() + if let (size, inset, interfaceState) = self.validLayout { + self.updateState(size: size, inset: inset, interfaceState: interfaceState) + } } override func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize { @@ -151,7 +157,9 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { } override func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) { - let bounds = self.bounds + self.validLayout = (size, inset, interfaceState) + + let bounds = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 45.0)) let leftInset: CGFloat = 55.0 let textLineInset: CGFloat = 10.0 let rightInset: CGFloat = 55.0