mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-25 17:43:18 +00:00
mac updater [skip ci]
This commit is contained in:
parent
e654d6095e
commit
eb686ae189
@ -78,7 +78,7 @@ public enum AppUpdateDownloadResult {
|
||||
case finished(String)
|
||||
}
|
||||
|
||||
public func downloadAppUpdate(account: Account, source: String, fileName: String) -> Signal<AppUpdateDownloadResult, InternalUpdaterError> {
|
||||
public func downloadAppUpdate(account: Account, source: String, messageId: Int32) -> Signal<AppUpdateDownloadResult, InternalUpdaterError> {
|
||||
return resolvePeerByName(account: account, name: source)
|
||||
|> castError(InternalUpdaterError.self)
|
||||
|> mapToSignal { peerId -> Signal<Peer?, InternalUpdaterError> in
|
||||
@ -87,12 +87,12 @@ public func downloadAppUpdate(account: Account, source: String, fileName: String
|
||||
} |> castError(InternalUpdaterError.self)
|
||||
}
|
||||
|> mapToSignal { peer in
|
||||
if let peer = peer, let inputPeer = apiInputPeer(peer) {
|
||||
return account.network.request(Api.functions.messages.getHistory(peer: inputPeer, offsetId: 0, offsetDate: 0, addOffset: 0, limit: 10, maxId: Int32.max, minId: 0, hash: 0))
|
||||
if let peer = peer, let inputChannel = apiInputChannel(peer) {
|
||||
return account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(id: messageId)]))
|
||||
|> retryRequest
|
||||
|> castError(InternalUpdaterError.self)
|
||||
|> mapToSignal { result in
|
||||
switch result {
|
||||
|> mapToSignal { messages in
|
||||
switch messages {
|
||||
case let .channelMessages(_, _, _, apiMessages, apiChats, apiUsers):
|
||||
|
||||
var peers: [PeerId: Peer] = [:]
|
||||
@ -113,11 +113,7 @@ public func downloadAppUpdate(account: Account, source: String, fileName: String
|
||||
}.sorted(by: {
|
||||
$0.id > $1.id
|
||||
}).first(where: { value -> Bool in
|
||||
if let file = value.media.first as? TelegramMediaFile, file.fileName == fileName {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
return value.media.first is TelegramMediaFile
|
||||
}).map { ($0, $0.media.first as! TelegramMediaFile )}
|
||||
|
||||
if let (message, media) = messageAndFile {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user