This commit is contained in:
Ali 2023-07-04 13:50:04 +02:00
parent 3ade624e87
commit 6afe111f39
3 changed files with 46 additions and 10 deletions

View File

@ -128,8 +128,9 @@ private final class PhoneAndCountryNode: ASDisplayNode {
if let strongSelf = self { if let strongSelf = self {
let _ = strongSelf.processNumberChange(number: strongSelf.phoneInputNode.number) let _ = strongSelf.processNumberChange(number: strongSelf.phoneInputNode.number)
if strongSelf.hasCountry { let isServiceNumber = strongSelf.phoneInputNode.number.hasPrefix("+999")
strongSelf.hasNumberUpdated?(!strongSelf.phoneInputNode.codeAndNumber.2.isEmpty) if strongSelf.hasCountry || isServiceNumber {
strongSelf.hasNumberUpdated?(!strongSelf.phoneInputNode.codeAndNumber.2.isEmpty || isServiceNumber)
} else { } else {
strongSelf.hasNumberUpdated?(false) strongSelf.hasNumberUpdated?(false)
} }

View File

@ -215,6 +215,7 @@ private final class FetchImpl {
private var requiredRangesDisposable: Disposable? private var requiredRangesDisposable: Disposable?
private var requiredRanges: [RequiredRange] = [] private var requiredRanges: [RequiredRange] = []
private let defaultPartSize: Int64
private var state: State? private var state: State?
private let loggingIdentifier: String private let loggingIdentifier: String
@ -263,6 +264,24 @@ private final class FetchImpl {
self.updatedFileReference = Data() self.updatedFileReference = Data()
#endif*/ #endif*/
var isStory = false
if let info = parameters?.info as? TelegramCloudMediaResourceFetchInfo {
switch info.reference {
case let .media(media, _):
if case .story = media {
isStory = true
}
default:
break
}
}
if isStory {
self.defaultPartSize = 512 * 1024
} else {
self.defaultPartSize = 128 * 1024
}
if let resource = resource as? TelegramCloudMediaResource { if let resource = resource as? TelegramCloudMediaResource {
if let apiInputLocation = resource.apiInputLocation(fileReference: Data()) { if let apiInputLocation = resource.apiInputLocation(fileReference: Data()) {
self.loggingIdentifier = "\(apiInputLocation)" self.loggingIdentifier = "\(apiInputLocation)"
@ -297,7 +316,7 @@ private final class FetchImpl {
self.state = .fetching(FetchingState( self.state = .fetching(FetchingState(
fetchLocation: .datacenter(self.datacenterId), fetchLocation: .datacenter(self.datacenterId),
partSize: 128 * 1024, partSize: self.defaultPartSize,
minPartSize: 4 * 1024, minPartSize: 4 * 1024,
maxPartSize: 1 * 1024 * 1024, maxPartSize: 1 * 1024 * 1024,
partAlignment: 4 * 1024, partAlignment: 4 * 1024,
@ -451,9 +470,9 @@ private final class FetchImpl {
} }
self.state = .fetching(FetchImpl.FetchingState( self.state = .fetching(FetchImpl.FetchingState(
fetchLocation: .cdn(cdnData), fetchLocation: .cdn(cdnData),
partSize: 128 * 1024, partSize: self.defaultPartSize,
minPartSize: 4 * 1024, minPartSize: 4 * 1024,
maxPartSize: 128 * 1024, maxPartSize: self.defaultPartSize,
partAlignment: 4 * 1024, partAlignment: 4 * 1024,
partDivision: 1 * 1024 * 1024, partDivision: 1 * 1024 * 1024,
maxPendingParts: 6 maxPendingParts: 6
@ -499,9 +518,9 @@ private final class FetchImpl {
self.state = .fetching(FetchingState( self.state = .fetching(FetchingState(
fetchLocation: fetchLocation, fetchLocation: fetchLocation,
partSize: 128 * 1024, partSize: self.defaultPartSize,
minPartSize: 4 * 1024, minPartSize: 4 * 1024,
maxPartSize: 128 * 1024, maxPartSize: self.defaultPartSize,
partAlignment: 4 * 1024, partAlignment: 4 * 1024,
partDivision: 1 * 1024 * 1024, partDivision: 1 * 1024 * 1024,
maxPendingParts: 6 maxPendingParts: 6
@ -686,9 +705,9 @@ private final class FetchImpl {
case let .cdnRedirect(cdnData): case let .cdnRedirect(cdnData):
self.state = .fetching(FetchImpl.FetchingState( self.state = .fetching(FetchImpl.FetchingState(
fetchLocation: .cdn(cdnData), fetchLocation: .cdn(cdnData),
partSize: 128 * 1024, partSize: self.defaultPartSize,
minPartSize: 4 * 1024, minPartSize: 4 * 1024,
maxPartSize: 128 * 1024, maxPartSize: self.defaultPartSize,
partAlignment: 4 * 1024, partAlignment: 4 * 1024,
partDivision: 1 * 1024 * 1024, partDivision: 1 * 1024 * 1024,
maxPendingParts: 6 maxPendingParts: 6

View File

@ -513,7 +513,23 @@ private final class MultipartFetchManager {
self.useMainConnection = useMainConnection self.useMainConnection = useMainConnection
self.completeSize = size self.completeSize = size
if let size = size {
var isStory = false
if let info = parameters?.info as? TelegramCloudMediaResourceFetchInfo {
switch info.reference {
case let .media(media, _):
if case .story = media {
isStory = true
}
default:
break
}
}
if isStory {
self.defaultPartSize = 512 * 1024
self.parallelParts = 4
} else if let size = size {
if size <= 512 * 1024 { if size <= 512 * 1024 {
self.defaultPartSize = 16 * 1024 self.defaultPartSize = 16 * 1024
self.parallelParts = 4 * 4 self.parallelParts = 4 * 4