mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 12:17:53 +00:00
FetchChatList: skip deactivated groups
This commit is contained in:
parent
737e0c55f7
commit
40f7e805b8
@ -62,6 +62,21 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message],
|
|||||||
var referencedFolders: [PeerGroupId: PeerGroupUnreadCountersSummary] = [:]
|
var referencedFolders: [PeerGroupId: PeerGroupUnreadCountersSummary] = [:]
|
||||||
var itemIds: [PeerId] = []
|
var itemIds: [PeerId] = []
|
||||||
|
|
||||||
|
var peers: [PeerId: Peer] = [:]
|
||||||
|
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||||
|
for chat in apiChats {
|
||||||
|
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||||
|
peers[groupOrChannel.id] = groupOrChannel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for user in apiUsers {
|
||||||
|
let telegramUser = TelegramUser(user: user)
|
||||||
|
peers[telegramUser.id] = telegramUser
|
||||||
|
if let presence = TelegramUserPresence(apiUser: user) {
|
||||||
|
peerPresences[telegramUser.id] = presence
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for dialog in apiDialogs {
|
for dialog in apiDialogs {
|
||||||
let apiPeer: Api.Peer
|
let apiPeer: Api.Peer
|
||||||
let apiReadInboxMaxId: Int32
|
let apiReadInboxMaxId: Int32
|
||||||
@ -74,7 +89,17 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message],
|
|||||||
let apiNotificationSettings: Api.PeerNotifySettings
|
let apiNotificationSettings: Api.PeerNotifySettings
|
||||||
switch dialog {
|
switch dialog {
|
||||||
case let .dialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, peerNotificationSettings, pts, _, _):
|
case let .dialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, peerNotificationSettings, pts, _, _):
|
||||||
itemIds.append(peer.peerId)
|
if let peer = peers[peer.peerId] {
|
||||||
|
var isExluded = false
|
||||||
|
if let group = peer as? TelegramGroup {
|
||||||
|
if group.flags.contains(.deactivated) {
|
||||||
|
isExluded = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !isExluded {
|
||||||
|
itemIds.append(peer.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
apiPeer = peer
|
apiPeer = peer
|
||||||
apiTopMessage = topMessage
|
apiTopMessage = topMessage
|
||||||
apiReadInboxMaxId = readInboxMaxId
|
apiReadInboxMaxId = readInboxMaxId
|
||||||
@ -144,24 +169,9 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var peers: [Peer] = []
|
|
||||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
|
||||||
for chat in apiChats {
|
|
||||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
|
||||||
peers.append(groupOrChannel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for user in apiUsers {
|
|
||||||
let telegramUser = TelegramUser(user: user)
|
|
||||||
peers.append(telegramUser)
|
|
||||||
if let presence = TelegramUserPresence(apiUser: user) {
|
|
||||||
peerPresences[telegramUser.id] = presence
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ParsedDialogs(
|
return ParsedDialogs(
|
||||||
itemIds: itemIds,
|
itemIds: itemIds,
|
||||||
peers: peers,
|
peers: Array(peers.values),
|
||||||
peerPresences: peerPresences,
|
peerPresences: peerPresences,
|
||||||
|
|
||||||
notificationSettings: notificationSettings,
|
notificationSettings: notificationSettings,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user