Fix monoforum loading placeholder

This commit is contained in:
Isaac 2025-06-05 20:17:41 +08:00
parent 2ca01d18eb
commit e3afecd82c
2 changed files with 12 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import UIKit
import AsyncDisplayKit import AsyncDisplayKit
import SwiftSignalKit import SwiftSignalKit
import Display import Display
import Postbox
import TelegramCore import TelegramCore
import TelegramPresentationData import TelegramPresentationData
import ActivityIndicator import ActivityIndicator
@ -408,17 +409,17 @@ public final class ChatLoadingPlaceholderNode: ASDisplayNode {
case channel case channel
} }
private var chatType: ChatType = .channel private var chatType: ChatType = .channel
public func updatePresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState) { public func updatePresentationInterfaceState(renderedPeer: RenderedPeer?, chatLocation: ChatLocation) {
var chatType: ChatType = .channel var chatType: ChatType = .channel
if let peer = chatPresentationInterfaceState.renderedPeer?.peer { if let peer = renderedPeer?.peer {
if peer is TelegramUser { if peer is TelegramUser {
chatType = .user chatType = .user
} else if peer is TelegramGroup { } else if peer is TelegramGroup {
chatType = .group chatType = .group
} else if let channel = peer as? TelegramChannel { } else if let channel = peer as? TelegramChannel {
if channel.isMonoForum { if channel.isMonoForum {
if let mainChannel = chatPresentationInterfaceState.renderedPeer?.chatOrMonoforumMainPeer as? TelegramChannel, mainChannel.hasPermission(.sendSomething) { if let mainChannel = renderedPeer?.chatOrMonoforumMainPeer as? TelegramChannel, mainChannel.hasPermission(.sendSomething) {
if chatPresentationInterfaceState.chatLocation.threadId == nil { if chatLocation.threadId == nil {
chatType = .group chatType = .group
} else { } else {
chatType = .user chatType = .user

View File

@ -200,6 +200,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
private(set) var validLayout: (ContainerViewLayout, CGFloat)? private(set) var validLayout: (ContainerViewLayout, CGFloat)?
private var visibleAreaInset = UIEdgeInsets() private var visibleAreaInset = UIEdgeInsets()
private var loadingNodeInsets = UIEdgeInsets()
private var currentListViewLayout: (size: CGSize, insets: UIEdgeInsets, scrollIndicatorInsets: UIEdgeInsets)? private var currentListViewLayout: (size: CGSize, insets: UIEdgeInsets, scrollIndicatorInsets: UIEdgeInsets)?
private(set) var searchNavigationNode: ChatSearchNavigationContentNode? private(set) var searchNavigationNode: ChatSearchNavigationContentNode?
@ -360,7 +361,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
} }
} else { } else {
loadingPlaceholderNode = ChatLoadingPlaceholderNode(context: self.context, theme: self.chatPresentationInterfaceState.theme, chatWallpaper: self.chatPresentationInterfaceState.chatWallpaper, bubbleCorners: self.chatPresentationInterfaceState.bubbleCorners, backgroundNode: self.backgroundNode) 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.backgroundNode.supernode?.insertSubnode(loadingPlaceholderNode, aboveSubnode: self.backgroundNode)
self.loadingPlaceholderNode = loadingPlaceholderNode self.loadingPlaceholderNode = loadingPlaceholderNode
@ -370,7 +371,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
let contentBounds = self.loadingNode.frame let contentBounds = self.loadingNode.frame
loadingPlaceholderNode.frame = contentBounds loadingPlaceholderNode.frame = contentBounds
if let loadingPlaceholderNode = self.loadingPlaceholderNode, let validLayout = self.validLayout { 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) loadingPlaceholderNode.update(rect: contentBounds, within: contentBounds.size, transition: .immediate)
} }
} }
@ -2245,6 +2246,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
if let leftPanelSize { if let leftPanelSize {
loadingNodeInsets.left += leftPanelSize.width loadingNodeInsets.left += leftPanelSize.width
} }
self.loadingNodeInsets = loadingNodeInsets
self.loadingNode.updateLayout(size: contentBounds.size, insets: loadingNodeInsets, transition: transition) self.loadingNode.updateLayout(size: contentBounds.size, insets: loadingNodeInsets, transition: transition)
if let loadingPlaceholderNode = self.loadingPlaceholderNode { if let loadingPlaceholderNode = self.loadingPlaceholderNode {
@ -3571,7 +3573,9 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
self.backgroundNode.update(wallpaper: chatPresentationInterfaceState.chatWallpaper, animated: true) self.backgroundNode.update(wallpaper: chatPresentationInterfaceState.chatWallpaper, animated: true)
self.historyNode.verticalScrollIndicatorColor = UIColor(white: 0.5, alpha: 0.8) 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) var updatedInputFocus = self.chatPresentationInterfaceStateRequiresInputFocus(self.chatPresentationInterfaceState) != self.chatPresentationInterfaceStateRequiresInputFocus(chatPresentationInterfaceState)
if self.chatPresentationInterfaceStateInputView(self.chatPresentationInterfaceState) !== self.chatPresentationInterfaceStateInputView(chatPresentationInterfaceState) { if self.chatPresentationInterfaceStateInputView(self.chatPresentationInterfaceState) !== self.chatPresentationInterfaceStateInputView(chatPresentationInterfaceState) {