[WIP] Monoforums

This commit is contained in:
Isaac
2025-05-05 18:02:50 +02:00
parent 65a0b41071
commit cbb09e4780
20 changed files with 4306 additions and 2108 deletions

View File

@@ -4,6 +4,8 @@ import TelegramCore
import AccountContext
import ChatPresentationInterfaceState
import ChatControllerInteraction
import ComponentFlow
import ChatSideTopicsPanel
func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentPanel: ChatTitleAccessoryPanelNode?, controllerInteraction: ChatControllerInteraction?, interfaceInteraction: ChatPanelInterfaceInteraction?, force: Bool) -> ChatTitleAccessoryPanelNode? {
if !force, case .standard(.embedded) = chatPresentationInterfaceState.mode {
@@ -108,7 +110,6 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
}
}
if let _ = chatPresentationInterfaceState.peerVerification {
if let currentPanel = currentPanel as? ChatVerifiedPeerTitlePanelNode {
return currentPanel
@@ -166,6 +167,19 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
}
}
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
let topicListDisplayMode = chatPresentationInterfaceState.topicListDisplayMode ?? .top
if case .top = topicListDisplayMode, let peerId = chatPresentationInterfaceState.chatLocation.peerId {
if let currentPanel = currentPanel as? ChatTopicListTitleAccessoryPanelNode {
return currentPanel
} else {
let panel = ChatTopicListTitleAccessoryPanelNode(context: context, peerId: peerId)
panel.interfaceInteraction = interfaceInteraction
return panel
}
}
}
if (selectedContext == nil || selectedContext! <= .pinnedMessage) {
if displayActionsPanel {
if let currentPanel = currentPanel as? ChatReportPeerTitlePanelNode {
@@ -231,3 +245,34 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
return nil
}
func sidePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentPanel: AnyComponentWithIdentity<ChatSidePanelEnvironment>?, controllerInteraction: ChatControllerInteraction?, interfaceInteraction: ChatPanelInterfaceInteraction?, force: Bool) -> AnyComponentWithIdentity<ChatSidePanelEnvironment>? {
guard let peerId = chatPresentationInterfaceState.chatLocation.peerId else {
return nil
}
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
let topicListDisplayMode = chatPresentationInterfaceState.topicListDisplayMode ?? .top
if case .side = topicListDisplayMode {
return AnyComponentWithIdentity(
id: "topics",
component: AnyComponent(ChatSideTopicsPanel(
context: context,
theme: chatPresentationInterfaceState.theme,
strings: chatPresentationInterfaceState.strings,
peerId: peerId,
topicId: chatPresentationInterfaceState.chatLocation.threadId,
togglePanel: { [weak interfaceInteraction] in
interfaceInteraction?.toggleChatSidebarMode()
},
updateTopicId: { [weak interfaceInteraction] topicId in
interfaceInteraction?.updateChatLocationThread(topicId)
}
))
)
}
}
return nil
}