mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-28 00:39:56 +00:00
Experimental chat list filtering
This commit is contained in:
@@ -139,10 +139,44 @@ public struct OperationLogTags {
|
||||
public static let SynchronizeEmojiKeywords = PeerOperationLogTag(value: 19)
|
||||
}
|
||||
|
||||
public struct LegacyPeerSummaryCounterTags: OptionSet, Sequence, Hashable {
|
||||
public var rawValue: Int32
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let regularChatsAndPrivateGroups = LegacyPeerSummaryCounterTags(rawValue: 1 << 0)
|
||||
public static let publicGroups = LegacyPeerSummaryCounterTags(rawValue: 1 << 1)
|
||||
public static let channels = LegacyPeerSummaryCounterTags(rawValue: 1 << 2)
|
||||
|
||||
public func makeIterator() -> AnyIterator<LegacyPeerSummaryCounterTags> {
|
||||
var index = 0
|
||||
return AnyIterator { () -> LegacyPeerSummaryCounterTags? in
|
||||
while index < 31 {
|
||||
let currentTags = self.rawValue >> UInt32(index)
|
||||
let tag = LegacyPeerSummaryCounterTags(rawValue: 1 << UInt32(index))
|
||||
index += 1
|
||||
if currentTags == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
if (currentTags & 1) != 0 {
|
||||
return tag
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension PeerSummaryCounterTags {
|
||||
static let regularChatsAndPrivateGroups = PeerSummaryCounterTags(rawValue: 1 << 0)
|
||||
static let publicGroups = PeerSummaryCounterTags(rawValue: 1 << 1)
|
||||
static let channels = PeerSummaryCounterTags(rawValue: 1 << 2)
|
||||
static let privateChat = PeerSummaryCounterTags(rawValue: 1 << 3)
|
||||
static let secretChat = PeerSummaryCounterTags(rawValue: 1 << 4)
|
||||
static let privateGroup = PeerSummaryCounterTags(rawValue: 1 << 5)
|
||||
static let bot = PeerSummaryCounterTags(rawValue: 1 << 6)
|
||||
static let channel = PeerSummaryCounterTags(rawValue: 1 << 7)
|
||||
static let publicGroup = PeerSummaryCounterTags(rawValue: 1 << 8)
|
||||
}
|
||||
|
||||
private enum PreferencesKeyValues: Int32 {
|
||||
|
||||
@@ -19,19 +19,30 @@ public let telegramPostboxSeedConfiguration: SeedConfiguration = {
|
||||
}
|
||||
|
||||
return SeedConfiguration(globalMessageIdsPeerIdNamespaces: globalMessageIdsPeerIdNamespaces, initializeChatListWithHole: (topLevel: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: 0), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1)), groups: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: 0), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1))), messageHoles: messageHoles, existingMessageTags: MessageTags.all, messageTagsWithSummary: MessageTags.unseenPersonalMessage, existingGlobalMessageTags: GlobalMessageTags.all, peerNamespacesRequiringMessageTextIndex: [Namespaces.Peer.SecretChat], peerSummaryCounterTags: { peer in
|
||||
if let peer = peer as? TelegramChannel {
|
||||
switch peer.info {
|
||||
case .group:
|
||||
if let addressName = peer.username, !addressName.isEmpty {
|
||||
return [.publicGroups]
|
||||
} else {
|
||||
return [.regularChatsAndPrivateGroups]
|
||||
}
|
||||
case .broadcast:
|
||||
return [.channels]
|
||||
if let peer = peer as? TelegramUser {
|
||||
if peer.botInfo != nil {
|
||||
return .bot
|
||||
} else {
|
||||
return .privateChat
|
||||
}
|
||||
} else if let _ = peer as? TelegramGroup {
|
||||
return .privateGroup
|
||||
} else if let _ = peer as? TelegramSecretChat {
|
||||
return .secretChat
|
||||
} else if let channel = peer as? TelegramChannel {
|
||||
switch channel.info {
|
||||
case .broadcast:
|
||||
return .channel
|
||||
case .group:
|
||||
if channel.username != nil {
|
||||
return .publicGroup
|
||||
} else {
|
||||
return .privateGroup
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return [.regularChatsAndPrivateGroups]
|
||||
assertionFailure()
|
||||
return .privateChat
|
||||
}
|
||||
}, additionalChatListIndexNamespace: Namespaces.Message.Cloud, messageNamespacesRequiringGroupStatsValidation: [Namespaces.Message.Cloud], defaultMessageNamespaceReadStates: [Namespaces.Message.Local: .idBased(maxIncomingReadId: 0, maxOutgoingReadId: 0, maxKnownId: 0, count: 0, markedUnread: false)], chatMessagesNamespaces: Set([Namespaces.Message.Cloud, Namespaces.Message.Local, Namespaces.Message.SecretIncoming]))
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user