From 6afe111f39633a155f1f3135e244c8474b21dc48 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 4 Jul 2023 13:50:04 +0200 Subject: [PATCH] Stories --- ...tionSequencePhoneEntryControllerNode.swift | 5 +-- .../Sources/Network/FetchV2.swift | 33 +++++++++++++++---- .../Sources/Network/MultipartFetch.swift | 18 +++++++++- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift b/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift index cd168e2cf3..26cb4321d8 100644 --- a/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift +++ b/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift @@ -128,8 +128,9 @@ private final class PhoneAndCountryNode: ASDisplayNode { if let strongSelf = self { let _ = strongSelf.processNumberChange(number: strongSelf.phoneInputNode.number) - if strongSelf.hasCountry { - strongSelf.hasNumberUpdated?(!strongSelf.phoneInputNode.codeAndNumber.2.isEmpty) + let isServiceNumber = strongSelf.phoneInputNode.number.hasPrefix("+999") + if strongSelf.hasCountry || isServiceNumber { + strongSelf.hasNumberUpdated?(!strongSelf.phoneInputNode.codeAndNumber.2.isEmpty || isServiceNumber) } else { strongSelf.hasNumberUpdated?(false) } diff --git a/submodules/TelegramCore/Sources/Network/FetchV2.swift b/submodules/TelegramCore/Sources/Network/FetchV2.swift index 830e96ddfc..652ee0df72 100644 --- a/submodules/TelegramCore/Sources/Network/FetchV2.swift +++ b/submodules/TelegramCore/Sources/Network/FetchV2.swift @@ -215,6 +215,7 @@ private final class FetchImpl { private var requiredRangesDisposable: Disposable? private var requiredRanges: [RequiredRange] = [] + private let defaultPartSize: Int64 private var state: State? private let loggingIdentifier: String @@ -263,6 +264,24 @@ private final class FetchImpl { self.updatedFileReference = Data() #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 apiInputLocation = resource.apiInputLocation(fileReference: Data()) { self.loggingIdentifier = "\(apiInputLocation)" @@ -297,7 +316,7 @@ private final class FetchImpl { self.state = .fetching(FetchingState( fetchLocation: .datacenter(self.datacenterId), - partSize: 128 * 1024, + partSize: self.defaultPartSize, minPartSize: 4 * 1024, maxPartSize: 1 * 1024 * 1024, partAlignment: 4 * 1024, @@ -451,9 +470,9 @@ private final class FetchImpl { } self.state = .fetching(FetchImpl.FetchingState( fetchLocation: .cdn(cdnData), - partSize: 128 * 1024, + partSize: self.defaultPartSize, minPartSize: 4 * 1024, - maxPartSize: 128 * 1024, + maxPartSize: self.defaultPartSize, partAlignment: 4 * 1024, partDivision: 1 * 1024 * 1024, maxPendingParts: 6 @@ -499,9 +518,9 @@ private final class FetchImpl { self.state = .fetching(FetchingState( fetchLocation: fetchLocation, - partSize: 128 * 1024, + partSize: self.defaultPartSize, minPartSize: 4 * 1024, - maxPartSize: 128 * 1024, + maxPartSize: self.defaultPartSize, partAlignment: 4 * 1024, partDivision: 1 * 1024 * 1024, maxPendingParts: 6 @@ -686,9 +705,9 @@ private final class FetchImpl { case let .cdnRedirect(cdnData): self.state = .fetching(FetchImpl.FetchingState( fetchLocation: .cdn(cdnData), - partSize: 128 * 1024, + partSize: self.defaultPartSize, minPartSize: 4 * 1024, - maxPartSize: 128 * 1024, + maxPartSize: self.defaultPartSize, partAlignment: 4 * 1024, partDivision: 1 * 1024 * 1024, maxPendingParts: 6 diff --git a/submodules/TelegramCore/Sources/Network/MultipartFetch.swift b/submodules/TelegramCore/Sources/Network/MultipartFetch.swift index 6fe352baf3..8c49845633 100644 --- a/submodules/TelegramCore/Sources/Network/MultipartFetch.swift +++ b/submodules/TelegramCore/Sources/Network/MultipartFetch.swift @@ -513,7 +513,23 @@ private final class MultipartFetchManager { self.useMainConnection = useMainConnection 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 { self.defaultPartSize = 16 * 1024 self.parallelParts = 4 * 4