Stop using CTCarrier for country code detection due to it's deprecation

This commit is contained in:
Ilya Laktyushin
2024-02-19 19:17:51 -04:00
parent 939b29770a
commit 5d967279b9
5 changed files with 27 additions and 47 deletions

View File

@@ -162,8 +162,26 @@ public func ChangePhoneNumberController(context: AccountContext) -> ViewControll
}
Queue.mainQueue().justDispatch {
controller.updateData(countryCode: AuthorizationSequenceController.defaultCountryCode(), countryName: nil, number: "")
controller.updateCountryCode()
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId))
|> deliverOnMainQueue).start(next: { accountPeer in
guard let accountPeer, case let .user(user) = accountPeer else {
return
}
let initialCountryCode: Int32
if let phone = user.phone {
if let (_, countryCode) = lookupCountryIdByNumber(phone, configuration: context.currentCountriesConfiguration.with { $0 }), let codeValue = Int32(countryCode.code) {
initialCountryCode = codeValue
} else {
initialCountryCode = AuthorizationSequenceController.defaultCountryCode()
}
} else {
initialCountryCode = AuthorizationSequenceController.defaultCountryCode()
}
controller.updateData(countryCode: initialCountryCode, countryName: nil, number: "")
controller.updateCountryCode()
})
}
return controller