mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
inactive channels
This commit is contained in:
parent
97c2834506
commit
4c427c1c87
35
submodules/TelegramCore/Sources/InactiveChannels.swift
Normal file
35
submodules/TelegramCore/Sources/InactiveChannels.swift
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
import Foundation
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
public struct InactiveChannel : Equatable {
|
||||
public let peer: Peer
|
||||
public let lastActivityDate: Int32
|
||||
init(peer: Peer, lastActivityDate: Int32) {
|
||||
self.peer = peer
|
||||
self.lastActivityDate = lastActivityDate
|
||||
}
|
||||
public static func ==(lhs: InactiveChannel, rhs: InactiveChannel) -> Bool {
|
||||
return lhs.peer.isEqual(rhs.peer) && lhs.lastActivityDate == rhs.lastActivityDate
|
||||
}
|
||||
}
|
||||
|
||||
public func inactiveChannelList(network: Network) -> Signal<[InactiveChannel], NoError> {
|
||||
return network.request(Api.functions.channels.getInactiveChannels())
|
||||
|> retryRequest
|
||||
|> map { result in
|
||||
switch result {
|
||||
case let .inactiveChats(dates, chats, users):
|
||||
let channels = chats.compactMap {
|
||||
parseTelegramGroupOrChannel(chat: $0)
|
||||
}
|
||||
var inactive: [InactiveChannel] = []
|
||||
for (i, channel) in channels.enumerated() {
|
||||
inactive.append(InactiveChannel(peer: channel, lastActivityDate: dates[i]))
|
||||
}
|
||||
return inactive
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user