mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various improvements
This commit is contained in:
@@ -2,6 +2,25 @@ import Postbox
|
||||
import TelegramApi
|
||||
import MtProtoKit
|
||||
|
||||
public func smallestVideoRepresentation(_ representations: [TelegramMediaImage.VideoRepresentation]) -> TelegramMediaImage.VideoRepresentation? {
|
||||
if representations.count == 0 {
|
||||
return nil
|
||||
} else {
|
||||
var dimensions = representations[0].dimensions
|
||||
var index = 0
|
||||
|
||||
for i in 1 ..< representations.count {
|
||||
let representationDimensions = representations[i].dimensions
|
||||
if representationDimensions.width < dimensions.width && representationDimensions.height < dimensions.height {
|
||||
dimensions = representationDimensions
|
||||
index = i
|
||||
}
|
||||
}
|
||||
|
||||
return representations[index]
|
||||
}
|
||||
}
|
||||
|
||||
public func smallestImageRepresentation(_ representations: [TelegramMediaImageRepresentation]) -> TelegramMediaImageRepresentation? {
|
||||
if representations.count == 0 {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user