Move ImageQualityLevel.defaultCallingCode(…)

This commit is contained in:
Max Radermacher 2026-01-22 14:20:51 -06:00 committed by GitHub
parent 1af14c8dc8
commit 1b25935b0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 11 deletions

View File

@ -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)
}

View File

@ -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)

View File

@ -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)
}

View File

@ -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