From 66ce61e75697bed9598479d3f43ea1f30fab1200 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 27 May 2025 21:51:30 +0800 Subject: [PATCH] Monoforums --- .../Sources/NotificationService.swift | 12 ++++++++++-- .../Sources/ChatListSearchListPaneNode.swift | 12 +++++++++++- .../Sources/AsyncListComponent.swift | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Telegram/NotificationService/Sources/NotificationService.swift b/Telegram/NotificationService/Sources/NotificationService.swift index 8c92b1ef94..deb4e1a3e9 100644 --- a/Telegram/NotificationService/Sources/NotificationService.swift +++ b/Telegram/NotificationService/Sources/NotificationService.swift @@ -1712,7 +1712,11 @@ private final class NotificationServiceHandler { var content = initialContent if let interactionAuthorId = interactionAuthorId { - if inAppNotificationSettings.displayNameOnLockscreen, let peer = transaction.getPeer(interactionAuthorId) { + if inAppNotificationSettings.displayNameOnLockscreen, var peer = transaction.getPeer(interactionAuthorId) { + if let channel = peer as? TelegramChannel, channel.isMonoForum, let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = transaction.getPeer(linkedMonoforumId) { + peer = mainChannel + } + var foundLocalId: String? transaction.enumerateDeviceContactImportInfoItems({ _, value in if let value = value as? TelegramDeviceContactImportedData { @@ -2026,7 +2030,11 @@ private final class NotificationServiceHandler { var content = initialContent if let interactionAuthorId = interactionAuthorId { - if inAppNotificationSettings.displayNameOnLockscreen, let peer = transaction.getPeer(interactionAuthorId) { + if inAppNotificationSettings.displayNameOnLockscreen, var peer = transaction.getPeer(interactionAuthorId) { + if let channel = peer as? TelegramChannel, channel.isMonoForum, let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = transaction.getPeer(linkedMonoforumId) { + peer = mainChannel + } + var foundLocalId: String? transaction.enumerateDeviceContactImportInfoItems({ _, value in if let value = value as? TelegramDeviceContactImportedData { diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 92eaa12538..fd486ba5c7 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -2990,6 +2990,8 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { var associatedPeer: EnginePeer? if case let .secretChat(secretChat) = peer, let associatedPeerId = secretChat.associatedPeerId { associatedPeer = renderedPeer.peers[associatedPeerId] + } else if case let .channel(channel) = peer, channel.isMonoForum { + associatedPeer = renderedPeer.chatOrMonoforumMainPeer } entries.append(.recentlySearchedPeer(peer, associatedPeer, foundLocalPeers.unread[peer.id], index, presentationData.theme, presentationData.strings, presentationData.nameSortOrder, presentationData.nameDisplayOrder, nil, false)) @@ -3001,8 +3003,13 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { if lowercasedQuery.count > 1 { for peer in recentPeers { + let renderedPeer = peer if let peer = peer.peer.chatMainPeer, !existingPeerIds.contains(peer.id) { let peer = EnginePeer(peer) + var associatedPeer: EnginePeer? + if case let .channel(channel) = peer, channel.isMonoForum { + associatedPeer = renderedPeer.peer.chatOrMonoforumMainPeer.flatMap(EnginePeer.init) + } var matches = false if case let .user(user) = peer { @@ -3017,7 +3024,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { if matches { existingPeerIds.insert(peer.id) - entries.append(.localPeer(peer, nil, nil, index, presentationData.theme, presentationData.strings, presentationData.nameSortOrder, presentationData.nameDisplayOrder, localExpandType, nil, false, false)) + entries.append(.localPeer(peer, associatedPeer, nil, index, presentationData.theme, presentationData.strings, presentationData.nameSortOrder, presentationData.nameDisplayOrder, localExpandType, nil, false, false)) } } } @@ -3038,6 +3045,8 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { var associatedPeer: EnginePeer? if case let .secretChat(secretChat) = peer, let associatedPeerId = secretChat.associatedPeerId { associatedPeer = renderedPeer.peers[associatedPeerId] + } else if case let .channel(channel) = peer, channel.isMonoForum { + associatedPeer = renderedPeer.chatOrMonoforumMainPeer } entries.append(.localPeer(peer, associatedPeer, foundLocalPeers.unread[peer.id], index, presentationData.theme, presentationData.strings, presentationData.nameSortOrder, presentationData.nameDisplayOrder, localExpandType, nil, false, false)) @@ -3081,6 +3090,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { if !existingPeerIds.contains(peer.peer.id), filteredPeer(EnginePeer(peer.peer), EnginePeer(accountPeer)) { existingPeerIds.insert(peer.peer.id) + entries.append(.globalPeer(peer, nil, index, presentationData.theme, presentationData.strings, presentationData.nameSortOrder, presentationData.nameDisplayOrder, globalExpandType, nil, false, finalQuery)) index += 1 numberOfGlobalPeers += 1 diff --git a/submodules/TelegramUI/Components/AsyncListComponent/Sources/AsyncListComponent.swift b/submodules/TelegramUI/Components/AsyncListComponent/Sources/AsyncListComponent.swift index 39f4764599..bafe1552f6 100644 --- a/submodules/TelegramUI/Components/AsyncListComponent/Sources/AsyncListComponent.swift +++ b/submodules/TelegramUI/Components/AsyncListComponent/Sources/AsyncListComponent.swift @@ -335,6 +335,8 @@ public final class AsyncListComponent: Component { super.init(layerBacked: false, dynamicBounce: false, rotated: false, seeThrough: false) self.view.addSubview(self.contentContainer) + + self.scrollPositioningInsets = UIEdgeInsets(top: -24.0, left: 0.0, bottom: -24.0, right: 0.0) } deinit {