mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Merge commit 'b6d84038f17cc37618016d2dca66cd05265e0bf3' into beta
This commit is contained in:
@@ -1524,6 +1524,11 @@ public final class GroupCallParticipantsContext {
|
||||
strongSelf.isLoadingMore = false
|
||||
strongSelf.shouldResetStateFromServer = false
|
||||
var state = state
|
||||
state.adminIds = strongSelf.stateValue.state.adminIds
|
||||
state.isCreator = strongSelf.stateValue.state.isCreator
|
||||
state.defaultParticipantsAreMuted = strongSelf.stateValue.state.defaultParticipantsAreMuted
|
||||
state.title = strongSelf.stateValue.state.title
|
||||
state.recordingStartTimestamp = strongSelf.stateValue.state.recordingStartTimestamp
|
||||
state.mergeActivity(from: strongSelf.stateValue.state, myPeerId: nil, previousMyPeerId: nil, mergeActivityTimestamps: false)
|
||||
strongSelf.stateValue.state = state
|
||||
strongSelf.endedProcessingUpdate()
|
||||
|
||||
@@ -4,33 +4,49 @@ import Foundation
|
||||
private final class LinkHelperClass: NSObject {
|
||||
}
|
||||
|
||||
public func dataSizeString(_ size: Int, forceDecimal: Bool = false, decimalSeparator: String = ".") -> String {
|
||||
return dataSizeString(Int64(size), forceDecimal: forceDecimal, decimalSeparator: decimalSeparator)
|
||||
public func dataSizeString(_ size: Int, forceDecimal: Bool = false, formatting: DataSizeStringFormatting) -> String {
|
||||
return dataSizeString(Int64(size), forceDecimal: forceDecimal, formatting: formatting)
|
||||
}
|
||||
|
||||
public func dataSizeString(_ size: Int64, forceDecimal: Bool = false, decimalSeparator: String = ".") -> String {
|
||||
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 "\(size / (1024 * 1024 * 1024))\(decimalSeparator)\(remainder) GB"
|
||||
return formatting.gigabyte("\(size / (1024 * 1024 * 1024))\(formatting.decimalSeparator)\(remainder)").0
|
||||
} else {
|
||||
return "\(size / (1024 * 1024 * 1024)) GB"
|
||||
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 "\(size / (1024 * 1024))\(decimalSeparator)\(remainder) MB"
|
||||
return formatting.megabyte( "\(size / (1024 * 1024))\(formatting.decimalSeparator)\(remainder)").0
|
||||
} else {
|
||||
return "\(size / (1024 * 1024)) MB"
|
||||
return formatting.megabyte("\(size / (1024 * 1024))").0
|
||||
}
|
||||
} else if size >= 1024 {
|
||||
let remainder = (size % (1024)) / (102)
|
||||
if remainder != 0 || forceDecimal {
|
||||
return "\(size / 1024)\(decimalSeparator)\(remainder) KB"
|
||||
return formatting.kilobyte("\(size / 1024)\(formatting.decimalSeparator)\(remainder)").0
|
||||
} else {
|
||||
return "\(size / 1024) KB"
|
||||
return formatting.kilobyte("\(size / 1024)").0
|
||||
}
|
||||
} else {
|
||||
return "\(size) B"
|
||||
return formatting.byte("\(size)").0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user