mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Wallpaper improvements
This commit is contained in:
@@ -152,3 +152,28 @@ func _internal_setChatWallpaper(account: Account, peerId: PeerId, wallpaper: Tel
|
||||
} |> switchToLatest
|
||||
}
|
||||
}
|
||||
|
||||
public enum SetExistingChatWallpaperError {
|
||||
case generic
|
||||
}
|
||||
|
||||
func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId) -> Signal<Void, SetExistingChatWallpaperError> {
|
||||
return account.postbox.transaction { transaction -> Peer? in
|
||||
return transaction.getPeer(messageId.peerId)
|
||||
}
|
||||
|> castError(SetExistingChatWallpaperError.self)
|
||||
|> mapToSignal { peer -> Signal<Void, SetExistingChatWallpaperError> in
|
||||
guard let peer = peer, let inputPeer = apiInputPeer(peer) else {
|
||||
return .complete()
|
||||
}
|
||||
let flags: Int32 = 1 << 1
|
||||
return account.network.request(Api.functions.messages.setChatWallPaper(flags: flags, peer: inputPeer, wallpaper: nil, settings: nil, id: messageId.id))
|
||||
|> `catch` { _ -> Signal<Api.Updates, SetExistingChatWallpaperError> in
|
||||
return .fail(.generic)
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<Void, SetExistingChatWallpaperError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user