diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 86a748c929..be628a147f 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -2945,7 +2945,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { } } if let isForum = groupType.isForum { - if isForum != channel.flags.contains(.isForum) { + if isForum != channel.isForum { match = false } } diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index cf42c530ac..ad864f6be2 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -2555,7 +2555,7 @@ public final class ChatListNode: ListView { } } if let isForum = groupType.isForum { - if isForum != channel.flags.contains(.isForum) { + if isForum != channel.isForum { match = false } } diff --git a/submodules/PeerInfoUI/Sources/ChannelAdminController.swift b/submodules/PeerInfoUI/Sources/ChannelAdminController.swift index 8b24fd7ab0..fb9030c920 100644 --- a/submodules/PeerInfoUI/Sources/ChannelAdminController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelAdminController.swift @@ -665,7 +665,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s ] case .group: isGroup = true - if channel.flags.contains(.isForum) { + if channel.isForum { rightsOrder = [ .direct(.canChangeInfo), .direct(.canDeleteMessages), @@ -732,7 +732,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s enabled = right == .canBeAnonymous - itemTitle = stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, isChannel: isChannel, isForum: channel.flags.contains(.isForum), defaultBannedRights: channel.defaultBannedRights) + itemTitle = stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, isChannel: isChannel, isForum: channel.isForum, defaultBannedRights: channel.defaultBannedRights) isSelected = currentRightsFlags.contains(right) case let .sub(type, subRights): let filteredSubRights = subRights.filter({ accountUserRightsFlags.contains($0) }) @@ -756,7 +756,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s for subRight in filteredSubRights { let subRightEnabled = true - subItems.append(AdminSubPermission(title: stringForRight(strings: presentationData.strings, right: subRight, isGroup: isGroup, isChannel: isChannel, isForum: channel.flags.contains(.isForum), defaultBannedRights: channel.defaultBannedRights), flags: subRight, isSelected: currentRightsFlags.contains(subRight), isEnabled: enabled && subRightEnabled)) + subItems.append(AdminSubPermission(title: stringForRight(strings: presentationData.strings, right: subRight, isGroup: isGroup, isChannel: isChannel, isForum: channel.isForum, defaultBannedRights: channel.defaultBannedRights), flags: subRight, isSelected: currentRightsFlags.contains(subRight), isEnabled: enabled && subRightEnabled)) } } @@ -811,7 +811,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s enabled = !state.updating && admin.id != accountPeerId && !rightEnabledByDefault(channelPeer: .channel(channel), right: right) - itemTitle = stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, isChannel: isChannel, isForum: channel.flags.contains(.isForum), defaultBannedRights: channel.defaultBannedRights) + itemTitle = stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, isChannel: isChannel, isForum: channel.isForum, defaultBannedRights: channel.defaultBannedRights) isSelected = currentRightsFlags.contains(right) case let .sub(type, subRights): let filteredSubRights = subRights.filter({ accountUserRightsFlags.contains($0) }) @@ -835,7 +835,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s for subRight in filteredSubRights { let subRightEnabled = !state.updating && admin.id != accountPeerId && !rightEnabledByDefault(channelPeer: .channel(channel), right: subRight) - subItems.append(AdminSubPermission(title: stringForRight(strings: presentationData.strings, right: subRight, isGroup: isGroup, isChannel: isChannel, isForum: channel.flags.contains(.isForum), defaultBannedRights: channel.defaultBannedRights), flags: subRight, isSelected: currentRightsFlags.contains(subRight), isEnabled: enabled && subRightEnabled)) + subItems.append(AdminSubPermission(title: stringForRight(strings: presentationData.strings, right: subRight, isGroup: isGroup, isChannel: isChannel, isForum: channel.isForum, defaultBannedRights: channel.defaultBannedRights), flags: subRight, isSelected: currentRightsFlags.contains(subRight), isEnabled: enabled && subRightEnabled)) } } @@ -878,7 +878,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s switch right { case let .direct(right): - itemTitle = stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, isChannel: isChannel, isForum: channel.flags.contains(.isForum), defaultBannedRights: channel.defaultBannedRights) + itemTitle = stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, isChannel: isChannel, isForum: channel.isForum, defaultBannedRights: channel.defaultBannedRights) isSelected = adminInfo.rights.rights.contains(right) case let .sub(type, subRights): let filteredSubRights = subRights @@ -900,7 +900,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s for subRight in filteredSubRights { let subRightEnabled = false - subItems.append(AdminSubPermission(title: stringForRight(strings: presentationData.strings, right: subRight, isGroup: isGroup, isChannel: isChannel, isForum: channel.flags.contains(.isForum), defaultBannedRights: channel.defaultBannedRights), flags: subRight, isSelected: adminInfo.rights.rights.contains(subRight), isEnabled: enabled && subRightEnabled)) + subItems.append(AdminSubPermission(title: stringForRight(strings: presentationData.strings, right: subRight, isGroup: isGroup, isChannel: isChannel, isForum: channel.isForum, defaultBannedRights: channel.defaultBannedRights), flags: subRight, isSelected: adminInfo.rights.rights.contains(subRight), isEnabled: enabled && subRightEnabled)) } } diff --git a/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift b/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift index bdd377d175..b18a9f3f24 100644 --- a/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift @@ -345,7 +345,7 @@ private func channelBannedMemberControllerEntries(presentationData: Presentation } } - entries.append(.rightItem(presentationData.theme, index, stringForGroupPermission(strings: presentationData.strings, right: right, isForum: channel.flags.contains(.isForum)), right, isSelected, defaultEnabled && !state.updating, subItems, state.expandedPermissions.contains(right))) + entries.append(.rightItem(presentationData.theme, index, stringForGroupPermission(strings: presentationData.strings, right: right, isForum: channel.isForum), right, isSelected, defaultEnabled && !state.updating, subItems, state.expandedPermissions.contains(right))) index += 1 } diff --git a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift index 3e283a4dd9..85c54f41a8 100644 --- a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift @@ -347,7 +347,7 @@ public func channelDiscussionGroupSetupController(context: AccountContext, updat let presentationData = context.sharedContext.currentPresentationData.with { $0 } - if case let .channel(channel) = groupPeer, channel.flags.contains(.isForum) { + if case let .channel(channel) = groupPeer, channel.isForum { let text = presentationData.strings.PeerInfo_TopicsLimitedDiscussionGroups presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .universal(animation: "anim_topics", scale: 0.066, colors: [:], title: nil, text: text, customUndoText: nil, timeout: nil), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil) return diff --git a/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift b/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift index 5847588a2e..814f2d52da 100644 --- a/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift @@ -595,7 +595,7 @@ private let internal_allPossibleGroupPermissionList: [(TelegramChatBannedRightsF public func allGroupPermissionList(peer: EnginePeer, expandMedia: Bool) -> [(TelegramChatBannedRightsFlags, TelegramChannelPermission)] { var result: [(TelegramChatBannedRightsFlags, TelegramChannelPermission)] - if case let .channel(channel) = peer, channel.flags.contains(.isForum) { + if case let .channel(channel) = peer, channel.isForum { result = [ (.banSendText, .banMembers), (.banSendMedia, .banMembers), @@ -711,7 +711,7 @@ private func channelPermissionsControllerEntries(context: AccountContext, presen } } - entries.append(.permission(presentationData.theme, rightIndex, stringForGroupPermission(strings: presentationData.strings, right: rights, isForum: channel.flags.contains(.isForum)), isSelected, rights, enabled, subItems, state.expandedPermissions.contains(rights))) + entries.append(.permission(presentationData.theme, rightIndex, stringForGroupPermission(strings: presentationData.strings, right: rights, isForum: channel.isForum), isSelected, rights, enabled, subItems, state.expandedPermissions.contains(rights))) rightIndex += 1 } diff --git a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift index 2e9687ce88..75b2a2a8b4 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift @@ -812,7 +812,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, if let message = transaction.getMessage(replyToMessageId.messageId) { if let threadIdValue = message.threadId { if threadIdValue == 1 { - if let channel = transaction.getPeer(message.id.peerId) as? TelegramChannel, channel.flags.contains(.isForum) { + if let peer = transaction.getPeer(message.id.peerId), peer.isForum { threadId = threadIdValue } else { if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .group = channel.info { @@ -829,7 +829,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, } } - if threadId == nil, let channel = transaction.getPeer(peerId) as? TelegramChannel, channel.flags.contains(.isForum) { + if threadId == nil, let peer = transaction.getPeer(peerId), peer.isForum { threadId = 1 } @@ -1074,7 +1074,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, augmentedMediaList = augmentedMediaList.map(convertForwardedMediaForSecretChat) } - if threadId == nil, let channel = transaction.getPeer(peerId) as? TelegramChannel, channel.flags.contains(.isForum) { + if threadId == nil, let peer = transaction.getPeer(peerId), peer.isForum { threadId = 1 } diff --git a/submodules/TelegramCore/Sources/State/ManagedConsumePersonalMessagesActions.swift b/submodules/TelegramCore/Sources/State/ManagedConsumePersonalMessagesActions.swift index 23e20e5ec0..0815f236b0 100644 --- a/submodules/TelegramCore/Sources/State/ManagedConsumePersonalMessagesActions.swift +++ b/submodules/TelegramCore/Sources/State/ManagedConsumePersonalMessagesActions.swift @@ -534,7 +534,7 @@ func managedSynchronizeMessageHistoryTagSummaries(postbox: Postbox, network: Net private func synchronizeMessageHistoryTagSummary(accountPeerId: PeerId, postbox: Postbox, network: Network, entry: InvalidatedMessageHistoryTagsSummaryEntry) -> Signal { return postbox.transaction { transaction -> Signal in if let threadId = entry.key.threadId { - if let peer = transaction.getPeer(entry.key.peerId) as? TelegramChannel, peer.flags.contains(.isForum), !peer.flags.contains(.isMonoforum), let inputPeer = apiInputPeer(peer) { + if let peer = transaction.getPeer(entry.key.peerId), peer.isForum, !peer.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 in diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/ApplyMaxReadIndexInteractively.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ApplyMaxReadIndexInteractively.swift index be6fa38686..7b6a8bac02 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/ApplyMaxReadIndexInteractively.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ApplyMaxReadIndexInteractively.swift @@ -143,7 +143,7 @@ func _internal_toggleForumThreadUnreadMarkInteractively(transaction: Transaction guard let peer = transaction.getPeer(peerId) else { return } - guard let channel = peer as? TelegramChannel, channel.isForumOrMonoForum else { + guard peer.isForumOrMonoForum else { return } guard var data = transaction.getMessageHistoryThreadInfo(peerId: peerId, threadId: threadId)?.data.get(MessageHistoryThreadData.self) else { @@ -161,9 +161,9 @@ func _internal_toggleForumThreadUnreadMarkInteractively(transaction: Transaction transaction.setMessageHistoryThreadInfo(peerId: peerId, threadId: threadId, info: entry) } - if channel.flags.contains(.isForum) { - } else if channel.flags.contains(.isMonoforum) { - if let inputPeer = apiInputPeer(channel), let subPeer = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer) { + if peer.isForum { + } else if peer.isMonoForum { + if let inputPeer = apiInputPeer(peer), let subPeer = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer) { let _ = network.request(Api.functions.messages.markDialogUnread(flags: 1 << 0, parentPeer: inputPeer, peer: .inputDialogPeer(peer: subPeer))).start() } } @@ -178,12 +178,12 @@ func _internal_toggleForumThreadUnreadMarkInteractively(transaction: Transaction transaction.setMessageHistoryThreadInfo(peerId: peerId, threadId: threadId, info: entry) } - if channel.flags.contains(.isForum) { - if let inputPeer = apiInputPeer(channel) { + if peer.isForum { + if let inputPeer = apiInputPeer(peer) { let _ = network.request(Api.functions.messages.readDiscussion(peer: inputPeer, msgId: Int32(clamping: threadId), readMaxId: messageIndex.id.id)).start() } - } else if channel.flags.contains(.isMonoforum) { - if let inputPeer = apiInputPeer(channel), let subPeer = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer) { + } else if peer.isMonoForum { + if let inputPeer = apiInputPeer(peer), let subPeer = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer) { let _ = network.request(Api.functions.messages.readSavedHistory(parentPeer: inputPeer, peer: subPeer, maxId: messageIndex.id.id)).start() } } @@ -195,7 +195,7 @@ func _internal_markForumThreadAsReadInteractively(transaction: Transaction, netw guard let peer = transaction.getPeer(peerId) else { return } - guard let channel = peer as? TelegramChannel, channel.isForumOrMonoForum else { + guard peer.isForumOrMonoForum else { return } guard var data = transaction.getMessageHistoryThreadInfo(peerId: peerId, threadId: threadId)?.data.get(MessageHistoryThreadData.self) else { @@ -214,12 +214,12 @@ func _internal_markForumThreadAsReadInteractively(transaction: Transaction, netw transaction.setMessageHistoryThreadInfo(peerId: peerId, threadId: threadId, info: entry) } - if channel.flags.contains(.isForum) { - if let inputPeer = apiInputPeer(channel) { + if peer.isForum { + if let inputPeer = apiInputPeer(peer) { let _ = network.request(Api.functions.messages.readDiscussion(peer: inputPeer, msgId: Int32(clamping: threadId), readMaxId: messageIndex.id.id)).start() } - } else if channel.flags.contains(.isMonoforum) { - if let inputPeer = apiInputPeer(channel), let subPeer = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer) { + } else if peer.isMonoForum { + if let inputPeer = apiInputPeer(peer), let subPeer = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer) { let _ = network.request(Api.functions.messages.readSavedHistory(parentPeer: inputPeer, peer: subPeer, maxId: messageIndex.id.id)).start() } } @@ -238,7 +238,7 @@ func _internal_togglePeerUnreadMarkInteractively(transaction: Transaction, netwo displayAsRegularChat = cachedData.viewForumAsMessages.knownValue ?? false } - if let channel = peer as? TelegramChannel, channel.isForumOrMonoForum, !displayAsRegularChat { + if peer.isForumOrMonoForum, !displayAsRegularChat { for item in transaction.getMessageHistoryThreadIndex(peerId: peerId, limit: 20) { guard var data = transaction.getMessageHistoryThreadInfo(peerId: peerId, threadId: item.threadId)?.data.get(MessageHistoryThreadData.self) else { continue @@ -256,12 +256,12 @@ func _internal_togglePeerUnreadMarkInteractively(transaction: Transaction, netwo transaction.setMessageHistoryThreadInfo(peerId: peerId, threadId: item.threadId, info: entry) } - if channel.flags.contains(.isForum) { - if let inputPeer = apiInputPeer(channel) { + if peer.isForum { + if let inputPeer = apiInputPeer(peer) { let _ = network.request(Api.functions.messages.readDiscussion(peer: inputPeer, msgId: Int32(clamping: item.threadId), readMaxId: messageIndex.id.id)).start() } - } else if channel.flags.contains(.isMonoforum) { - if let inputPeer = apiInputPeer(channel), let subPeer = transaction.getPeer(PeerId(item.threadId)).flatMap(apiInputPeer) { + } else if peer.isMonoForum { + if let inputPeer = apiInputPeer(peer), let subPeer = transaction.getPeer(PeerId(item.threadId)).flatMap(apiInputPeer) { let _ = network.request(Api.functions.messages.readSavedHistory(parentPeer: inputPeer, peer: subPeer, maxId: messageIndex.id.id)).start() } }