Don't display virtual numbers tip for US accounts

This commit is contained in:
Ilya Laktyushin 2022-11-28 00:05:09 +04:00
parent 61b298b9e2
commit ec2b3f42e8
2 changed files with 16 additions and 5 deletions

View File

@ -39,7 +39,7 @@ private func removePlus(_ text: String?) -> String {
return result
}
private func lookupCountryIdByNumber(_ number: String, configuration: CountriesConfiguration) -> (Country, Country.CountryCode)? {
public func lookupCountryIdByNumber(_ number: String, configuration: CountriesConfiguration) -> (Country, Country.CountryCode)? {
let number = removePlus(number)
var results: [(Country, Country.CountryCode)]? = nil
for i in 0 ..< number.count {

View File

@ -5473,13 +5473,15 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
return
}
let _ = (getUserPeer(engine: self.context.engine, peerId: self.peerId)
|> deliverOnMainQueue).start(next: { [weak self] peer in
let _ = (combineLatest(
getUserPeer(engine: self.context.engine, peerId: self.peerId),
getUserPeer(engine: self.context.engine, peerId: self.context.account.peerId)
) |> deliverOnMainQueue).start(next: { [weak self] peer, accountPeer in
guard let strongSelf = self else {
return
}
let presentationData = strongSelf.presentationData
let telegramCallAction: (Bool) -> Void = { [weak self] isVideo in
guard let strongSelf = self else {
return
@ -5503,6 +5505,15 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
strongSelf.controller?.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: presentationData.strings.Conversation_PhoneCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
}
var accountIsFromUS = false
if let accountPeer, case let .user(user) = accountPeer, let phone = user.phone {
if let (country, _) = lookupCountryIdByNumber(phone, configuration: strongSelf.context.currentCountriesConfiguration.with { $0 }) {
if country.id == "US" {
accountIsFromUS = true
}
}
}
let formattedPhoneNumber = formatPhoneNumber(context: strongSelf.context, number: value)
var isAnonymousNumber = false
var items: [ContextMenuItem] = []
@ -5552,7 +5563,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
)
}
var actions = ContextController.Items(content: .list(items))
if isAnonymousNumber {
if isAnonymousNumber && !accountIsFromUS {
actions.tip = .animatedEmoji(text: strongSelf.presentationData.strings.UserInfo_AnonymousNumberInfo, arguments: nil, file: nil, action: { [weak self] in
if let strongSelf = self {
strongSelf.context.sharedContext.openExternalUrl(context: strongSelf.context, urlContext: .generic, url: "https://fragment.com", forceExternal: true, presentationData: strongSelf.presentationData, navigationController: nil, dismissInput: {})