[WIP] Monoforums

This commit is contained in:
Isaac 2025-05-08 20:56:55 +01:00
parent 2bd66ced8c
commit 0e119dd6f1
85 changed files with 387 additions and 243 deletions

View File

@ -1309,7 +1309,7 @@ private func mapPeersToFriends(accountId: AccountRecordId, accountPeerId: PeerId
var profileImage: INImage?
var isForum = false
if let peer = peer as? TelegramChannel, peer.flags.contains(.isForum) {
if let peer = peer as? TelegramChannel, peer.isForumOrMonoForum {
isForum = true
}

View File

@ -178,7 +178,7 @@ private func getCommonTimeline(friends: [Friend]?, in context: TimelineProviderC
}
var isForum = false
if let peer = peer as? TelegramChannel, peer.flags.contains(.isForum) {
if let peer = peer as? TelegramChannel, peer.isForumOrMonoForum {
isForum = true
}

View File

@ -110,7 +110,7 @@ public func peerAvatarCompleteImage(postbox: Postbox, network: Network, peer: En
let clipStyle: AvatarNodeClipStyle
if round {
if case let .channel(channel) = peer, channel.isForum {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -195,7 +195,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
}
var isForum = false
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
isForum = true
}

View File

@ -1073,7 +1073,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
}
if openAsInlineForum, case let .channel(channel) = peer, channel.flags.contains(.isForum), threadId == nil {
if openAsInlineForum, case let .channel(channel) = peer, channel.isForum, threadId == nil {
self.chatListDisplayNode.clearHighlightAnimated(true)
if self.chatListDisplayNode.inlineStackContainerNode?.location == .forum(peerId: channel.id) {
self.setInlineChatList(location: nil)
@ -1083,7 +1083,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
return
}
if case let .channel(channel) = peer, channel.flags.contains(.isForum), let threadId {
if case let .channel(channel) = peer, channel.isForumOrMonoForum, let threadId {
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
navigationController: navigationController,
context: self.context,
@ -1093,7 +1093,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
channelMessageId: nil,
isChannelPost: false,
isForumPost: true,
isMonoforum: channel.flags.contains(.isMonoforum),
isMonoforumPost: channel.isMonoForum,
maxMessage: nil,
maxReadIncomingMessageId: nil,
maxReadOutgoingMessageId: nil,
@ -1344,7 +1344,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
if case .chatList(.root) = strongSelf.location {
navigationAnimationOptions = .removeOnMasterDetails
}
if case let .channel(channel) = actualPeer, channel.flags.contains(.isForum), let threadId {
if case let .channel(channel) = actualPeer, channel.isForumOrMonoForum, let threadId {
let _ = strongSelf.context.sharedContext.navigateToForumThread(context: strongSelf.context, peerId: peer.id, threadId: threadId, messageId: messageId, navigationController: navigationController, activateInput: nil, scrollToEndIfExists: false, keepStack: .never).startStandalone()
} else {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(actualPeer), subject: .message(id: .id(messageId), highlight: ChatControllerSubject.MessageHighlight(quote: nil), timecode: nil, setupReply: false), purposefulAction: {
@ -1377,7 +1377,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
if case .chatList(.root) = strongSelf.location {
navigationAnimationOptions = .removeOnMasterDetails
}
if case let .channel(channel) = peer, channel.flags.contains(.isForum), let threadId {
if case let .channel(channel) = peer, channel.isForumOrMonoForum, let threadId {
let _ = strongSelf.context.sharedContext.navigateToForumThread(context: strongSelf.context, peerId: peer.id, threadId: threadId, messageId: nil, navigationController: navigationController, activateInput: nil, scrollToEndIfExists: false, keepStack: .never).startStandalone()
} else {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer), purposefulAction: { [weak self] in
@ -1515,11 +1515,11 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
switch item.index {
case .chatList:
if case let .channel(channel) = peer.peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer.peer, channel.isForumOrMonoForum {
if let threadId = threadId {
let source: ContextContentSource
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .replyThread(message: ChatReplyThreadMessage(
peerId: peer.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
peerId: peer.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
)), subject: nil, botStart: nil, mode: .standard(.previewing), params: nil)
chatController.canReadHistory.set(false)
source = .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController))
@ -1588,7 +1588,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
let source: ContextContentSource
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .replyThread(message: ChatReplyThreadMessage(
peerId: peer.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
peerId: peer.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
)), subject: nil, botStart: nil, mode: .standard(.previewing), params: nil)
chatController.canReadHistory.set(false)
source = .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController))
@ -1625,7 +1625,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
return
}
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
let chatListController = ChatListControllerImpl(context: strongSelf.context, location: .forum(peerId: channel.id), controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: false)
chatListController.navigationPresentation = .master
let contextController = ContextController(presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.id, promoInfo: nil, source: .search(source), chatListController: strongSelf, joined: false) |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
@ -7163,7 +7163,7 @@ private final class ChatListLocationContext {
self.ready.set(.single(true))
}
if let channel = peerView.peers[peerView.peerId] as? TelegramChannel, !channel.flags.contains(.isForum) {
if let channel = peerView.peers[peerView.peerId] as? TelegramChannel, !channel.isForumOrMonoForum {
if let parentController = self.parentController, let navigationController = parentController.navigationController as? NavigationController {
let chatController = self.context.sharedContext.makeChatController(context: self.context, chatLocation: .peer(id: peerId), subject: nil, botStart: nil, mode: .standard(.default), params: nil)
navigationController.replaceController(parentController, with: chatController, animated: true)

View File

@ -536,7 +536,7 @@ public class ChatListItem: ListViewItem, ChatListSearchItemNeighbour {
if case let .forum(_, _, threadIdValue, _, _) = self.index {
threadId = threadIdValue
}
if threadId == nil, self.interaction.searchTextHighightState != nil, case let .channel(channel) = peerData.peer.peer, channel.flags.contains(.isForum) {
if threadId == nil, self.interaction.searchTextHighightState != nil, case let .channel(channel) = peerData.peer.peer, channel.isForumOrMonoForum {
threadId = message.threadId
}
self.interaction.messageSelected(peer, threadId, message, peerData.promoInfo)
@ -768,7 +768,7 @@ private func leftRevealOptions(strings: PresentationStrings, theme: Presentation
options.append(ItemListRevealOption(key: RevealOptionKey.toggleMarkedUnread.rawValue, title: strings.DialogList_Read, icon: readIcon, color: theme.list.itemDisclosureActions.inactive.fillColor, textColor: theme.list.itemDisclosureActions.neutral1.foregroundColor))
} else {
var canMarkUnread = true
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
canMarkUnread = false
}
@ -1726,7 +1726,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
overrideImage = .deletedIcon
}
var isForumAvatar = false
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
isForumAvatar = true
}
if case let .peer(data) = item.content {
@ -2392,7 +2392,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
}
}
if let _ = peerText, case let .channel(channel) = itemPeer.chatMainPeer, channel.flags.contains(.isForum), threadInfo == nil {
if let _ = peerText, case let .channel(channel) = itemPeer.chatMainPeer, channel.isForumOrMonoForum, threadInfo == nil {
if let forumTopicData = forumTopicData {
forumThread = (forumTopicData.id, forumTopicData.title, forumTopicData.iconFileId, forumTopicData.iconColor, forumTopicData.isUnread)
} else if let threadInfo = threadInfo {

View File

@ -598,7 +598,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
}
var isForum = false
if let peer = chatPeer, case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if let peer = chatPeer, case let .channel(channel) = peer, channel.isForumOrMonoForum {
isForum = true
if editing, case .chatList = mode {
enabled = false
@ -948,7 +948,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
}
var isForum = false
if let peer = chatPeer, case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if let peer = chatPeer, case let .channel(channel) = peer, channel.isForumOrMonoForum {
isForum = true
if editing, case .chatList = mode {
enabled = false
@ -2987,7 +2987,7 @@ public final class ChatListNode: ListView {
guard case .global = chatPeerId.category else {
continue
}
if case let .channel(channel) = peerMap[chatPeerId.peerId], channel.flags.contains(.isForum) {
if case let .channel(channel) = peerMap[chatPeerId.peerId], channel.isForumOrMonoForum {
continue
}
itemId = ChatListNodePeerInputActivities.ItemId(peerId: chatPeerId.peerId, threadId: nil)

View File

@ -1227,7 +1227,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
if case .app(true) = item.peerMode {
clipStyle = .roundedRect
displayDimensions = CGSize(width: displayDimensions.width, height: displayDimensions.width * 1.2)
} else if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
} else if case let .channel(channel) = peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -1721,7 +1721,7 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
strongSelf.avatarNode.imageNode.animateFirstTransition = item.animateFirstAvatarTransition
var clipStyle: AvatarNodeClipStyle = .round
if case let .channel(channel) = item.peer, channel.isForum {
if case let .channel(channel) = item.peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
}

View File

@ -556,7 +556,7 @@ public class ItemListDisclosureItemNode: ListViewItemNode, ItemListItemNode {
let avatarSize: CGFloat = 40.0
avatarNode.frame = CGRect(origin: CGPoint(x: params.leftInset + floor((leftInset - params.leftInset - avatarSize) / 2.0), y: floor((height - avatarSize) / 2.0)), size: CGSize(width: avatarSize, height: avatarSize))
var clipStyle: AvatarNodeClipStyle = .round
if case let .channel(channel) = iconPeer, channel.flags.contains(.isForum) {
if case let .channel(channel) = iconPeer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
}
var overrideImage: AvatarNodeImageOverride?

View File

@ -203,7 +203,7 @@ public final class SelectablePeerNode: ASDisplayNode {
}
var isForum = false
if let peer = peer.chatMainPeer, case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if let peer = peer.chatMainPeer, case let .channel(channel) = peer, channel.isForumOrMonoForum {
isForum = true
}
@ -375,7 +375,7 @@ public final class SelectablePeerNode: ASDisplayNode {
}
var isForum = false
if let peer = self.peer?.chatMainPeer, case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if let peer = self.peer?.chatMainPeer, case let .channel(channel) = peer, channel.isForumOrMonoForum {
isForum = true
}

View File

@ -576,7 +576,7 @@ final class ShareControllerNode: ViewControllerTracingNode, ASScrollViewDelegate
strongSelf.controllerInteraction!.selectedPeerIds.remove(peer.peerId)
strongSelf.controllerInteraction!.selectedPeers = strongSelf.controllerInteraction!.selectedPeers.filter({ $0.peerId != peer.peerId })
} else {
if case let .channel(channel) = peer.peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer.peer, channel.isForumOrMonoForum {
if strongSelf.controllerInteraction!.selectedTopics[peer.peerId] != nil {
strongSelf.controllerInteraction!.selectedTopics[peer.peerId] = nil
strongSelf.peersContentNode?.update()

View File

@ -465,7 +465,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1877932953] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowUsers($0) }
dict[609840449] = { return Api.InputQuickReplyShortcut.parse_inputQuickReplyShortcut($0) }
dict[18418929] = { return Api.InputQuickReplyShortcut.parse_inputQuickReplyShortcutId($0) }
dict[583071445] = { return Api.InputReplyTo.parse_inputReplyToMessage($0) }
dict[-1334822736] = { return Api.InputReplyTo.parse_inputReplyToMessage($0) }
dict[1775660101] = { return Api.InputReplyTo.parse_inputReplyToMonoForum($0) }
dict[1484862010] = { return Api.InputReplyTo.parse_inputReplyToStory($0) }
dict[-251549057] = { return Api.InputSavedStarGift.parse_inputSavedStarGiftChat($0) }
dict[545636920] = { return Api.InputSavedStarGift.parse_inputSavedStarGiftSlug($0) }

View File

@ -272,14 +272,15 @@ public extension Api {
}
public extension Api {
indirect enum InputReplyTo: TypeConstructorDescription {
case inputReplyToMessage(flags: Int32, replyToMsgId: Int32, topMsgId: Int32?, replyToPeerId: Api.InputPeer?, quoteText: String?, quoteEntities: [Api.MessageEntity]?, quoteOffset: Int32?)
case inputReplyToMessage(flags: Int32, replyToMsgId: Int32, topMsgId: Int32?, replyToPeerId: Api.InputPeer?, quoteText: String?, quoteEntities: [Api.MessageEntity]?, quoteOffset: Int32?, monoforumPeerId: Api.InputPeer?)
case inputReplyToMonoForum(monoforumPeerId: Api.InputPeer)
case inputReplyToStory(peer: Api.InputPeer, storyId: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .inputReplyToMessage(let flags, let replyToMsgId, let topMsgId, let replyToPeerId, let quoteText, let quoteEntities, let quoteOffset):
case .inputReplyToMessage(let flags, let replyToMsgId, let topMsgId, let replyToPeerId, let quoteText, let quoteEntities, let quoteOffset, let monoforumPeerId):
if boxed {
buffer.appendInt32(583071445)
buffer.appendInt32(-1334822736)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(replyToMsgId, buffer: buffer, boxed: false)
@ -292,6 +293,13 @@ public extension Api {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 4) != 0 {serializeInt32(quoteOffset!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 5) != 0 {monoforumPeerId!.serialize(buffer, true)}
break
case .inputReplyToMonoForum(let monoforumPeerId):
if boxed {
buffer.appendInt32(1775660101)
}
monoforumPeerId.serialize(buffer, true)
break
case .inputReplyToStory(let peer, let storyId):
if boxed {
@ -305,8 +313,10 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .inputReplyToMessage(let flags, let replyToMsgId, let topMsgId, let replyToPeerId, let quoteText, let quoteEntities, let quoteOffset):
return ("inputReplyToMessage", [("flags", flags as Any), ("replyToMsgId", replyToMsgId as Any), ("topMsgId", topMsgId as Any), ("replyToPeerId", replyToPeerId as Any), ("quoteText", quoteText as Any), ("quoteEntities", quoteEntities as Any), ("quoteOffset", quoteOffset as Any)])
case .inputReplyToMessage(let flags, let replyToMsgId, let topMsgId, let replyToPeerId, let quoteText, let quoteEntities, let quoteOffset, let monoforumPeerId):
return ("inputReplyToMessage", [("flags", flags as Any), ("replyToMsgId", replyToMsgId as Any), ("topMsgId", topMsgId as Any), ("replyToPeerId", replyToPeerId as Any), ("quoteText", quoteText as Any), ("quoteEntities", quoteEntities as Any), ("quoteOffset", quoteOffset as Any), ("monoforumPeerId", monoforumPeerId as Any)])
case .inputReplyToMonoForum(let monoforumPeerId):
return ("inputReplyToMonoForum", [("monoforumPeerId", monoforumPeerId as Any)])
case .inputReplyToStory(let peer, let storyId):
return ("inputReplyToStory", [("peer", peer as Any), ("storyId", storyId as Any)])
}
@ -331,6 +341,10 @@ public extension Api {
} }
var _7: Int32?
if Int(_1!) & Int(1 << 4) != 0 {_7 = reader.readInt32() }
var _8: Api.InputPeer?
if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.InputPeer
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
@ -338,8 +352,22 @@ public extension Api {
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.InputReplyTo.inputReplyToMessage(flags: _1!, replyToMsgId: _2!, topMsgId: _3, replyToPeerId: _4, quoteText: _5, quoteEntities: _6, quoteOffset: _7)
let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.InputReplyTo.inputReplyToMessage(flags: _1!, replyToMsgId: _2!, topMsgId: _3, replyToPeerId: _4, quoteText: _5, quoteEntities: _6, quoteOffset: _7, monoforumPeerId: _8)
}
else {
return nil
}
}
public static func parse_inputReplyToMonoForum(_ reader: BufferReader) -> InputReplyTo? {
var _1: Api.InputPeer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.InputPeer
}
let _c1 = _1 != nil
if _c1 {
return Api.InputReplyTo.inputReplyToMonoForum(monoforumPeerId: _1!)
}
else {
return nil

View File

@ -144,7 +144,7 @@ final class VideoChatExpandedSpeakingToastComponent: Component {
let avatarSize = CGSize(width: avatarWidth, height: avatarWidth)
let clipStyle: AvatarNodeClipStyle
if case let .channel(channel) = component.peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = component.peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -247,7 +247,7 @@ final class VideoChatParticipantAvatarComponent: Component {
let avatarSize = availableSize
let clipStyle: AvatarNodeClipStyle
if case let .channel(channel) = component.peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = component.peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -476,7 +476,7 @@ struct AccountMutableState {
return peer.isForum
} else if let chat = self.apiChats[peerId] {
if let channel = parseTelegramGroupOrChannel(chat: chat) {
return channel.isForum
return channel.isForumOrMonoForum
} else {
return false
}

View File

@ -211,7 +211,7 @@ private func requestEditMessageInternal(accountPeerId: PeerId, postbox: Postbox,
if let result = result {
return postbox.transaction { transaction -> RequestEditMessageResult in
var toMedia: Media?
if let message = result.messages.first.flatMap({ StoreMessage(apiMessage: $0, accountPeerId: accountPeerId, peerIsForum: peer.isForum) }) {
if let message = result.messages.first.flatMap({ StoreMessage(apiMessage: $0, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum) }) {
toMedia = message.media.first
}
@ -227,7 +227,7 @@ private func requestEditMessageInternal(accountPeerId: PeerId, postbox: Postbox,
let peers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: peers)
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum), case let .Id(id) = message.id {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum), case let .Id(id) = message.id {
transaction.updateMessage(id, update: { previousMessage in
var updatedFlags = message.flags
var updatedLocalTags = message.localTags

View File

@ -324,8 +324,18 @@ private func sendUploadedMessageContent(
var uniqueId: Int64 = 0
var forwardSourceInfoAttribute: ForwardSourceInfoAttribute?
var messageEntities: [Api.MessageEntity]?
var replyMessageId: Int32? = threadId.flatMap { threadId in
return Int32(clamping: threadId)
var replyMessageId: Int32?
var topMsgId: Int32?
var monoforumPeerId: Api.InputPeer?
if let threadId {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isMonoforum) {
if let monoforumTargetPeer = transaction.getPeer(PeerId(threadId)) {
monoforumPeerId = apiInputPeer(monoforumTargetPeer)
}
} else {
replyMessageId = Int32(clamping: threadId)
topMsgId = Int32(clamping: threadId)
}
}
var replyToStoryId: StoryId?
var scheduleTime: Int32?
@ -412,19 +422,24 @@ private func sendUploadedMessageContent(
}
var replyTo: Api.InputReplyTo?
if let replyMessageId = replyMessageId {
if let replyMessageId {
flags |= 1 << 0
var replyFlags: Int32 = 0
if threadId != nil {
if topMsgId != nil {
replyFlags |= 1 << 0
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: threadId.flatMap(Int32.init(clamping:)), replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
} else if let replyToStoryId = replyToStoryId {
if monoforumPeerId != nil {
replyFlags |= 1 << 5
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId)
} else if let replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
}
} else if let monoforumPeerId {
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
sendMessageRequest = network.requestWithAdditionalInfo(Api.functions.messages.sendMessage(flags: flags, peer: inputPeer, replyTo: replyTo, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer, quickReplyShortcut: nil, effect: nil, allowPaidStars: allowPaidStars), info: .acknowledgement, tag: dependencyTag)
@ -438,10 +453,13 @@ private func sendUploadedMessageContent(
flags |= 1 << 0
var replyFlags: Int32 = 0
if threadId != nil {
if topMsgId != nil {
replyFlags |= 1 << 0
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: threadId.flatMap(Int32.init(clamping:)), replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
if monoforumPeerId != nil {
replyFlags |= 1 << 5
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
@ -452,10 +470,8 @@ private func sendUploadedMessageContent(
sendMessageRequest = network.request(Api.functions.messages.sendMedia(flags: flags, peer: inputPeer, replyTo: replyTo, media: inputMedia, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer, quickReplyShortcut: nil, effect: nil, allowPaidStars: allowPaidStars), tag: dependencyTag)
|> map(NetworkRequestResult.result)
case let .forward(sourceInfo):
var topMsgId: Int32?
if let threadId = threadId {
if topMsgId != nil {
flags |= Int32(1 << 9)
topMsgId = Int32(clamping: threadId)
}
if let forwardSourceInfoAttribute = forwardSourceInfoAttribute, let sourcePeer = transaction.getPeer(forwardSourceInfoAttribute.messageId.peerId), let sourceInputPeer = apiInputPeer(sourcePeer) {
@ -474,10 +490,13 @@ private func sendUploadedMessageContent(
flags |= 1 << 0
var replyFlags: Int32 = 0
if threadId != nil {
if topMsgId != nil {
replyFlags |= 1 << 0
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: threadId.flatMap(Int32.init(clamping:)), replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
if monoforumPeerId != nil {
replyFlags |= 1 << 5
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
@ -492,18 +511,18 @@ private func sendUploadedMessageContent(
if let replyMessageId = replyMessageId {
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
} else {
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
}
} else {
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
}
sendMessageRequest = network.request(Api.functions.messages.sendScreenshotNotification(peer: inputPeer, replyTo: replyTo, randomId: uniqueId))
@ -641,7 +660,6 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M
flags |= 1 << 21
}
let sendMessageRequest: Signal<Api.Updates, NoError>
switch content {
case let .text(text):
@ -650,7 +668,7 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M
flags |= 1 << 0
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
@ -658,7 +676,7 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M
}
} else if let threadId {
flags |= 1 << 0
replyTo = .inputReplyToMessage(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
}
sendMessageRequest = account.network.request(Api.functions.messages.sendMessage(flags: flags, peer: inputPeer, replyTo: replyTo, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer, quickReplyShortcut: nil, effect: nil, allowPaidStars: allowPaidStars))
@ -671,7 +689,7 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M
flags |= 1 << 0
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
@ -679,7 +697,7 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M
}
} else if let threadId {
flags |= 1 << 0
replyTo = .inputReplyToMessage(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
}
sendMessageRequest = account.network.request(Api.functions.messages.sendMedia(flags: flags, peer: inputPeer, replyTo: replyTo, media: inputMedia, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer, quickReplyShortcut: nil, effect: nil, allowPaidStars: allowPaidStars))

View File

@ -1571,10 +1571,11 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
case let .draftMessage(_, replyToMsgHeader, message, entities, media, date, messageEffectId):
let _ = media
var replySubject: EngineMessageReplySubject?
if let replyToMsgHeader = replyToMsgHeader {
if let replyToMsgHeader {
switch replyToMsgHeader {
case let .inputReplyToMessage(_, replyToMsgId, topMsgId, replyToPeerId, quoteText, quoteEntities, quoteOffset):
case let .inputReplyToMessage(_, replyToMsgId, topMsgId, replyToPeerId, quoteText, quoteEntities, quoteOffset, monoforumPeerId):
let _ = topMsgId
let _ = monoforumPeerId
var quote: EngineMessageReplyQuote?
if let quoteText = quoteText {
@ -1612,6 +1613,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
)
case .inputReplyToStory:
break
case .inputReplyToMonoForum:
break
}
}
inputState = SynchronizeableChatInputState(replySubject: replySubject, text: message, entities: messageTextEntitiesFromApiEntities(entities ?? []), timestamp: date, textSelection: nil, messageEffectId: messageEffectId)
@ -1926,11 +1929,13 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, network: Netwo
case let .AddMessages(messages, _):
for message in messages {
if let threadId = message.threadId {
if let channel = state.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info, channel.flags.contains(.isForum) {
if let channel = state.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info {
if channel.flags.contains(.isForum) {
forumThreadIds.insert(MessageId(peerId: message.id.peerId, namespace: message.id.namespace, id: Int32(clamping: threadId)))
}
}
}
}
default:
break
}

View File

@ -125,7 +125,7 @@ private func fetchWebpage(account: Account, messageId: MessageId, threadId: Int6
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
for message in messages {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum, namespace: targetMessageNamespace) {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum, namespace: targetMessageNamespace) {
var webpage: TelegramMediaWebpage?
for media in storeMessage.media {
if let media = media as? TelegramMediaWebpage {
@ -1110,7 +1110,7 @@ public final class AccountViewTracker {
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
for message in messages {
guard let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForum) else {
guard let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForumOrMonoForum) else {
continue
}
guard case let .Id(id) = storeMessage.id else {

View File

@ -145,7 +145,7 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
namespace = Namespaces.Message.ScheduledCloud
}
if let apiMessage = apiMessage, let apiMessagePeerId = apiMessage.peerId, let updatedMessage = StoreMessage(apiMessage: apiMessage, accountPeerId: accountPeerId, peerIsForum: transaction.getPeer(apiMessagePeerId)?.isForum ?? false, namespace: namespace) {
if let apiMessage = apiMessage, let apiMessagePeerId = apiMessage.peerId, let updatedMessage = StoreMessage(apiMessage: apiMessage, accountPeerId: accountPeerId, peerIsForum: transaction.getPeer(apiMessagePeerId)?.isForumOrMonoForum ?? false, namespace: namespace) {
media = updatedMessage.media
attributes = updatedMessage.attributes
text = updatedMessage.text
@ -423,7 +423,7 @@ func applyUpdateGroupMessages(postbox: Postbox, stateManager: AccountStateManage
for apiMessage in result.messages {
var peerIsForum = false
if let apiMessagePeerId = apiMessage.peerId, let peer = transaction.getPeer(apiMessagePeerId) {
if peer.isForum {
if peer.isForumOrMonoForum {
peerIsForum = true
}
}

View File

@ -145,7 +145,7 @@ private func parseDialogs(accountPeerId: PeerId, apiDialogs: [Api.Dialog], apiMe
for message in apiMessages {
var peerIsForum = false
if let peerId = message.peerId, let peer = peers.get(peerId), peer.isForum {
if let peerId = message.peerId, let peer = peers.get(peerId), peer.isForumOrMonoForum {
peerIsForum = true
}
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peerIsForum) {

View File

@ -763,7 +763,7 @@ private func validateBatch(postbox: Postbox, network: Network, transaction: Tran
var storeMessages: [StoreMessage] = []
for message in messages {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForum, namespace: messageNamespace) {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForumOrMonoForum, namespace: messageNamespace) {
var attributes = storeMessage.attributes
if let channelPts = channelPts {
attributes.append(ChannelMessageStateVersionAttribute(pts: channelPts))
@ -810,7 +810,7 @@ private func validateBatch(postbox: Postbox, network: Network, transaction: Tran
}
var ids = Set<MessageId>()
for message in apiMessages {
if let parsedMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForum, namespace: messageNamespace), case let .Id(id) = parsedMessage.id {
if let parsedMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForumOrMonoForum, namespace: messageNamespace), case let .Id(id) = parsedMessage.id {
if let tag = tag {
if parsedMessage.tags.contains(tag) {
ids.insert(id)
@ -1014,7 +1014,7 @@ private func validateReplyThreadBatch(postbox: Postbox, network: Network, transa
var storeMessages: [StoreMessage] = []
for message in messages {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForum, namespace: messageNamespace) {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForumOrMonoForum, namespace: messageNamespace) {
var attributes = storeMessage.attributes
if let channelPts = channelPts {
attributes.append(ChannelMessageStateVersionAttribute(pts: channelPts))
@ -1059,7 +1059,7 @@ private func validateReplyThreadBatch(postbox: Postbox, network: Network, transa
}
var ids = Set<MessageId>()
for message in apiMessages {
if let parsedMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForum, namespace: messageNamespace), case let .Id(id) = parsedMessage.id {
if let parsedMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: topPeer.isForumOrMonoForum, namespace: messageNamespace), case let .Id(id) = parsedMessage.id {
ids.insert(id)
}
}

View File

@ -301,7 +301,7 @@ func withResolvedAssociatedMessages<T>(postbox: Postbox, source: FetchMessageHis
for (peer, messages, chats, users) in results {
if !messages.isEmpty {
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum) {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum) {
additionalMessages.append(message)
}
}
@ -905,7 +905,7 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
var storeMessages: [StoreMessage] = []
for message in messages {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum, namespace: namespace) {
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum, namespace: namespace) {
if let channelPts = channelPts {
var attributes = storeMessage.attributes
attributes.append(ChannelMessageStateVersionAttribute(pts: channelPts))
@ -1204,7 +1204,7 @@ func fetchCallListHole(network: Network, postbox: Postbox, accountPeerId: PeerId
for message in messages {
var peerIsForum = false
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForum {
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForumOrMonoForum {
peerIsForum = true
}
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peerIsForum) {

View File

@ -534,7 +534,7 @@ func managedSynchronizeMessageHistoryTagSummaries(postbox: Postbox, network: Net
private func synchronizeMessageHistoryTagSummary(accountPeerId: PeerId, postbox: Postbox, network: Network, entry: InvalidatedMessageHistoryTagsSummaryEntry) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Signal<Void, NoError> in
if let threadId = entry.key.threadId {
if let peer = transaction.getPeer(entry.key.peerId) as? TelegramChannel, peer.flags.contains(.isForum), let inputPeer = apiInputPeer(peer) {
if let peer = transaction.getPeer(entry.key.peerId) as? TelegramChannel, peer.flags.contains(.isForum), !peer.flags.contains(.isMonoforum), let inputPeer = apiInputPeer(peer) {
return network.request(Api.functions.messages.getReplies(peer: inputPeer, msgId: Int32(clamping: threadId), offsetId: 0, offsetDate: 0, addOffset: 0, limit: 1, maxId: 0, minId: 0, hash: 0))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.messages.Messages?, NoError> in

View File

@ -128,7 +128,7 @@ func managedSynchronizeChatInputStateOperations(postbox: Postbox, network: Netwo
private func synchronizeChatInputState(transaction: Transaction, postbox: Postbox, network: Network, peerId: PeerId, threadId: Int64?, operation: SynchronizeChatInputStateOperation) -> Signal<Void, NoError> {
var inputState: SynchronizeableChatInputState?
let peerChatInterfaceState: StoredPeerChatInterfaceState?
if let threadId = threadId {
if let threadId {
peerChatInterfaceState = transaction.getPeerChatThreadInterfaceState(peerId, threadId: threadId)
} else {
peerChatInterfaceState = transaction.getPeerChatInterfaceState(peerId)
@ -146,16 +146,26 @@ private func synchronizeChatInputState(transaction: Transaction, postbox: Postbo
}
}
var topMsgId: Int32?
if let threadId = threadId {
var monoforumPeerId: Api.InputPeer?
if let threadId {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isMonoforum) {
monoforumPeerId = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer)
} else {
topMsgId = Int32(clamping: threadId)
}
}
var replyTo: Api.InputReplyTo?
if let replySubject = inputState?.replySubject {
flags |= 1 << 0
var innerFlags: Int32 = 0
//inputReplyToMessage#73ec805 flags:# reply_to_msg_id:int top_msg_id:flags.0?int reply_to_peer_id:flags.1?InputPeer quote_text:flags.2?string quote_entities:flags.3?Vector<MessageEntity> = InputReplyTo;
if topMsgId != nil {
innerFlags |= 1 << 0
} else if monoforumPeerId != nil {
innerFlags |= 1 << 5
}
var replyToPeer: Api.InputPeer?
var discard = false
if replySubject.messageId.peerId != peerId {
@ -201,14 +211,17 @@ private func synchronizeChatInputState(transaction: Transaction, postbox: Postbo
}
if !discard {
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: replySubject.messageId.id, topMsgId: topMsgId, replyToPeerId: replyToPeer, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset)
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: replySubject.messageId.id, topMsgId: topMsgId, replyToPeerId: replyToPeer, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId)
}
} else if let topMsgId = topMsgId {
} else if let topMsgId {
flags |= 1 << 0
var innerFlags: Int32 = 0
innerFlags |= 1 << 0
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: topMsgId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: topMsgId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
} else if let monoforumPeerId {
flags |= 1 << 0
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
return network.request(Api.functions.messages.saveDraft(flags: flags, replyTo: replyTo, peer: inputPeer, message: inputState?.text ?? "", entities: apiEntitiesFromMessageTextEntities(inputState?.entities ?? [], associatedPeers: SimpleDictionary()), media: nil, effect: nil))

View File

@ -195,7 +195,7 @@ private func synchronizePinnedChats(transaction: Transaction, postbox: Postbox,
for message in messages {
var peerIsForum = false
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForum {
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForumOrMonoForum {
peerIsForum = true
}
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peerIsForum) {
@ -318,7 +318,7 @@ private func synchronizePinnedSavedChats(transaction: Transaction, postbox: Post
for message in messages {
var peerIsForum = false
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForum {
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForumOrMonoForum {
peerIsForum = true
}
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peerIsForum) {

View File

@ -1035,10 +1035,15 @@ public final class PendingMessageManager {
}
var topMsgId: Int32?
var monoforumPeerId: Api.InputPeer?
if let threadId = messages[0].0.threadId {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isMonoforum) {
monoforumPeerId = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer)
} else {
flags |= Int32(1 << 9)
topMsgId = Int32(clamping: threadId)
}
}
var replyTo: Api.InputReplyTo?
if let replyMessageId = replyMessageId {
@ -1047,6 +1052,8 @@ public final class PendingMessageManager {
var replyFlags: Int32 = 0
if topMsgId != nil {
replyFlags |= 1 << 0
} else if monoforumPeerId != nil {
replyFlags |= 1 << 5
}
var replyToPeerId: Api.InputPeer?
@ -1085,12 +1092,15 @@ public final class PendingMessageManager {
}
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset)
} else if let replyToStoryId = replyToStoryId {
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId)
} else if let replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
}
} else if let monoforumPeerId {
flags |= 1 << 0
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
var quickReplyShortcut: Api.InputQuickReplyShortcut?
@ -1328,14 +1338,20 @@ public final class PendingMessageManager {
var sendAsPeerId: PeerId?
var bubbleUpEmojiOrStickersets = false
var quickReply: OutgoingQuickReplyMessageAttribute?
var suggestedPost: OutgoingSuggestedPostMessageAttribute?
var messageEffect: EffectMessageAttribute?
var allowPaidStars: Int64?
var flags: Int32 = 0
//TODO:release
let _ = suggestedPost
var topMsgId: Int32?
var monoforumPeerId: Api.InputPeer?
if let threadId = message.threadId {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isMonoforum) {
monoforumPeerId = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer)
} else {
topMsgId = Int32(clamping: threadId)
}
}
for attribute in message.attributes {
if let replyAttribute = attribute as? ReplyMessageAttribute {
@ -1370,8 +1386,6 @@ public final class PendingMessageManager {
sendAsPeerId = attribute.peerId
} else if let attribute = attribute as? OutgoingQuickReplyMessageAttribute {
quickReply = attribute
} else if let attribute = attribute as? OutgoingSuggestedPostMessageAttribute {
suggestedPost = attribute
} else if let attribute = attribute as? EffectMessageAttribute {
messageEffect = attribute
} else if let attribute = attribute as? ForwardVideoTimestampAttribute {
@ -1413,8 +1427,10 @@ public final class PendingMessageManager {
flags |= 1 << 0
var replyFlags: Int32 = 0
if message.threadId != nil {
if topMsgId != nil {
replyFlags |= 1 << 0
} else if monoforumPeerId != nil {
replyFlags |= 1 << 5
}
var replyToPeerId: Api.InputPeer?
@ -1453,12 +1469,17 @@ public final class PendingMessageManager {
}
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
}
} else if let monoforumPeerId {
flags |= 1 << 0
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
if let attribute = message.webpagePreviewAttribute {
if attribute.leadingPreview {
@ -1500,8 +1521,10 @@ public final class PendingMessageManager {
flags |= 1 << 0
var replyFlags: Int32 = 0
if message.threadId != nil {
if topMsgId != nil {
replyFlags |= 1 << 0
} else if monoforumPeerId != nil {
replyFlags |= 1 << 5
}
var replyToPeerId: Api.InputPeer?
@ -1540,12 +1563,15 @@ public final class PendingMessageManager {
}
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
}
} else if let monoforumPeerId {
flags |= 1 << 0
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
if let attribute = message.webpagePreviewAttribute {
@ -1620,8 +1646,10 @@ public final class PendingMessageManager {
flags |= 1 << 0
var replyFlags: Int32 = 0
if message.threadId != nil {
if topMsgId != nil {
replyFlags |= 1 << 0
} else if monoforumPeerId != nil {
replyFlags |= 1 << 5
}
var replyToPeerId: Api.InputPeer?
@ -1660,12 +1688,15 @@ public final class PendingMessageManager {
}
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
}
} else if let monoforumPeerId {
flags |= 1 << 0
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
var quickReplyShortcut: Api.InputQuickReplyShortcut?
@ -1689,18 +1720,18 @@ public final class PendingMessageManager {
if let replyMessageId = replyMessageId {
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
} else if let replyToStoryId = replyToStoryId {
if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) {
flags |= 1 << 0
replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id)
} else {
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId)
}
} else {
let replyFlags: Int32 = 0
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId)
}
sendMessageRequest = network.request(Api.functions.messages.sendScreenshotNotification(peer: inputPeer, replyTo: replyTo, randomId: uniqueId))

View File

@ -25,7 +25,7 @@ func _internal_resetAccountState(postbox: Postbox, network: Network, accountPeer
}
if peerId.namespace == Namespaces.Peer.CloudChannel {
if let channel = transaction.getPeer(peerId) as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = transaction.getPeer(peerId) as? TelegramChannel, channel.isForumOrMonoForum {
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: [])
for threadId in transaction.setMessageHistoryThreads(peerId: peerId) {
transaction.setMessageHistoryThreadInfo(peerId: peerId, threadId: threadId, info: nil)

View File

@ -66,11 +66,7 @@ public let telegramPostboxSeedConfiguration: SeedConfiguration = {
case .broadcast:
return .channel
case .group:
if channel.flags.contains(.isForum) {
return .group
} else {
return .group
}
}
} else {
assertionFailure()

View File

@ -116,6 +116,7 @@ func _internal_togglePeerUnreadMarkInteractively(postbox: Postbox, network: Netw
}
func _internal_markForumThreadAsReadInteractively(transaction: Transaction, network: Network, viewTracker: AccountViewTracker, peerId: PeerId, threadId: Int64) {
//TODO:release monoforums
guard let peer = transaction.getPeer(peerId) else {
return
}
@ -145,6 +146,7 @@ func _internal_markForumThreadAsReadInteractively(transaction: Transaction, netw
}
func _internal_togglePeerUnreadMarkInteractively(transaction: Transaction, network: Network, viewTracker: AccountViewTracker, peerId: PeerId, setToValue: Bool? = nil) {
//TODO:release monoforums
guard let peer = transaction.getPeer(peerId) else {
return
}

View File

@ -147,16 +147,20 @@ public enum RequestWebViewError {
case generic
}
private func keepWebViewSignal(network: Network, stateManager: AccountStateManager, flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyToMessageId: MessageId?, threadId: Int64?, sendAs: Api.InputPeer?) -> Signal<Never, KeepWebViewError> {
private func keepWebViewSignal(network: Network, stateManager: AccountStateManager, flags: Int32, peer: Api.InputPeer, monoforumPeerId: Api.InputPeer?, bot: Api.InputUser, queryId: Int64, replyToMessageId: MessageId?, threadId: Int64?, sendAs: Api.InputPeer?) -> Signal<Never, KeepWebViewError> {
let signal = Signal<Never, KeepWebViewError> { subscriber in
let poll = Signal<Never, KeepWebViewError> { subscriber in
var replyTo: Api.InputReplyTo?
if let replyToMessageId = replyToMessageId {
if let replyToMessageId {
var replyFlags: Int32 = 0
if threadId != nil {
var topMsgId: Int32?
if monoforumPeerId != nil {
replyFlags |= 1 << 5
} else if let threadId {
replyFlags |= 1 << 0
topMsgId = Int32(clamping: threadId)
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: threadId.flatMap(Int32.init(clamping:)), replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId)
}
let signal: Signal<Never, KeepWebViewError> = network.request(Api.functions.messages.prolongWebView(flags: flags, peer: peer, bot: bot, queryId: queryId, replyTo: replyTo, sendAs: sendAs))
|> mapError { _ -> KeepWebViewError in
@ -223,14 +227,30 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
}
var replyTo: Api.InputReplyTo?
var monoforumPeerId: Api.InputPeer?
var topMsgId: Int32?
if let threadId {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isMonoforum) {
monoforumPeerId = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer)
} else {
topMsgId = Int32(clamping: threadId)
}
}
if let replyToMessageId = replyToMessageId {
flags |= (1 << 0)
var replyFlags: Int32 = 0
if threadId != nil {
if monoforumPeerId != nil {
replyFlags |= 1 << 5
} else if topMsgId != nil {
replyFlags |= 1 << 0
}
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: threadId.flatMap(Int32.init(clamping:)), replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId)
} else if let monoforumPeerId {
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, platform: botWebViewPlatform, replyTo: replyTo, sendAs: nil))
@ -249,7 +269,7 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
}
let keepAlive: Signal<Never, KeepWebViewError>?
if let queryId {
keepAlive = keepWebViewSignal(network: network, stateManager: stateManager, flags: flags, peer: inputPeer, bot: inputBot, queryId: queryId, replyToMessageId: replyToMessageId, threadId: threadId, sendAs: nil)
keepAlive = keepWebViewSignal(network: network, stateManager: stateManager, flags: flags, peer: inputPeer, monoforumPeerId: monoforumPeerId, bot: inputBot, queryId: queryId, replyToMessageId: replyToMessageId, threadId: threadId, sendAs: nil)
} else {
keepAlive = nil
}

View File

@ -522,7 +522,7 @@ extension EngineChatList.Item {
let readCounters = readState.flatMap(EnginePeerReadCounters.init)
if let channel = renderedPeer.peer as? TelegramChannel {
if channel.flags.contains(.isForum) {
if channel.isForumOrMonoForum {
draft = nil
} else {
forumTopicDataValue = nil

View File

@ -38,17 +38,25 @@ func _internal_clearCloudDraftsInteractively(postbox: Postbox, network: Network,
if let peer = transaction.getPeer(key.peerId), let inputPeer = apiInputPeer(peer) {
var topMsgId: Int32?
var monoforumPeerId: Api.InputPeer?
if let threadId = key.threadId {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isMonoforum) {
monoforumPeerId = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer)
} else {
topMsgId = Int32(clamping: threadId)
}
}
var flags: Int32 = 0
var replyTo: Api.InputReplyTo?
if let topMsgId = topMsgId {
if let topMsgId {
flags |= (1 << 0)
var innerFlags: Int32 = 0
innerFlags |= 1 << 0
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: 0, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil)
replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: 0, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil)
} else if let monoforumPeerId {
flags |= (1 << 0)
replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId)
}
signals.append(network.request(Api.functions.messages.saveDraft(flags: flags, replyTo: replyTo, peer: inputPeer, message: "", entities: nil, media: nil, effect: nil))
|> `catch` { _ -> Signal<Api.Bool, NoError> in

View File

@ -100,7 +100,7 @@ func _internal_getMessagesLoadIfNecessary(_ messageIds: [MessageId], postbox: Po
var storeMessages: [StoreMessage] = []
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum) {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum) {
storeMessages.append(message)
}
}

View File

@ -8,6 +8,7 @@ private struct DiscussionMessage {
var channelMessageId: MessageId?
var isChannelPost: Bool
var isForumPost: Bool
var isMonoforumPost: Bool
var maxMessage: MessageId?
var maxReadIncomingMessageId: MessageId?
var maxReadOutgoingMessageId: MessageId?
@ -165,7 +166,7 @@ private class ReplyThreadHistoryContextImpl {
switch discussionMessage {
case let .discussionMessage(_, messages, maxId, readInboxMaxId, readOutboxMaxId, unreadCount, chats, users):
let parsedMessages = messages.compactMap { message -> StoreMessage? in
StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum)
StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum)
}
guard let topMessage = parsedMessages.last, let parsedIndex = topMessage.index else {
@ -237,15 +238,22 @@ private class ReplyThreadHistoryContextImpl {
}
var isForumPost = false
if let channel = transaction.getPeer(parsedIndex.id.peerId) as? TelegramChannel, channel.flags.contains(.isForum) {
var isMonoforumPost = false
if let channel = transaction.getPeer(parsedIndex.id.peerId) as? TelegramChannel {
if channel.isForumOrMonoForum {
isForumPost = true
}
if channel.isMonoForum {
isMonoforumPost = true
}
}
return .single(DiscussionMessage(
messageId: parsedIndex.id,
channelMessageId: channelMessageId,
isChannelPost: isChannelPost,
isForumPost: isForumPost,
isMonoforumPost: isMonoforumPost,
maxMessage: resolvedMaxMessage,
maxReadIncomingMessageId: maxReadIncomingMessageId,
maxReadOutgoingMessageId: readOutboxMaxId.flatMap { readMaxId in
@ -565,7 +573,7 @@ public struct ChatReplyThreadMessage: Equatable {
public var channelMessageId: MessageId?
public var isChannelPost: Bool
public var isForumPost: Bool
public var isMonoforum: Bool
public var isMonoforumPost: Bool
public var maxMessage: MessageId?
public var maxReadIncomingMessageId: MessageId?
public var maxReadOutgoingMessageId: MessageId?
@ -582,13 +590,13 @@ public struct ChatReplyThreadMessage: Equatable {
}
}
public init(peerId: PeerId, threadId: Int64, channelMessageId: MessageId?, isChannelPost: Bool, isForumPost: Bool, isMonoforum: Bool, maxMessage: MessageId?, maxReadIncomingMessageId: MessageId?, maxReadOutgoingMessageId: MessageId?, unreadCount: Int, initialFilledHoles: IndexSet, initialAnchor: Anchor, isNotAvailable: Bool) {
public init(peerId: PeerId, threadId: Int64, channelMessageId: MessageId?, isChannelPost: Bool, isForumPost: Bool, isMonoforumPost: Bool, maxMessage: MessageId?, maxReadIncomingMessageId: MessageId?, maxReadOutgoingMessageId: MessageId?, unreadCount: Int, initialFilledHoles: IndexSet, initialAnchor: Anchor, isNotAvailable: Bool) {
self.peerId = peerId
self.threadId = threadId
self.channelMessageId = channelMessageId
self.isChannelPost = isChannelPost
self.isForumPost = isForumPost
self.isMonoforum = isMonoforum
self.isMonoforumPost = isMonoforumPost
self.maxMessage = maxMessage
self.maxReadIncomingMessageId = maxReadIncomingMessageId
self.maxReadOutgoingMessageId = maxReadOutgoingMessageId
@ -600,7 +608,7 @@ public struct ChatReplyThreadMessage: Equatable {
public var normalized: ChatReplyThreadMessage {
if self.isForumPost {
return ChatReplyThreadMessage(peerId: self.peerId, threadId: self.threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false)
return ChatReplyThreadMessage(peerId: self.peerId, threadId: self.threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: self.isMonoforumPost, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false)
} else {
return self
}
@ -644,7 +652,7 @@ func _internal_fetchChannelReplyThreadMessage(account: Account, messageId: Messa
switch discussionMessage {
case let .discussionMessage(_, messages, maxId, readInboxMaxId, readOutboxMaxId, unreadCount, chats, users):
let parsedMessages = messages.compactMap { message -> StoreMessage? in
StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum)
StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum)
}
guard let topMessage = parsedMessages.last, let parsedIndex = topMessage.index else {
@ -685,15 +693,22 @@ func _internal_fetchChannelReplyThreadMessage(account: Account, messageId: Messa
}
var isForumPost = false
if let channel = transaction.getPeer(parsedIndex.id.peerId) as? TelegramChannel, channel.flags.contains(.isForum) {
var isMonoforumPost = false
if let channel = transaction.getPeer(parsedIndex.id.peerId) as? TelegramChannel {
if channel.isForumOrMonoForum {
isForumPost = true
}
if channel.isMonoForum {
isMonoforumPost = true
}
}
return DiscussionMessage(
messageId: parsedIndex.id,
channelMessageId: channelMessageId,
isChannelPost: isChannelPost,
isForumPost: isForumPost,
isMonoforumPost: isMonoforumPost,
maxMessage: resolvedMaxMessage,
maxReadIncomingMessageId: readInboxMaxId.flatMap { readMaxId in
MessageId(peerId: parsedIndex.id.peerId, namespace: Namespaces.Message.Cloud, id: readMaxId)
@ -718,6 +733,7 @@ func _internal_fetchChannelReplyThreadMessage(account: Account, messageId: Messa
channelMessageId: nil,
isChannelPost: false,
isForumPost: true,
isMonoforumPost: false,
maxMessage: MessageId(peerId: messageId.peerId, namespace: messageId.namespace, id: threadData.maxKnownMessageId),
maxReadIncomingMessageId: MessageId(peerId: messageId.peerId, namespace: messageId.namespace, id: threadData.maxIncomingReadId),
maxReadOutgoingMessageId: MessageId(peerId: messageId.peerId, namespace: messageId.namespace, id: threadData.maxOutgoingReadId),
@ -933,7 +949,7 @@ func _internal_fetchChannelReplyThreadMessage(account: Account, messageId: Messa
channelMessageId: discussionMessage.channelMessageId,
isChannelPost: discussionMessage.isChannelPost,
isForumPost: discussionMessage.isForumPost,
isMonoforum: false,
isMonoforumPost: discussionMessage.isMonoforumPost,
maxMessage: discussionMessage.maxMessage,
maxReadIncomingMessageId: discussionMessage.maxReadIncomingMessageId,
maxReadOutgoingMessageId: discussionMessage.maxReadOutgoingMessageId,

View File

@ -139,7 +139,7 @@ private func mergedState(transaction: Transaction, seedConfiguration: SeedConfig
var renderedMessages: [Message] = []
for message in messages {
var peerIsForum = false
if let peerId = message.peerId, let peer = peers[peerId], peer.isForum {
if let peerId = message.peerId, let peer = peers[peerId], peer.isForumOrMonoForum {
peerIsForum = true
}
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peerIsForum) {
@ -671,7 +671,7 @@ func _internal_downloadMessage(accountPeerId: PeerId, postbox: Postbox, network:
var renderedMessages: [Message] = []
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum), let renderedMessage = locallyRenderedMessage(message: message, peers: peers) {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum), let renderedMessage = locallyRenderedMessage(message: message, peers: peers) {
renderedMessages.append(renderedMessage)
}
}
@ -755,7 +755,7 @@ func fetchRemoteMessage(accountPeerId: PeerId, postbox: Postbox, source: FetchMe
var renderedMessages: [Message] = []
for message in messages {
var peerIsForum = false
if let peerId = message.peerId, let peer = transaction.getPeer(peerId) ?? parsedPeers.get(peerId), peer.isForum {
if let peerId = message.peerId, let peer = transaction.getPeer(peerId) ?? parsedPeers.get(peerId), peer.isForumOrMonoForum {
peerIsForum = true
}
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peerIsForum, namespace: id.namespace), case let .Id(updatedId) = message.id {
@ -810,7 +810,7 @@ func _internal_searchMessageIdByTimestamp(account: Account, peerId: PeerId, thre
messages = []
}
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: peer.isForum) {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: peer.isForumOrMonoForum) {
return message.index
}
}
@ -847,7 +847,7 @@ func _internal_searchMessageIdByTimestamp(account: Account, peerId: PeerId, thre
messages = []
}
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: peer.isForum) {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: peer.isForumOrMonoForum) {
return message.index
}
}
@ -880,7 +880,7 @@ func _internal_searchMessageIdByTimestamp(account: Account, peerId: PeerId, thre
messages = []
}
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: secondaryPeer.isForum) {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: secondaryPeer.isForumOrMonoForum) {
return message.index
}
}
@ -904,7 +904,7 @@ func _internal_searchMessageIdByTimestamp(account: Account, peerId: PeerId, thre
messages = []
}
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: peer.isForum) {
if let message = StoreMessage(apiMessage: message, accountPeerId: account.peerId, peerIsForum: peer.isForumOrMonoForum) {
return message.index
}
}

View File

@ -842,7 +842,7 @@ public final class SparseMessageCalendar {
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
for message in messages {
if let parsedMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum) {
if let parsedMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum) {
parsedMessages.append(parsedMessage)
}
}

View File

@ -882,7 +882,7 @@ private func loadAndStorePeerChatInfos(accountPeerId: PeerId, postbox: Postbox,
var storeMessages: [StoreMessage] = []
for message in messages {
var peerIsForum = false
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForum {
if let peerId = message.peerId, let peer = parsedPeers.get(peerId), peer.isForumOrMonoForum {
peerIsForum = true
}
if let storeMessage = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peerIsForum) {

View File

@ -114,7 +114,7 @@ func _internal_requestPeerPhotos(accountPeerId: PeerId, postbox: Postbox, networ
var renderedMessages: [Message] = []
for message in messages {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForum), let renderedMessage = locallyRenderedMessage(message: message, peers: peers) {
if let message = StoreMessage(apiMessage: message, accountPeerId: accountPeerId, peerIsForum: peer.isForumOrMonoForum), let renderedMessage = locallyRenderedMessage(message: message, peers: peers) {
renderedMessages.append(renderedMessage)
}
}

View File

@ -271,6 +271,22 @@ public extension Peer {
}
}
var isMonoForum: Bool {
if let channel = self as? TelegramChannel {
return channel.flags.contains(.isMonoforum)
} else {
return false
}
}
var isForumOrMonoForum: Bool {
if let channel = self as? TelegramChannel {
return channel.flags.contains(.isForum) || channel.flags.contains(.isMonoforum)
} else {
return false
}
}
var nameColor: PeerNameColor? {
switch self {
case let user as TelegramUser:

View File

@ -206,7 +206,7 @@ final class AdminUserActionsPeerComponent: Component {
}
if let peer = component.peer {
let clipStyle: AvatarNodeClipStyle
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -461,7 +461,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
if self.discussButton.isHidden {
if let peer = interfaceState.renderedPeer?.peer as? TelegramChannel {
if case .broadcast = peer.info, interfaceState.starGiftsAvailable {
if case let .broadcast(broadcastInfo) = peer.info, interfaceState.starGiftsAvailable {
if self.giftButton.isHidden && !isFirstTime {
self.giftButton.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
self.giftButton.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2)
@ -469,7 +469,12 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
self.giftButton.isHidden = false
self.helpButton.isHidden = true
self.suggestedPostButton.isHidden = true
self.suggestedPostButton.isHidden = !broadcastInfo.flags.contains(.hasMonoforum)
self.presentGiftOrSuggestTooltip()
} else if case let .broadcast(broadcastInfo) = peer.info, broadcastInfo.flags.contains(.hasMonoforum) {
self.giftButton.isHidden = true
self.helpButton.isHidden = true
self.suggestedPostButton.isHidden = false
self.presentGiftOrSuggestTooltip()
} else if peer.flags.contains(.isGigagroup), self.action == .muteNotifications || self.action == .unmuteNotifications {
self.giftButton.isHidden = true

View File

@ -1161,7 +1161,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
}
var hasReply = replyMessage != nil || replyForward != nil || replyStory != nil
if case let .peer(peerId) = item.chatLocation, (peerId == replyMessage?.id.peerId || item.message.threadId == 1), let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum), item.message.associatedThreadInfo != nil {
if case let .peer(peerId) = item.chatLocation, (peerId == replyMessage?.id.peerId || item.message.threadId == 1), let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.isForumOrMonoForum, item.message.associatedThreadInfo != nil {
if let threadId = item.message.threadId, let replyMessage = replyMessage, Int64(replyMessage.id.id) == threadId {
hasReply = false
}

View File

@ -2227,7 +2227,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
if replyMessage != nil || replyForward != nil || replyStory != nil {
displayHeader = true
}
if !displayHeader, case .peer = item.chatLocation, let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum), item.message.associatedThreadInfo != nil {
if !displayHeader, case .peer = item.chatLocation, let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.isForumOrMonoForum, item.message.associatedThreadInfo != nil {
displayHeader = true
}
if case let .customChatContents(contents) = item.associatedData.subject, case .hashTagSearch = contents.kind, let peer = item.message.peers[item.message.id.peerId] {
@ -2572,7 +2572,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
}
var hasThreadInfo = false
if case let .peer(peerId) = item.chatLocation, (peerId == replyMessage?.id.peerId || item.message.threadId == 1 || item.associatedData.isRecentActions), let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum), item.message.associatedThreadInfo != nil {
if case let .peer(peerId) = item.chatLocation, (peerId == replyMessage?.id.peerId || item.message.threadId == 1 || item.associatedData.isRecentActions), let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.isForumOrMonoForum, item.message.associatedThreadInfo != nil {
hasThreadInfo = true
} else if case let .customChatContents(contents) = item.associatedData.subject, case .hashTagSearch = contents.kind {
if let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, case .broadcast = channel.info {

View File

@ -93,7 +93,7 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs
}
var sameThread = true
if let lhsPeer = lhs.peers[lhs.id.peerId], let rhsPeer = rhs.peers[rhs.id.peerId], arePeersEqual(lhsPeer, rhsPeer), let channel = lhsPeer as? TelegramChannel, channel.flags.contains(.isForum), lhs.threadId != rhs.threadId {
if let lhsPeer = lhs.peers[lhs.id.peerId], let rhsPeer = rhs.peers[rhs.id.peerId], arePeersEqual(lhsPeer, rhsPeer), let channel = lhsPeer as? TelegramChannel, channel.isForumOrMonoForum, lhs.threadId != rhs.threadId {
sameThread = false
}

View File

@ -727,7 +727,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView {
}
var hasReply = replyMessage != nil || replyForward != nil || replyStory != nil
if case let .peer(peerId) = item.chatLocation, (peerId == replyMessage?.id.peerId || item.message.threadId == 1), let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum), item.message.associatedThreadInfo != nil {
if case let .peer(peerId) = item.chatLocation, (peerId == replyMessage?.id.peerId || item.message.threadId == 1), let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.isForumOrMonoForum, item.message.associatedThreadInfo != nil {
if let threadId = item.message.threadId, let replyMessage = replyMessage, Int64(replyMessage.id.id) == threadId {
hasReply = false
}

View File

@ -323,7 +323,7 @@ public class ChatMessageThreadInfoNode: ASDisplayNode {
var topicTitle = ""
var topicIconId: Int64?
var topicIconColor: Int32 = 0
if let _ = arguments.parentMessage.threadId, let channel = arguments.parentMessage.peers[arguments.parentMessage.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum), let threadInfo = arguments.parentMessage.associatedThreadInfo {
if let _ = arguments.parentMessage.threadId, let channel = arguments.parentMessage.peers[arguments.parentMessage.id.peerId] as? TelegramChannel, channel.isForumOrMonoForum, let threadInfo = arguments.parentMessage.associatedThreadInfo {
topicTitle = threadInfo.title
topicIconId = threadInfo.icon
topicIconColor = threadInfo.iconColor

View File

@ -205,7 +205,7 @@ final class PeerListItemComponent: Component {
}
if let peer = component.peer {
let clipStyle: AvatarNodeClipStyle
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -636,7 +636,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
state = .info(string, .generic)
}
} else if let channel = peer as? TelegramChannel {
if channel.flags.contains(.isForum), customTitle != nil {
if channel.isForumOrMonoForum, customTitle != nil {
let string = NSAttributedString(string: EnginePeer(peer).displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder), font: subtitleFont, textColor: titleTheme.rootController.navigationBar.secondaryTextColor)
state = .info(string, .generic)
} else if let cachedChannelData = peerView.cachedData as? CachedChannelData, let memberCount = onlineMemberCount.total ?? cachedChannelData.participantsSummary.memberCount {

View File

@ -210,7 +210,7 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, AS
channelMessageId: nil,
isChannelPost: false,
isForumPost: false,
isMonoforum: false,
isMonoforumPost: false,
maxMessage: nil,
maxReadIncomingMessageId: nil,
maxReadOutgoingMessageId: nil,
@ -379,7 +379,7 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, AS
if case let .peer(peerData) = item.content {
let threadId = peerData.peer.peerId.toInt64()
let chatController = self.context.sharedContext.makeChatController(context: self.context, chatLocation: .replyThread(message: ChatReplyThreadMessage(
peerId: self.context.account.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: false, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
peerId: self.context.account.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: false, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
)), subject: nil, botStart: nil, mode: .standard(.previewing), params: nil)
chatController.canReadHistory.set(false)
let source: ContextContentSource = .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: parentController.navigationController as? NavigationController))

View File

@ -149,7 +149,7 @@ public final class PeerInfoChatPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScro
self.coveringView = UIView()
self.chatController = context.sharedContext.makeChatController(context: context, chatLocation: .replyThread(message: ChatReplyThreadMessage(peerId: context.account.peerId, threadId: peerId.toInt64(), channelMessageId: nil, isChannelPost: false, isForumPost: false, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false)), subject: nil, botStart: nil, mode: .standard(.embedded(invertDirection: true)), params: nil)
self.chatController = context.sharedContext.makeChatController(context: context, chatLocation: .replyThread(message: ChatReplyThreadMessage(peerId: context.account.peerId, threadId: peerId.toInt64(), channelMessageId: nil, isChannelPost: false, isForumPost: false, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false)), subject: nil, botStart: nil, mode: .standard(.embedded(invertDirection: true)), params: nil)
self.chatController.navigation_setNavigationController(navigationController())
super.init()

View File

@ -158,7 +158,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode {
}
var isForum = false
if let peer, let channel = peer as? TelegramChannel, channel.isForum {
if let peer, let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
isForum = true
}
@ -325,7 +325,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode {
var isForum = false
let avatarCornerRadius: CGFloat
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
avatarCornerRadius = floor(avatarSize * 0.25)
isForum = true
} else {

View File

@ -2317,7 +2317,7 @@ func peerInfoCanEdit(peer: Peer?, chatLocation: ChatLocation, threadData: Messag
}
return true
} else if let peer = peer as? TelegramChannel {
if peer.flags.contains(.isForum), let threadData = threadData {
if peer.isForumOrMonoForum, let threadData = threadData {
if peer.flags.contains(.isCreator) {
return true
} else if threadData.isOwnedByMe {

View File

@ -90,7 +90,7 @@ final class PeerInfoEditingAvatarNode: ASDisplayNode {
var isForum = false
let avatarCornerRadius: CGFloat
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
isForum = true
avatarCornerRadius = floor(avatarSize * 0.25)
} else {

View File

@ -71,7 +71,7 @@ final class PeerInfoEditingAvatarOverlayNode: ASDisplayNode {
let transition = ContainedViewLayoutTransition.animated(duration: 0.2, curve: .linear)
let clipStyle: AvatarNodeClipStyle
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -573,7 +573,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
}
var isForum = false
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
isForum = true
}

View File

@ -2543,7 +2543,7 @@ private func editingItems(data: PeerInfoScreenData?, boostStatus: ChannelBoostSt
}))
}
if (isCreator || (channel.adminRights != nil && channel.hasPermission(.banMembers))) && cachedData.peerGeoLocation == nil, !isPublic, case .known(nil) = cachedData.linkedDiscussionPeerId, !channel.flags.contains(.isForum) {
if (isCreator || (channel.adminRights != nil && channel.hasPermission(.banMembers))) && cachedData.peerGeoLocation == nil, !isPublic, case .known(nil) = cachedData.linkedDiscussionPeerId, !channel.isForumOrMonoForum {
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemPreHistory, label: .text(cachedData.flags.contains(.preHistoryEnabled) ? presentationData.strings.GroupInfo_GroupHistoryVisible : presentationData.strings.GroupInfo_GroupHistoryHidden), text: presentationData.strings.GroupInfo_GroupHistoryShort, icon: UIImage(bundleImageName: "Chat/Info/GroupDiscussionIcon"), action: {
interaction.editingOpenPreHistorySetup()
}))
@ -3285,7 +3285,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, _ in
c?.dismiss(completion: {
if let strongSelf = self, let currentPeer = strongSelf.data?.peer, let navigationController = strongSelf.controller?.navigationController as? NavigationController {
if let channel = currentPeer as? TelegramChannel, channel.flags.contains(.isForum), let threadId = message.threadId {
if let channel = currentPeer as? TelegramChannel, channel.isForumOrMonoForum, let threadId = message.threadId {
let _ = strongSelf.context.sharedContext.navigateToForumThread(context: strongSelf.context, peerId: currentPeer.id, threadId: threadId, messageId: message.id, navigationController: navigationController, activateInput: nil, scrollToEndIfExists: false, keepStack: .default).startStandalone()
} else {
let targetLocation: NavigateToChatControllerParams.Location
@ -3447,7 +3447,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
items.append(.action(ContextMenuActionItem(text: strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, f in
c?.dismiss(completion: {
if let strongSelf = self, let currentPeer = strongSelf.data?.peer, let navigationController = strongSelf.controller?.navigationController as? NavigationController {
if let channel = currentPeer as? TelegramChannel, channel.flags.contains(.isForum), let threadId = message.threadId {
if let channel = currentPeer as? TelegramChannel, channel.isForumOrMonoForum, let threadId = message.threadId {
let _ = strongSelf.context.sharedContext.navigateToForumThread(context: strongSelf.context, peerId: currentPeer.id, threadId: threadId, messageId: message.id, navigationController: navigationController, activateInput: nil, scrollToEndIfExists: false, keepStack: .default).startStandalone()
} else {
let targetLocation: NavigateToChatControllerParams.Location
@ -5148,7 +5148,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
}
}
if let channel = data.peer as? TelegramChannel, channel.flags.contains(.isForum), self.chatLocation.threadId == nil {
if let channel = data.peer as? TelegramChannel, channel.isForumOrMonoForum, self.chatLocation.threadId == nil {
if self.forumTopicNotificationExceptionsDisposable == nil {
self.forumTopicNotificationExceptionsDisposable = (self.context.engine.peers.forumChannelTopicNotificationExceptions(id: channel.id)
|> deliverOnMainQueue).startStrict(next: { [weak self] list in
@ -5936,7 +5936,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
} else {
displayCustomNotificationSettings = true
}
if self.data?.threadData == nil, let channel = self.data?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if self.data?.threadData == nil, let channel = self.data?.peer as? TelegramChannel, channel.isForumOrMonoForum {
displayCustomNotificationSettings = true
}
@ -7089,7 +7089,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
private func openChatForReporting(title: String, option: Data, message: String?) {
if let peer = self.data?.peer, let navigationController = (self.controller?.navigationController as? NavigationController) {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
//let _ = self.context.engine.peers.reportPeer(peerId: peer.id, reason: reason, message: "").startStandalone()
//self.controller?.present(UndoOverlayController(presentationData: self.presentationData, content: .emoji(name: "PoliceCar", text: self.presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return false }), in: .current)
} else {
@ -9868,7 +9868,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
}
var isForum = false
if let peer = strongSelf.data?.peer as? TelegramChannel, peer.flags.contains(.isForum) {
if let peer = strongSelf.data?.peer as? TelegramChannel, peer.isForumOrMonoForum {
isForum = true
}
@ -11032,7 +11032,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
channelMessageId: nil,
isChannelPost: false,
isForumPost: false,
isMonoforum: false,
isMonoforumPost: false,
maxMessage: nil,
maxReadIncomingMessageId: nil,
maxReadOutgoingMessageId: nil,
@ -11062,7 +11062,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
channelMessageId: nil,
isChannelPost: false,
isForumPost: false,
isMonoforum: false,
isMonoforumPost: false,
maxMessage: nil,
maxReadIncomingMessageId: nil,
maxReadOutgoingMessageId: nil,
@ -13376,7 +13376,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc
let navigateChatLocation: NavigateToChatControllerParams.Location
if let threadId = item.threadId {
navigateChatLocation = .replyThread(ChatReplyThreadMessage(
peerId: item.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false,maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
peerId: item.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false,maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
))
} else {
navigateChatLocation = .peer(itemPeer)

View File

@ -30,7 +30,7 @@ extension PeerInfoScreenImpl {
let peerId = self.peerId
var isForum = false
if let peer = peer as? TelegramChannel, peer.flags.contains(.isForum) {
if let peer = peer as? TelegramChannel, peer.isForumOrMonoForum {
isForum = true
}
@ -135,7 +135,7 @@ extension PeerInfoScreenImpl {
peerType = .group
} else if case let .channel(channel) = peer {
if case .group = channel.info {
peerType = channel.flags.contains(.isForum) ? .forum : .group
peerType = channel.isForumOrMonoForum ? .forum : .group
} else {
peerType = .channel
}

View File

@ -276,7 +276,7 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
self.peerSelectionNode.requestOpenPeer = { [weak self] peer, threadId in
if let strongSelf = self, let peerSelected = strongSelf.peerSelected {
if case let .channel(peer) = peer, peer.flags.contains(.isForum), threadId == nil, strongSelf.selectForumThreads {
if case let .channel(peer) = peer, peer.isForumOrMonoForum, threadId == nil, strongSelf.selectForumThreads {
let controller = PeerSelectionControllerImpl(
PeerSelectionControllerParams(
context: strongSelf.context,
@ -316,7 +316,7 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
strongSelf.openMessageFromSearchDisposable.set((_internal_storedMessageFromSearchPeer(postbox: strongSelf.context.account.postbox, peer: peer._asPeer())
|> deliverOnMainQueue).start(completed: { [weak strongSelf] in
if let strongSelf = strongSelf, let peerSelected = strongSelf.peerSelected {
if case let .channel(peer) = peer, peer.flags.contains(.isForum), threadId == nil, strongSelf.selectForumThreads {
if case let .channel(peer) = peer, peer.isForumOrMonoForum, threadId == nil, strongSelf.selectForumThreads {
let controller = PeerSelectionControllerImpl(
PeerSelectionControllerParams(
context: strongSelf.context,

View File

@ -238,7 +238,7 @@ final class PeerListItemComponent: Component {
}
if let peer = component.peer {
let clipStyle: AvatarNodeClipStyle
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -271,7 +271,7 @@ final class PeerNameColorProfilePreviewItemNode: ListViewItemNode {
let clipStyle: AvatarNodeClipStyle
switch item.peer {
case let .channel(channel) where channel.isForum:
case let .channel(channel) where channel.isForumOrMonoForum:
clipStyle = .roundedRect
default:
clipStyle = .round

View File

@ -283,7 +283,7 @@ private final class PeerListItemComponent: Component {
}
if let peer = component.peer {
let clipStyle: AvatarNodeClipStyle
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -2585,8 +2585,8 @@ final class StorageUsageScreenComponent: Component {
}
var chatLocation: NavigateToChatControllerParams.Location = .peer(peer)
if case let .channel(channel) = peer, channel.flags.contains(.isForum), let threadId = message.threadId {
chatLocation = .replyThread(ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
if case let .channel(channel) = peer, channel.isForumOrMonoForum, let threadId = message.threadId {
chatLocation = .replyThread(ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
}
component.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
@ -2688,8 +2688,8 @@ final class StorageUsageScreenComponent: Component {
}
var chatLocation: NavigateToChatControllerParams.Location = .peer(peer)
if case let .channel(channel) = peer, channel.flags.contains(.isForum), let threadId = message.threadId {
chatLocation = .replyThread(ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
if case let .channel(channel) = peer, channel.isForumOrMonoForum, let threadId = message.threadId {
chatLocation = .replyThread(ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
}
component.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(

View File

@ -913,7 +913,7 @@ public final class PeerListItemComponent: Component {
if let peer = component.peer {
let clipStyle: AvatarNodeClipStyle
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
clipStyle = .roundedRect
} else {
clipStyle = .round

View File

@ -2808,7 +2808,7 @@ final class StoryItemSetContainerSendMessage {
let context = component.context
switch navigation {
case let .chat(_, subject, peekData):
if case let .channel(channel) = peerId, channel.flags.contains(.isForum) {
if case let .channel(channel) = peerId, channel.isForumOrMonoForum {
controller.dismissWithoutTransitionOut()
context.sharedContext.navigateToForumChannel(context: context, peerId: peerId.id, navigationController: navigationController)
} else {

View File

@ -325,7 +325,7 @@ final class AuthorizedApplicationContext {
let chatLocation: NavigateToChatControllerParams.Location
if let _ = threadData, let threadId = firstMessage.threadId {
chatLocation = .replyThread(ChatReplyThreadMessage(
peerId: firstMessage.id.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
peerId: firstMessage.id.peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
).normalized)
} else {
guard let peer = firstMessage.peers[firstMessage.id.peerId] else {
@ -941,7 +941,7 @@ final class AuthorizedApplicationContext {
let chatLocation: NavigateToChatControllerParams.Location
if let threadId = threadId {
chatLocation = .replyThread(ChatReplyThreadMessage(
peerId: peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
peerId: peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false
))
} else {
chatLocation = .peer(peer)

View File

@ -586,7 +586,7 @@ extension ChatControllerImpl {
if let previous = strongSelf.peerView, let group = previous.peers[previous.peerId] as? TelegramGroup, group.migrationReference == nil, let updatedGroup = peerView.peers[peerView.peerId] as? TelegramGroup, let migrationReference = updatedGroup.migrationReference {
upgradedToPeerId = migrationReference.peerId
}
if let previous = strongSelf.peerView, let channel = previous.peers[previous.peerId] as? TelegramChannel, !channel.flags.contains(.isForum), let updatedChannel = peerView.peers[peerView.peerId] as? TelegramChannel, updatedChannel.flags.contains(.isForum) {
if let previous = strongSelf.peerView, let channel = previous.peers[previous.peerId] as? TelegramChannel, !channel.isForumOrMonoForum, let updatedChannel = peerView.peers[peerView.peerId] as? TelegramChannel, updatedChannel.isForumOrMonoForum {
movedToForumTopics = true
}
@ -1133,7 +1133,7 @@ extension ChatControllerImpl {
}
let savedMessagesPeerId: PeerId?
if case let .replyThread(replyThreadMessage) = chatLocation, (replyThreadMessage.peerId == context.account.peerId || replyThreadMessage.isMonoforum) {
if case let .replyThread(replyThreadMessage) = chatLocation, (replyThreadMessage.peerId == context.account.peerId || replyThreadMessage.isMonoforumPost) {
savedMessagesPeerId = PeerId(replyThreadMessage.threadId)
} else {
savedMessagesPeerId = nil
@ -1625,7 +1625,7 @@ extension ChatControllerImpl {
}
})
if let replyThreadId, let channel = renderedPeer?.peer as? TelegramChannel, channel.isForum, strongSelf.nextChannelToReadDisposable == nil {
if let replyThreadId, let channel = renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum, strongSelf.nextChannelToReadDisposable == nil {
strongSelf.nextChannelToReadDisposable = (combineLatest(queue: .mainQueue(),
strongSelf.context.engine.peers.getNextUnreadForumTopic(peerId: channel.id, topicId: Int32(clamping: replyThreadId)),
ApplicationSpecificNotice.getNextChatSuggestionTip(accountManager: strongSelf.context.sharedContext.accountManager)
@ -1750,7 +1750,7 @@ extension ChatControllerImpl {
let isForum = self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|> map { peer -> Bool in
if case let .channel(channel) = peer {
return channel.flags.contains(.isForum)
return channel.isForumOrMonoForum
} else {
return false
}
@ -2464,7 +2464,7 @@ extension ChatControllerImpl {
}
if case let .replyThread(replyThreadMessageId) = strongSelf.chatLocation {
if let channel = combinedInitialData.initialData?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = combinedInitialData.initialData?.peer as? TelegramChannel, channel.isForumOrMonoForum {
pinnedMessageId = nil
} else {
pinnedMessageId = replyThreadMessageId.effectiveTopId
@ -6247,7 +6247,7 @@ extension ChatControllerImpl {
channelMessageId: nil,
isChannelPost: false,
isForumPost: true,
isMonoforum: isMonoforum,
isMonoforumPost: isMonoforum,
maxMessage: nil,
maxReadIncomingMessageId: nil,
maxReadOutgoingMessageId: nil,
@ -6718,7 +6718,7 @@ extension ChatControllerImpl {
channelMessageId: nil,
isChannelPost: false,
isForumPost: true,
isMonoforum: false,
isMonoforumPost: false,
maxMessage: nil,
maxReadIncomingMessageId: nil,
maxReadOutgoingMessageId: nil,

View File

@ -143,8 +143,8 @@ extension ChatControllerImpl {
self.dismiss()
let navigateToLocation: NavigateToChatControllerParams.Location
if let message = messages.first, let threadId = message.threadId, let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum) {
navigateToLocation = .replyThread(ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false,maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
if let message = messages.first, let threadId = message.threadId, let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.isForumOrMonoForum {
navigateToLocation = .replyThread(ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false,maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
} else {
navigateToLocation = .peer(peer)
}
@ -177,9 +177,9 @@ extension ChatControllerImpl {
var chatLocation: NavigateToChatControllerParams.Location = .peer(peer)
var preloadChatLocation: ChatLocation = .peer(id: peer.id)
var displayMessageNotFoundToast = false
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
if let message = message, let threadId = message.threadId {
let replyThreadMessage = ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false)
let replyThreadMessage = ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false)
chatLocation = .replyThread(replyThreadMessage)
preloadChatLocation = .replyThread(message: replyThreadMessage)
} else {

View File

@ -426,7 +426,7 @@ extension ChatControllerImpl {
if let infoController = self.context.sharedContext.makePeerInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, peer: peer, mode: .forumTopic(thread: replyThreadMessage), avatarInitiallyExpanded: false, fromChat: true, requestsContext: nil) {
self.effectiveNavigationController?.pushViewController(infoController)
}
} else if let channel = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum), case let .replyThread(message) = self.chatLocation {
} else if let channel = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum, case let .replyThread(message) = self.chatLocation {
if let infoController = self.context.sharedContext.makePeerInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, peer: channel, mode: .forumTopic(thread: message), avatarInitiallyExpanded: false, fromChat: true, requestsContext: self.inviteRequestsContext) {
self.effectiveNavigationController?.pushViewController(infoController)
}

View File

@ -224,7 +224,7 @@ extension ChatControllerImpl {
}
})
} else {
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
self.effectiveNavigationController?.pushViewController(ChatListControllerImpl(context: self.context, location: .forum(peerId: channel.id), controlsHistoryPreload: false, enableDebugActions: false))
} else {
self.effectiveNavigationController?.pushViewController(ChatControllerImpl(context: self.context, chatLocation: .peer(id: peer.id), subject: subject))

View File

@ -591,6 +591,7 @@ func updateChatPresentationInterfaceStateImpl(
if selfController.chatDisplayNode.historyNode.chatLocation != selfController.presentationInterfaceState.chatLocation {
selfController.chatLocation = selfController.presentationInterfaceState.chatLocation
selfController.chatDisplayNode.chatLocation = selfController.presentationInterfaceState.chatLocation
selfController.reloadChatLocation()
selfController.reloadCachedData()
selfController.chatDisplayNode.historyNode.updateChatLocation(chatLocation: selfController.presentationInterfaceState.chatLocation)

View File

@ -3044,7 +3044,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return .none
}
}
if case .peer = strongSelf.chatLocation, let channel = strongSelf.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if case .peer = strongSelf.chatLocation, let channel = strongSelf.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum {
if message.threadId == nil {
return .none
}
@ -6131,7 +6131,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
let chatLocation: ChatLocation
if let threadId {
chatLocation = .replyThread(message: ChatReplyThreadMessage(peerId: peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
chatLocation = .replyThread(message: ChatReplyThreadMessage(peerId: peerId, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false))
} else {
chatLocation = .peer(id: peerId)
}
@ -7032,7 +7032,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
interfaceState = interfaceState.withUpdatedHistoryScrollState(scrollState)
}
interfaceState = interfaceState.withUpdatedInputLanguage(self.chatDisplayNode.currentTextInputLanguage)
if case .peer = self.chatLocation, let channel = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if case .peer = self.chatLocation, let channel = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum {
interfaceState = interfaceState.withUpdatedComposeInputState(ChatTextInputState()).withUpdatedReplyMessageSubject(nil).withUpdatedSendMessageEffect(nil)
}
let _ = ChatInterfaceState.update(engine: self.context.engine, peerId: peerId, threadId: threadId, { _ in
@ -8610,7 +8610,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self?.playShakeAnimation()
}
} else if let navigationController = strongSelf.effectiveNavigationController {
if case let .channel(channel) = peerId, channel.flags.contains(.isForum) {
if case let .channel(channel) = peerId, channel.isForumOrMonoForum {
strongSelf.context.sharedContext.navigateToForumChannel(context: strongSelf.context, peerId: peerId.id, navigationController: navigationController)
} else {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peerId), subject: subject, updateTextInputState: !peerId.id.isGroupOrChannel ? textInputState : nil, keepStack: .always, peekData: peekData))

View File

@ -135,7 +135,7 @@ class HistoryNodeContainer: ASDisplayNode {
class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
let context: AccountContext
let chatLocation: ChatLocation
var chatLocation: ChatLocation
let controllerInteraction: ChatControllerInteraction
private weak var controller: ChatControllerImpl?
@ -2964,7 +2964,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
channelMessageId: nil,
isChannelPost: false,
isForumPost: false,
isMonoforum: false,
isMonoforumPost: false,
maxMessage: nil,
maxReadIncomingMessageId: nil,
maxReadOutgoingMessageId: nil,

View File

@ -102,7 +102,7 @@ func chatHistoryViewForLocation(
if tag != nil {
requestAroundId = true
}
if case let .replyThread(message) = chatLocation, (message.peerId == context.account.peerId || message.isMonoforum) {
if case let .replyThread(message) = chatLocation, (message.peerId == context.account.peerId || message.isMonoforumPost) {
preFixedReadState = .peer([:])
}

View File

@ -315,7 +315,7 @@ func canReplyInChat(_ chatPresentationInterfaceState: ChatPresentationInterfaceS
}
}
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
if let threadData = chatPresentationInterfaceState.threadData {
if threadData.isClosed {
var canManage = false
@ -722,7 +722,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
let message = messages[0]
if case .peer = chatPresentationInterfaceState.chatLocation, let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if case .peer = chatPresentationInterfaceState.chatLocation, let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum {
if message.threadId == nil {
canReply = false
}

View File

@ -340,22 +340,6 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
}
}
}
if channel.flags.contains(.isForum) {
/*if let _ = chatPresentationInterfaceState.threadData {
} else {
if chatPresentationInterfaceState.interfaceState.replyMessageSubject == nil {
if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) {
return (currentPanel, nil)
} else {
let panel = ChatRestrictedInputPanelNode()
panel.context = context
panel.interfaceInteraction = interfaceInteraction
return (panel, nil)
}
}
}*/
}
} else if let group = peer as? TelegramGroup {
switch group.membership {
case .Removed, .Left:

View File

@ -99,7 +99,7 @@ func rightNavigationButtonForChatInterfaceState(context: AccountContext, present
}
}
if let channel = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum), let moreInfoNavigationButton = moreInfoNavigationButton {
if let channel = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum, let moreInfoNavigationButton = moreInfoNavigationButton {
if case .replyThread = presentationInterfaceState.chatLocation {
} else {
if case .pinnedMessages = presentationInterfaceState.subject {
@ -155,7 +155,7 @@ func rightNavigationButtonForChatInterfaceState(context: AccountContext, present
}
if case .replyThread = presentationInterfaceState.chatLocation {
if let channel = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum {
} else if hasMessages {
if case .search = currentButton?.action {
return currentButton

View File

@ -120,7 +120,7 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
}
}
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum {
if let threadData = chatPresentationInterfaceState.threadData {
if threadData.isClosed {
var canManage = false
@ -167,7 +167,7 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
}
}
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum {
let topicListDisplayMode = chatPresentationInterfaceState.topicListDisplayMode ?? .top
if case .top = topicListDisplayMode, let peerId = chatPresentationInterfaceState.chatLocation.peerId {
if let currentPanel = currentPanel as? ChatTopicListTitleAccessoryPanelNode {
@ -252,7 +252,7 @@ func sidePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceState
}
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum {
let topicListDisplayMode = chatPresentationInterfaceState.topicListDisplayMode ?? .top
if case .side = topicListDisplayMode {
return AnyComponentWithIdentity(

View File

@ -103,7 +103,7 @@ private func peerButtons(_ state: ChatPresentationInterfaceState) -> [ChatReport
}
}
} else if let peer = state.renderedPeer?.chatMainPeer {
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum {
if let threadData = state.threadData {
if threadData.isClosed {
var canManage = false

View File

@ -98,7 +98,7 @@ final class ChatRestrictedInputPanelNode: ChatInputPanelNode {
} else if let threadData = interfaceState.threadData, threadData.isClosed {
iconImage = PresentationResourcesChat.chatPanelLockIcon(interfaceState.theme)
self.textNode.attributedText = NSAttributedString(string: interfaceState.strings.Chat_PanelTopicClosedText, font: Font.regular(15.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
} else if let channel = interfaceState.renderedPeer?.peer as? TelegramChannel, channel.flags.contains(.isForum), case .peer = interfaceState.chatLocation {
} else if let channel = interfaceState.renderedPeer?.peer as? TelegramChannel, channel.isForumOrMonoForum, case .peer = interfaceState.chatLocation {
if let replyMessage = interfaceState.replyMessage, let threadInfo = replyMessage.associatedThreadInfo {
self.textNode.attributedText = NSAttributedString(string: interfaceState.strings.Chat_TopicIsClosedLabel(threadInfo.title).string, font: Font.regular(15.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
} else {

View File

@ -1923,7 +1923,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
} else {
placeholder = interfaceState.strings.Conversation_InputTextPlaceholderReply
}
} else if let channel = peer as? TelegramChannel, channel.isForum, let forumTopicData = interfaceState.forumTopicData {
} else if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum, let forumTopicData = interfaceState.forumTopicData {
if let replyMessage = interfaceState.replyMessage, let threadInfo = replyMessage.associatedThreadInfo {
placeholder = interfaceState.strings.Chat_InputPlaceholderReplyInTopic(threadInfo.title).string
} else {

View File

@ -229,7 +229,7 @@ final class WidgetDataContext {
}
var isForum = false
if let peer = peer as? TelegramChannel, peer.flags.contains(.isForum) {
if let peer = peer as? TelegramChannel, peer.isForumOrMonoForum {
isForum = true
}

View File

@ -822,7 +822,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
})
}
case let .channelMessage(id, timecode):
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
let messageId = MessageId(peerId: channel.id, namespace: Namespaces.Message.Cloud, id: id)
return context.engine.messages.getMessagesLoadIfNecessary([messageId], strategy: .cloud(skipLocal: false))
|> `catch` { _ in
@ -841,7 +841,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
return .progress
case let .result(info):
if let _ = info {
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: messageId))
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: messageId))
} else {
return .result(.peer(peer._asPeer(), .chat(textInputState: nil, subject: nil, peekData: nil)))
}
@ -858,7 +858,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
case let .replyThread(id, replyId):
let replyThreadMessageId = MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id)
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
return context.engine.peers.fetchForumChannelTopic(id: channel.id, threadId: Int64(replyThreadMessageId.id))
|> map { result -> ResolveInternalUrlResult in
switch result {
@ -866,7 +866,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
return .progress
case let .result(info):
if let _ = info {
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: Int64(replyThreadMessageId.id), channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: MessageId(peerId: channel.id, namespace: Namespaces.Message.Cloud, id: replyId)))
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: Int64(replyThreadMessageId.id), channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: MessageId(peerId: channel.id, namespace: Namespaces.Message.Cloud, id: replyId)))
} else {
return .result(.peer(peer._asPeer(), .chat(textInputState: nil, subject: nil, peekData: nil)))
}
@ -947,7 +947,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
return .single(.progress) |> then(foundPeer
|> mapToSignal { foundPeer -> Signal<ResolveInternalUrlResult, NoError> in
if let foundPeer = foundPeer {
if case let .channel(channel) = foundPeer, channel.flags.contains(.isForum) {
if case let .channel(channel) = foundPeer, channel.isForumOrMonoForum {
if let threadId = threadId {
return context.engine.peers.fetchForumChannelTopic(id: channel.id, threadId: Int64(threadId))
|> map { result -> ResolveInternalUrlResult in
@ -956,7 +956,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
return .progress
case let .result(info):
if let _ = info {
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: Int64(threadId), channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: messageId))
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: Int64(threadId), channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: messageId))
} else {
return .result(.peer(peer?._asPeer(), .chat(textInputState: nil, subject: nil, peekData: nil)))
}
@ -980,7 +980,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
return .progress
case let .result(info):
if let _ = info {
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforum: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: messageId))
return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: messageId))
} else {
return .result(.peer(peer?._asPeer(), .chat(textInputState: nil, subject: nil, peekData: nil)))
}