Move ImageQualityLevel.defaultCallingCode(…)
This commit is contained in:
parent
1af14c8dc8
commit
1b25935b0f
@ -40,7 +40,9 @@ public struct OutgoingAttachmentLimits {
|
||||
|
||||
public static func currentLimits(
|
||||
remoteConfig: RemoteConfig = .current,
|
||||
callingCode: Int? = ImageQualityLevel.defaultCallingCode(),
|
||||
callingCode: Int? = DependenciesBridge.shared.tsAccountManager.localIdentifiersWithMaybeSneakyTransaction.flatMap({
|
||||
return SSKEnvironment.shared.phoneNumberUtilRef.localCallingCode(localIdentifiers: $0)
|
||||
}),
|
||||
) -> Self {
|
||||
return Self(remoteConfig: remoteConfig, callingCode: callingCode)
|
||||
}
|
||||
|
||||
@ -108,9 +108,7 @@ public class PhoneNumberUtil: NSObject {
|
||||
i -= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension PhoneNumberUtil {
|
||||
/// Returns calling codes for libPhoneNumber-unsupported country codes.
|
||||
///
|
||||
/// These are country codes that NSLocale.isoCountryCodes contains but
|
||||
@ -245,6 +243,10 @@ extension PhoneNumberUtil {
|
||||
return Locale.current.localizedString(forRegionCode: countryCode)?.nilIfEmpty ?? unknownValue
|
||||
}
|
||||
|
||||
public func localCallingCode(localIdentifiers: LocalIdentifiers) -> Int? {
|
||||
return parseE164(localIdentifiers.phoneNumber)?.getCallingCode()
|
||||
}
|
||||
|
||||
private func _parsePhoneNumber(filteredValue: String, countryCode: String = defaultCountryCode()) -> PhoneNumber? {
|
||||
do {
|
||||
let phoneNumber = try parse(filteredValue, defaultRegion: countryCode)
|
||||
|
||||
@ -401,7 +401,7 @@ public class RemoteConfig {
|
||||
|
||||
private static func countryCodeBucketValue(csvString: String, localIdentifiers: LocalIdentifiers) -> String? {
|
||||
let phoneNumberUtil = SSKEnvironment.shared.phoneNumberUtilRef
|
||||
let callingCode = phoneNumberUtil.parseE164(localIdentifiers.phoneNumber)?.getCallingCode()
|
||||
let callingCode = phoneNumberUtil.localCallingCode(localIdentifiers: localIdentifiers)
|
||||
return countryCodeValue(csvString: csvString, callingCode: callingCode)
|
||||
}
|
||||
|
||||
|
||||
@ -61,13 +61,6 @@ public enum ImageQualityLevel: UInt, Comparable {
|
||||
return remoteConfig.standardMediaQualityLevel(callingCode: callingCode) ?? .two
|
||||
}
|
||||
|
||||
public static func defaultCallingCode(
|
||||
phoneNumberUtil: PhoneNumberUtil = SSKEnvironment.shared.phoneNumberUtilRef,
|
||||
localIdentifiers: LocalIdentifiers? = DependenciesBridge.shared.tsAccountManager.localIdentifiersWithMaybeSneakyTransaction,
|
||||
) -> Int? {
|
||||
return localIdentifiers.flatMap({ phoneNumberUtil.parseE164($0.phoneNumber) })?.getCallingCode()
|
||||
}
|
||||
|
||||
public var startingTier: ImageQualityTier {
|
||||
switch self {
|
||||
case .one: return .four
|
||||
|
||||
Loading…
Reference in New Issue
Block a user