Fix chat title update

This commit is contained in:
Isaac
2026-02-10 10:52:53 +04:00
parent 73d7587a06
commit 692fbd9742
5 changed files with 48 additions and 11 deletions
+1 -1
View File
@@ -1 +1 @@
2620
2720
@@ -16,7 +16,7 @@ import EmojiStatusComponent
import GlassBackgroundComponent
public final class ChatNavigationBarTitleView: UIView, NavigationBarTitleView {
private final class ContentData {
private final class ContentData: Equatable {
let context: AccountContext
let theme: PresentationTheme
let preferClearGlass: Bool
@@ -36,6 +36,34 @@ public final class ChatNavigationBarTitleView: UIView, NavigationBarTitleView {
self.nameDisplayOrder = nameDisplayOrder
self.content = content
}
static func ==(lhs: ContentData, rhs: ContentData) -> Bool {
if lhs.context !== rhs.context {
return false
}
if lhs.theme !== rhs.theme {
return false
}
if lhs.preferClearGlass != rhs.preferClearGlass {
return false
}
if lhs.wallpaper != rhs.wallpaper {
return false
}
if lhs.strings !== rhs.strings {
return false
}
if lhs.dateTimeFormat != rhs.dateTimeFormat {
return false
}
if lhs.nameDisplayOrder != rhs.nameDisplayOrder {
return false
}
if lhs.content != rhs.content {
return false
}
return true
}
}
private let parentTitleState = ComponentState()
@@ -86,9 +114,9 @@ public final class ChatNavigationBarTitleView: UIView, NavigationBarTitleView {
content: ChatTitleContent,
transition: ComponentTransition,
ignoreParentTransitionRequests: Bool = false
) {
) -> Bool {
self.ignoreParentTransitionRequests = ignoreParentTransitionRequests
self.contentData = ContentData(
let contentData = ContentData(
context: context,
theme: theme,
preferClearGlass: preferClearGlass,
@@ -98,8 +126,12 @@ public final class ChatNavigationBarTitleView: UIView, NavigationBarTitleView {
nameDisplayOrder: nameDisplayOrder,
content: content
)
let isUpdated = self.contentData != contentData
self.contentData = contentData
self.update(transition: transition)
self.ignoreParentTransitionRequests = false
return isUpdated
}
public func updateActivities(activities: ChatTitleComponent.Activities?, transition: ComponentTransition) {
@@ -456,12 +456,14 @@ func updateChatPresentationInterfaceStateImpl(
selfController.tempHideAccessoryPanels = selfController.presentationInterfaceState.search != nil
if let chatTitleContent = selfController.contentData?.state.chatTitleContent {
var forceLayout = false
if let chatTitleContent = selfController.contentData?.state.chatTitleContent, let chatTitleView = selfController.chatTitleView {
var titleTransition = ComponentTransition(transition)
if case .messageOptions = selfController.subject {
titleTransition = titleTransition.withAnimation(.none)
}
selfController.chatTitleView?.update(
let isChatTitleViewUpdated = chatTitleView.update(
context: selfController.context,
theme: selfController.presentationData.theme,
preferClearGlass: selfController.presentationInterfaceState.preferredGlassType == .clear,
@@ -473,10 +475,13 @@ func updateChatPresentationInterfaceStateImpl(
transition: titleTransition,
ignoreParentTransitionRequests: true
)
if isChatTitleViewUpdated {
forceLayout = true
}
}
if selfController.isNodeLoaded {
selfController.chatDisplayNode.updateChatPresentationInterfaceState(updatedChatPresentationInterfaceState, transition: transition, interactive: interactive, completion: completion)
selfController.chatDisplayNode.updateChatPresentationInterfaceState(updatedChatPresentationInterfaceState, transition: transition, interactive: interactive, forceLayout: forceLayout, completion: completion)
} else {
completion(.immediate)
}
@@ -49,7 +49,7 @@ extension ChatControllerImpl {
contentNode.setErrorText(errorText: self.presentationData.strings.QuickReply_ShortcutExistsInlineError)
}
} else {
self.chatTitleView?.update(
let _ = self.chatTitleView?.update(
context: self.context,
theme: self.presentationData.theme,
preferClearGlass: self.presentationInterfaceState.preferredGlassType == .clear,
@@ -102,7 +102,7 @@ extension ChatControllerImpl {
} else {
linkUrl = link.url
}
self.chatTitleView?.update(
let _ = self.chatTitleView?.update(
context: self.context,
theme: self.presentationData.theme,
preferClearGlass: self.presentationInterfaceState.preferredGlassType == .clear,
@@ -3435,7 +3435,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
}
}
func updateChatPresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, transition: ContainedViewLayoutTransition, interactive: Bool, completion: @escaping (ContainedViewLayoutTransition) -> Void) {
func updateChatPresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, transition: ContainedViewLayoutTransition, interactive: Bool, forceLayout: Bool, completion: @escaping (ContainedViewLayoutTransition) -> Void) {
self.selectedMessages = chatPresentationInterfaceState.interfaceState.selectionState?.selectedIds
var textStateUpdated = false
@@ -3451,7 +3451,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
let presentationReadyUpdated = self.chatPresentationInterfaceState.presentationReady != chatPresentationInterfaceState.presentationReady
if (self.chatPresentationInterfaceState != chatPresentationInterfaceState && chatPresentationInterfaceState.presentationReady) || textStateUpdated {
if (self.chatPresentationInterfaceState != chatPresentationInterfaceState && chatPresentationInterfaceState.presentationReady) || textStateUpdated || forceLayout {
self.onLayoutCompletions.append(completion)
let themeUpdated = presentationReadyUpdated || (self.chatPresentationInterfaceState.theme !== chatPresentationInterfaceState.theme)