mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Merge branch 'master' into experimental-2
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
|
||||
import SyncCore
|
||||
|
||||
// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker
|
||||
private final class LinkHelperClass: NSObject {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
import MtProtoKit
|
||||
import SyncCore
|
||||
|
||||
public func smallestImageRepresentation(_ representations: [TelegramMediaImageRepresentation]) -> TelegramMediaImageRepresentation? {
|
||||
if representations.count == 0 {
|
||||
|
||||
@@ -2,7 +2,6 @@ import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
import SyncCore
|
||||
|
||||
extension JSON {
|
||||
private init?(_ object: Any) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
|
||||
import SyncCore
|
||||
|
||||
public extension MessageFlags {
|
||||
var isSending: Bool {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import SyncCore
|
||||
|
||||
public extension Peer {
|
||||
var debugDisplayTitle: String {
|
||||
|
||||
@@ -1,52 +1 @@
|
||||
import Foundation
|
||||
|
||||
// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker
|
||||
private final class LinkHelperClass: NSObject {
|
||||
}
|
||||
|
||||
public func dataSizeString(_ size: Int, forceDecimal: Bool = false, formatting: DataSizeStringFormatting) -> String {
|
||||
return dataSizeString(Int64(size), forceDecimal: forceDecimal, formatting: formatting)
|
||||
}
|
||||
|
||||
public struct DataSizeStringFormatting {
|
||||
let decimalSeparator: String
|
||||
let byte: (String) -> (String, [(Int, NSRange)])
|
||||
let kilobyte: (String) -> (String, [(Int, NSRange)])
|
||||
let megabyte: (String) -> (String, [(Int, NSRange)])
|
||||
let gigabyte: (String) -> (String, [(Int, NSRange)])
|
||||
|
||||
public init(decimalSeparator: String, byte: @escaping (String) -> (String, [(Int, NSRange)]), kilobyte: @escaping (String) -> (String, [(Int, NSRange)]), megabyte: @escaping (String) -> (String, [(Int, NSRange)]), gigabyte: @escaping (String) -> (String, [(Int, NSRange)])) {
|
||||
self.decimalSeparator = decimalSeparator
|
||||
self.byte = byte
|
||||
self.kilobyte = kilobyte
|
||||
self.megabyte = megabyte
|
||||
self.gigabyte = gigabyte
|
||||
}
|
||||
}
|
||||
|
||||
public func dataSizeString(_ size: Int64, forceDecimal: Bool = false, formatting: DataSizeStringFormatting) -> String {
|
||||
if size >= 1024 * 1024 * 1024 {
|
||||
let remainder = Int64((Double(size % (1024 * 1024 * 1024)) / (1024 * 1024 * 102.4)).rounded(.down))
|
||||
if remainder != 0 || forceDecimal {
|
||||
return formatting.gigabyte("\(size / (1024 * 1024 * 1024))\(formatting.decimalSeparator)\(remainder)").0
|
||||
} else {
|
||||
return formatting.gigabyte("\(size / (1024 * 1024 * 1024))").0
|
||||
}
|
||||
} else if size >= 1024 * 1024 {
|
||||
let remainder = Int64((Double(size % (1024 * 1024)) / (1024.0 * 102.4)).rounded(.down))
|
||||
if remainder != 0 || forceDecimal {
|
||||
return formatting.megabyte( "\(size / (1024 * 1024))\(formatting.decimalSeparator)\(remainder)").0
|
||||
} else {
|
||||
return formatting.megabyte("\(size / (1024 * 1024))").0
|
||||
}
|
||||
} else if size >= 1024 {
|
||||
let remainder = (size % (1024)) / (102)
|
||||
if remainder != 0 || forceDecimal {
|
||||
return formatting.kilobyte("\(size / 1024)\(formatting.decimalSeparator)\(remainder)").0
|
||||
} else {
|
||||
return formatting.kilobyte("\(size / 1024)").0
|
||||
}
|
||||
} else {
|
||||
return formatting.byte("\(size)").0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
import SyncCore
|
||||
|
||||
func updateMessageMedia(transaction: Transaction, id: MediaId, media: Media?) {
|
||||
let updatedMessageIndices = transaction.updateMedia(id, update: media)
|
||||
|
||||
Reference in New Issue
Block a user