From e3afecd82ce2579d82c139d89b296339e1bba389 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Thu, 5 Jun 2025 20:17:41 +0800 Subject: [PATCH] Fix monoforum loading placeholder --- .../Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift | 9 +++++---- submodules/TelegramUI/Sources/ChatControllerNode.swift | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift b/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift index 432fb81590..3468dc3172 100644 --- a/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift @@ -3,6 +3,7 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit import Display +import Postbox import TelegramCore import TelegramPresentationData import ActivityIndicator @@ -408,17 +409,17 @@ public final class ChatLoadingPlaceholderNode: ASDisplayNode { case channel } private var chatType: ChatType = .channel - public func updatePresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState) { + public func updatePresentationInterfaceState(renderedPeer: RenderedPeer?, chatLocation: ChatLocation) { var chatType: ChatType = .channel - if let peer = chatPresentationInterfaceState.renderedPeer?.peer { + if let peer = renderedPeer?.peer { if peer is TelegramUser { chatType = .user } else if peer is TelegramGroup { chatType = .group } else if let channel = peer as? TelegramChannel { if channel.isMonoForum { - if let mainChannel = chatPresentationInterfaceState.renderedPeer?.chatOrMonoforumMainPeer as? TelegramChannel, mainChannel.hasPermission(.sendSomething) { - if chatPresentationInterfaceState.chatLocation.threadId == nil { + if let mainChannel = renderedPeer?.chatOrMonoforumMainPeer as? TelegramChannel, mainChannel.hasPermission(.sendSomething) { + if chatLocation.threadId == nil { chatType = .group } else { chatType = .user diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index f39184e345..bfa90845ae 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -200,6 +200,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { private(set) var validLayout: (ContainerViewLayout, CGFloat)? private var visibleAreaInset = UIEdgeInsets() + private var loadingNodeInsets = UIEdgeInsets() private var currentListViewLayout: (size: CGSize, insets: UIEdgeInsets, scrollIndicatorInsets: UIEdgeInsets)? private(set) var searchNavigationNode: ChatSearchNavigationContentNode? @@ -360,7 +361,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { } } else { loadingPlaceholderNode = ChatLoadingPlaceholderNode(context: self.context, theme: self.chatPresentationInterfaceState.theme, chatWallpaper: self.chatPresentationInterfaceState.chatWallpaper, bubbleCorners: self.chatPresentationInterfaceState.bubbleCorners, backgroundNode: self.backgroundNode) - loadingPlaceholderNode.updatePresentationInterfaceState(self.chatPresentationInterfaceState) + loadingPlaceholderNode.updatePresentationInterfaceState(renderedPeer: self.chatPresentationInterfaceState.renderedPeer, chatLocation: self.chatLocation) self.backgroundNode.supernode?.insertSubnode(loadingPlaceholderNode, aboveSubnode: self.backgroundNode) self.loadingPlaceholderNode = loadingPlaceholderNode @@ -370,7 +371,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { let contentBounds = self.loadingNode.frame loadingPlaceholderNode.frame = contentBounds if let loadingPlaceholderNode = self.loadingPlaceholderNode, let validLayout = self.validLayout { - loadingPlaceholderNode.updateLayout(size: contentBounds.size, insets: self.visibleAreaInset, metrics: validLayout.0.metrics, transition: .immediate) + loadingPlaceholderNode.updateLayout(size: contentBounds.size, insets: self.loadingNodeInsets, metrics: validLayout.0.metrics, transition: .immediate) loadingPlaceholderNode.update(rect: contentBounds, within: contentBounds.size, transition: .immediate) } } @@ -2245,6 +2246,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { if let leftPanelSize { loadingNodeInsets.left += leftPanelSize.width } + self.loadingNodeInsets = loadingNodeInsets self.loadingNode.updateLayout(size: contentBounds.size, insets: loadingNodeInsets, transition: transition) if let loadingPlaceholderNode = self.loadingPlaceholderNode { @@ -3571,7 +3573,9 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { self.backgroundNode.update(wallpaper: chatPresentationInterfaceState.chatWallpaper, animated: true) self.historyNode.verticalScrollIndicatorColor = UIColor(white: 0.5, alpha: 0.8) - self.loadingPlaceholderNode?.updatePresentationInterfaceState(chatPresentationInterfaceState) + if self.pendingSwitchToChatLocation == nil { + self.loadingPlaceholderNode?.updatePresentationInterfaceState(renderedPeer: chatPresentationInterfaceState.renderedPeer, chatLocation: self.chatLocation) + } var updatedInputFocus = self.chatPresentationInterfaceStateRequiresInputFocus(self.chatPresentationInterfaceState) != self.chatPresentationInterfaceStateRequiresInputFocus(chatPresentationInterfaceState) if self.chatPresentationInterfaceStateInputView(self.chatPresentationInterfaceState) !== self.chatPresentationInterfaceStateInputView(chatPresentationInterfaceState) {