Monoforums

This commit is contained in:
Isaac 2025-06-04 23:38:44 +08:00
parent 99e09e0d5a
commit 1cbc239dc0
6 changed files with 45 additions and 22 deletions

View File

@ -370,7 +370,7 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
} }
}) })
if let headerSeparableThreadId, let headerDisplayPeer { if let headerSeparableThreadId, let headerDisplayPeer, !(associatedData.subject?.isService ?? false) {
self.topicHeader = ChatMessageDateHeader(timestamp: content.index.timestamp, separableThreadId: headerSeparableThreadId, scheduled: false, displayHeader: headerDisplayPeer, presentationData: presentationData, controllerInteraction: controllerInteraction, context: context, action: { _, _ in self.topicHeader = ChatMessageDateHeader(timestamp: content.index.timestamp, separableThreadId: headerSeparableThreadId, scheduled: false, displayHeader: headerDisplayPeer, presentationData: presentationData, controllerInteraction: controllerInteraction, context: context, action: { _, _ in
controllerInteraction.updateChatLocationThread(headerSeparableThreadId, nil) controllerInteraction.updateChatLocationThread(headerSeparableThreadId, nil)
}) })

View File

@ -23,6 +23,11 @@ func updateChatPresentationInterfaceStateImpl(
_ f: (ChatPresentationInterfaceState) -> ChatPresentationInterfaceState, _ f: (ChatPresentationInterfaceState) -> ChatPresentationInterfaceState,
completion externalCompletion: @escaping (ContainedViewLayoutTransition) -> Void completion externalCompletion: @escaping (ContainedViewLayoutTransition) -> Void
) { ) {
var transition = transition
if !selfController.didAppear {
transition = .immediate
}
var completion = externalCompletion var completion = externalCompletion
var temporaryChatPresentationInterfaceState = f(selfController.presentationInterfaceState) var temporaryChatPresentationInterfaceState = f(selfController.presentationInterfaceState)

View File

@ -6436,6 +6436,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.chatDisplayNode.historyNode.experimentalSnapScrollToItem = false self.chatDisplayNode.historyNode.experimentalSnapScrollToItem = false
self.chatDisplayNode.historyNode.canReadHistory.set(self.computedCanReadHistoryPromise.get()) self.chatDisplayNode.historyNode.canReadHistory.set(self.computedCanReadHistoryPromise.get())
self.chatDisplayNode.historyNode.areContentAnimationsEnabled = true
if !self.alwaysShowSearchResultsAsList { if !self.alwaysShowSearchResultsAsList {
self.chatDisplayNode.loadInputPanels(theme: self.presentationInterfaceState.theme, strings: self.presentationInterfaceState.strings, fontSize: self.presentationInterfaceState.fontSize) self.chatDisplayNode.loadInputPanels(theme: self.presentationInterfaceState.theme, strings: self.presentationInterfaceState.strings, fontSize: self.presentationInterfaceState.fontSize)
@ -9798,6 +9799,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.currentChatSwitchDirection = animationDirection self.currentChatSwitchDirection = animationDirection
self.chatLocation = updatedChatLocation self.chatLocation = updatedChatLocation
historyNode.areContentAnimationsEnabled = true
self.chatDisplayNode.prepareSwitchToChatLocation(historyNode: historyNode, animationDirection: animationDirection) self.chatDisplayNode.prepareSwitchToChatLocation(historyNode: historyNode, animationDirection: animationDirection)
apply(true) apply(true)

View File

@ -2061,7 +2061,10 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
} }
if immediatelyLayoutLeftPanelNodeAndAnimateAppearance || dismissedLeftPanel != nil || immediatelyLayoutTitleTopicsAccessoryPanelNodeAndAnimateAppearance || dismissedTitleTopicsAccessoryPanelNode != nil { if immediatelyLayoutLeftPanelNodeAndAnimateAppearance || dismissedLeftPanel != nil || immediatelyLayoutTitleTopicsAccessoryPanelNodeAndAnimateAppearance || dismissedTitleTopicsAccessoryPanelNode != nil {
self.historyNode.resetScrolledToItem() if transition.isAnimated {
self.historyNode.resetScrolledToItem()
self.historyNode.enableUnreadAlignment = false
}
} }
if let blurredHistoryNode = self.blurredHistoryNode { if let blurredHistoryNode = self.blurredHistoryNode {

View File

@ -478,7 +478,8 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
var messageTransitionNode: () -> ChatMessageTransitionNodeImpl? var messageTransitionNode: () -> ChatMessageTransitionNodeImpl?
private let mode: ChatHistoryListMode private let mode: ChatHistoryListMode
private var enableUnreadAlignment: Bool = true var enableUnreadAlignment: Bool = true
var areContentAnimationsEnabled: Bool = false
private var historyView: ChatHistoryView? private var historyView: ChatHistoryView?
public var originalHistoryView: MessageHistoryView? { public var originalHistoryView: MessageHistoryView? {
@ -2077,6 +2078,12 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
var disableAnimations = false var disableAnimations = false
var forceSynchronous = false var forceSynchronous = false
if let strongSelf = self {
if !strongSelf.areContentAnimationsEnabled {
disableAnimations = true
}
}
if switchedToAnotherSource { if switchedToAnotherSource {
disableAnimations = true disableAnimations = true
} }

View File

@ -230,26 +230,28 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
} }
func titleTopicsPanelForChatPresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentPanel: ChatTitleAccessoryPanelNode?, controllerInteraction: ChatControllerInteraction?, interfaceInteraction: ChatPanelInterfaceInteraction?, force: Bool) -> ChatTopicListTitleAccessoryPanelNode? { func titleTopicsPanelForChatPresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentPanel: ChatTitleAccessoryPanelNode?, controllerInteraction: ChatControllerInteraction?, interfaceInteraction: ChatPanelInterfaceInteraction?, force: Bool) -> ChatTopicListTitleAccessoryPanelNode? {
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum, let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = chatPresentationInterfaceState.renderedPeer?.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.sendSomething), chatPresentationInterfaceState.search == nil { if !(chatPresentationInterfaceState.subject?.isService ?? false) {
let topicListDisplayModeOnTheSide = chatPresentationInterfaceState.persistentData.topicListPanelLocation if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum, let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = chatPresentationInterfaceState.renderedPeer?.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.sendSomething), chatPresentationInterfaceState.search == nil {
if !topicListDisplayModeOnTheSide, let peerId = chatPresentationInterfaceState.chatLocation.peerId { let topicListDisplayModeOnTheSide = chatPresentationInterfaceState.persistentData.topicListPanelLocation
if let currentPanel = currentPanel as? ChatTopicListTitleAccessoryPanelNode { if !topicListDisplayModeOnTheSide, let peerId = chatPresentationInterfaceState.chatLocation.peerId {
return currentPanel if let currentPanel = currentPanel as? ChatTopicListTitleAccessoryPanelNode {
} else { return currentPanel
let panel = ChatTopicListTitleAccessoryPanelNode(context: context, peerId: peerId, isMonoforum: true) } else {
panel.interfaceInteraction = interfaceInteraction let panel = ChatTopicListTitleAccessoryPanelNode(context: context, peerId: peerId, isMonoforum: true)
return panel panel.interfaceInteraction = interfaceInteraction
return panel
}
} }
} } else if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForum, (channel.flags.contains(.displayForumAsTabs) || context.sharedContext.immediateExperimentalUISettings.allForumsHaveTabs), chatPresentationInterfaceState.search == nil {
} else if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForum, (channel.flags.contains(.displayForumAsTabs) || context.sharedContext.immediateExperimentalUISettings.allForumsHaveTabs), chatPresentationInterfaceState.search == nil { let topicListDisplayModeOnTheSide = chatPresentationInterfaceState.persistentData.topicListPanelLocation
let topicListDisplayModeOnTheSide = chatPresentationInterfaceState.persistentData.topicListPanelLocation if !topicListDisplayModeOnTheSide, let peerId = chatPresentationInterfaceState.chatLocation.peerId {
if !topicListDisplayModeOnTheSide, let peerId = chatPresentationInterfaceState.chatLocation.peerId { if let currentPanel = currentPanel as? ChatTopicListTitleAccessoryPanelNode {
if let currentPanel = currentPanel as? ChatTopicListTitleAccessoryPanelNode { return currentPanel
return currentPanel } else {
} else { let panel = ChatTopicListTitleAccessoryPanelNode(context: context, peerId: peerId, isMonoforum: false)
let panel = ChatTopicListTitleAccessoryPanelNode(context: context, peerId: peerId, isMonoforum: false) panel.interfaceInteraction = interfaceInteraction
panel.interfaceInteraction = interfaceInteraction return panel
return panel }
} }
} }
} }
@ -262,6 +264,10 @@ func sidePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceState
return nil return nil
} }
if chatPresentationInterfaceState.subject?.isService ?? false {
return nil
}
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isMonoForum, let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = chatPresentationInterfaceState.renderedPeer?.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.sendSomething), chatPresentationInterfaceState.search == nil { if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isMonoForum, let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = chatPresentationInterfaceState.renderedPeer?.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.sendSomething), chatPresentationInterfaceState.search == nil {
let topicListDisplayModeOnTheSide = chatPresentationInterfaceState.persistentData.topicListPanelLocation let topicListDisplayModeOnTheSide = chatPresentationInterfaceState.persistentData.topicListPanelLocation
if topicListDisplayModeOnTheSide { if topicListDisplayModeOnTheSide {