Fix websites and recent sessions layout

This commit is contained in:
Ali
2019-12-16 19:37:19 +04:00
parent 573ac6ce7b
commit db5fb4b642
24 changed files with 5116 additions and 4107 deletions

View File

@@ -7,29 +7,43 @@ import TelegramApi
public struct InactiveChannel : Equatable {
public let peer: Peer
public let lastActivityDate: Int32
init(peer: Peer, lastActivityDate: Int32) {
public let participantsCount: Int32?
init(peer: Peer, lastActivityDate: Int32, participantsCount: Int32?) {
self.peer = peer
self.lastActivityDate = lastActivityDate
self.participantsCount = participantsCount
}
public static func ==(lhs: InactiveChannel, rhs: InactiveChannel) -> Bool {
return lhs.peer.isEqual(rhs.peer) && lhs.lastActivityDate == rhs.lastActivityDate
return lhs.peer.isEqual(rhs.peer) && lhs.lastActivityDate == rhs.lastActivityDate && lhs.participantsCount == rhs.participantsCount
}
}
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
|> retryRequest
|> map { result in
switch result {
case let .inactiveChats(dates, chats, users):
let channels = chats.compactMap {
parseTelegramGroupOrChannel(chat: $0)
}
var participantsCounts: [PeerId: Int32] = [:]
for chat in chats {
switch chat {
case let .channel(channel):
if let participantsCountValue = channel.participantsCount {
participantsCounts[chat.peerId] = channel.participantsCount
}
default:
break
}
}
var inactive: [InactiveChannel] = []
for (i, channel) in channels.enumerated() {
inactive.append(InactiveChannel(peer: channel, lastActivityDate: dates[i], participantsCount: participantsCounts[channel.id]))
}
return inactive
}
}
}

View File

@@ -15,6 +15,9 @@ public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChan
|> take(1)
|> castError(JoinChannelError.self)
|> mapToSignal { peer -> Signal<RenderedChannelParticipant?, JoinChannelError> in
#if DEBUG
return .fail(.tooMuchJoined)
#endif
if let inputChannel = apiInputChannel(peer) {
return account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
|> mapError { error -> JoinChannelError in