mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-05-21 18:20:41 +00:00
493f3103b3
Squashes 20 commits — the implementation and outcome commits of
waves 37 through 43 plus wave 44's spec and implementation-plan
docs — into a single commit. Per-wave lessons remain recorded in
docs/superpowers/postbox-refactor-log.md. The unrelated "Add swift
svg" commit is preserved separately outside this squash.
Wave 37 — peerTokenTitle: peer Peer → EnginePeer (1 file)
Wave 38 — canSendMessagesToPeer: peer Peer → EnginePeer (12 files)
Wave 39 — AccountContext.makePeerInfoController: peer Peer → EnginePeer (52 files)
Wave 40 — makeChatQrCodeScreen + makeChatRecentActionsController bundle (8 files)
Wave 41 — RenderedChannelParticipant.peer: Peer → EnginePeer (28 files)
Wave 42 — PeerInfoScreenData.peer: Peer? → EnginePeer? (17 files)
Wave 43 — PeerInfoScreen 6 helpers: peer Peer? → EnginePeer? (12 files)
Wave 44 — RenderedChannelParticipant.peers design doc + implementation plan
(impl and outcome land in subsequent commits, not part of squash)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
2.6 KiB
Swift
48 lines
2.6 KiB
Swift
import Foundation
|
|
import SwiftSignalKit
|
|
import TelegramCore
|
|
import Display
|
|
import DeviceAccess
|
|
import AccountContext
|
|
import ShareController
|
|
import AlertUI
|
|
import PresentationDataUtils
|
|
import PeerInfoUI
|
|
import PhoneNumberFormat
|
|
|
|
func openAddContactImpl(context: AccountContext, peer: EnginePeer?, firstName: String = "", lastName: String = "", phoneNumber: String, label: String = "_$!<Mobile>!$_", present: @escaping (ViewController, Any?) -> Void, pushController: @escaping (ViewController) -> Void, completed: @escaping () -> Void = {}) {
|
|
let _ = (DeviceAccess.authorizationStatus(subject: .contacts)
|
|
|> take(1)
|
|
|> deliverOnMainQueue).startStandalone(next: { value in
|
|
switch value {
|
|
case .allowed:
|
|
let controller = context.sharedContext.makeNewContactScreen(
|
|
context: context,
|
|
peer: peer,
|
|
firstName: firstName.isEmpty ? nil : firstName,
|
|
lastName: lastName.isEmpty ? nil : lastName,
|
|
phoneNumber: cleanPhoneNumber(phoneNumber, removePlus: true),
|
|
shareViaException: false,
|
|
completion: { peer, stableId, contactData in
|
|
if let peer = peer {
|
|
if let infoController = context.sharedContext.makePeerInfoController(context: context, updatedPresentationData: nil, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, requestsContext: nil) {
|
|
pushController(infoController)
|
|
}
|
|
} else if let stableId, let contactData {
|
|
pushController(deviceContactInfoController(context: ShareControllerAppAccountContext(context: context), environment: ShareControllerAppEnvironment(sharedContext: context.sharedContext), subject: .vcard(nil, stableId, contactData), completed: nil, cancelled: nil))
|
|
}
|
|
completed()
|
|
}
|
|
)
|
|
pushController(controller)
|
|
case .notDetermined:
|
|
DeviceAccess.authorizeAccess(to: .contacts)
|
|
default:
|
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
|
present(textAlertController(context: context, title: presentationData.strings.AccessDenied_Title, text: presentationData.strings.Contacts_AccessDeniedError, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_NotNow, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.AccessDenied_Settings, action: {
|
|
context.sharedContext.applicationBindings.openSettings()
|
|
})]), nil)
|
|
}
|
|
})
|
|
}
|