mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Fixed calling from contact view screen
This commit is contained in:
parent
90c2cf8768
commit
252f4d03a3
@ -752,7 +752,7 @@ public func deviceContactInfoController(account: Account, subject: DeviceContact
|
||||
|
||||
var displayCopyContextMenuImpl: ((DeviceContactInfoEntryTag, String) -> Void)?
|
||||
|
||||
let requestCallImpl: (String) -> Void = { number in
|
||||
let callImpl: (String) -> Void = { number in
|
||||
let _ = (account.postbox.transaction { transaction -> TelegramUser? in
|
||||
if let peer = subject.peer {
|
||||
return transaction.getPeer(peer.id) as? TelegramUser
|
||||
@ -761,6 +761,15 @@ public func deviceContactInfoController(account: Account, subject: DeviceContact
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { user in
|
||||
if let user = user, let phone = user.phone, formatPhoneNumber(phone) == formatPhoneNumber(number) {
|
||||
let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
|
||||
let controller = ActionSheetController(presentationTheme: presentationData.theme)
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.UserInfo_TelegramCall, action: {
|
||||
dismissAction()
|
||||
let callResult = account.telegramApplicationContext.callManager?.requestCall(peerId: user.id, endCurrentIfAny: false)
|
||||
if let callResult = callResult, case let .alreadyInProgress(currentPeerId) = callResult {
|
||||
if currentPeerId == user.id {
|
||||
@ -778,6 +787,17 @@ public func deviceContactInfoController(account: Account, subject: DeviceContact
|
||||
})
|
||||
}
|
||||
}
|
||||
}),
|
||||
ActionSheetButtonItem(title: presentationData.strings.UserInfo_PhoneCall, action: {
|
||||
dismissAction()
|
||||
account.telegramApplicationContext.applicationBindings.openUrl("tel:\(formatPhoneNumber(number).replacingOccurrences(of: " ", with: ""))")
|
||||
}),
|
||||
]),
|
||||
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
||||
])
|
||||
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
} else {
|
||||
account.telegramApplicationContext.applicationBindings.openUrl("tel:\(formatPhoneNumber(number).replacingOccurrences(of: " ", with: ""))")
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -885,7 +905,7 @@ public func deviceContactInfoController(account: Account, subject: DeviceContact
|
||||
return state
|
||||
}
|
||||
}, callPhone: { phoneNumber in
|
||||
requestCallImpl(phoneNumber)
|
||||
callImpl(phoneNumber)
|
||||
}, openUrl: { url in
|
||||
openUrlImpl?(url)
|
||||
}, openAddress: { address in
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user