mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 05:51:42 +00:00
Merge commit '7ffa03a357b38fb3f58cc80570148b88c1f1651f'
This commit is contained in:
commit
3dcfa10aea
@ -259,6 +259,7 @@ public enum DeviceContactInfoSubject {
|
||||
public enum PeerInfoControllerMode {
|
||||
case generic
|
||||
case calls(messages: [Message])
|
||||
case nearbyPeer
|
||||
}
|
||||
|
||||
public enum ContactListActionItemInlineIconPosition {
|
||||
@ -449,7 +450,7 @@ public protocol SharedAccountContext: class {
|
||||
func openChatMessage(_ params: OpenChatMessageParams) -> Bool
|
||||
func messageFromPreloadedChatHistoryViewForLocation(id: MessageId, location: ChatHistoryLocationInput, account: Account, chatLocation: ChatLocation, tagMask: MessageTags?) -> Signal<(MessageIndex?, Bool), NoError>
|
||||
func makeOverlayAudioPlayerController(context: AccountContext, peerId: PeerId, type: MediaManagerPlayerType, initialMessageId: MessageId, initialOrder: MusicPlaybackSettingsOrder, parentNavigationController: NavigationController?) -> ViewController & OverlayAudioPlayerController
|
||||
func makePeerInfoController(context: AccountContext, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, fromChat: Bool, suggestSendMessage: Bool) -> ViewController?
|
||||
func makePeerInfoController(context: AccountContext, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, fromChat: Bool) -> ViewController?
|
||||
func makeDeviceContactInfoController(context: AccountContext, subject: DeviceContactInfoSubject, completed: (() -> Void)?, cancelled: (() -> Void)?) -> ViewController
|
||||
func makePeersNearbyController(context: AccountContext) -> ViewController
|
||||
func makeComposeController(context: AccountContext) -> ViewController
|
||||
|
||||
@ -154,7 +154,7 @@ public final class CallListController: ViewController {
|
||||
let _ = (strongSelf.context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
if let strongSelf = self, let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .calls(messages: messages), avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let strongSelf = self, let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .calls(messages: messages), avatarInitiallyExpanded: false, fromChat: false) {
|
||||
(strongSelf.navigationController as? NavigationController)?.pushViewController(controller)
|
||||
}
|
||||
})
|
||||
|
||||
@ -535,7 +535,7 @@ public class ContactsController: ViewController {
|
||||
return
|
||||
}
|
||||
if let peer = peer {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
(strongSelf.navigationController as? NavigationController)?.pushViewController(infoController)
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -1180,7 +1180,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
let _ = (strongSelf.context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
if let strongSelf = self {
|
||||
if let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
strongSelf.getNavigationController()?.pushViewController(controller)
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ public final class SecureIdAuthController: ViewController, StandalonePresentable
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
(strongSelf.navigationController as? NavigationController)?.pushViewController(infoController)
|
||||
}
|
||||
})
|
||||
|
||||
@ -366,7 +366,7 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId)
|
||||
}
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.GroupRemoved_ViewUserInfo, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: participant.peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: participant.peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
pushControllerImpl?(infoController)
|
||||
}
|
||||
}))
|
||||
|
||||
@ -450,7 +450,7 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) ->
|
||||
}
|
||||
}))
|
||||
}, openPeer: { peer in
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
pushControllerImpl?(controller)
|
||||
}
|
||||
}, inviteViaLink: {
|
||||
@ -502,7 +502,7 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) ->
|
||||
return state.withUpdatedSearchingMembers(false)
|
||||
}
|
||||
}, openPeer: { peer, _ in
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
pushControllerImpl?(infoController)
|
||||
}
|
||||
}, pushController: { c in
|
||||
|
||||
@ -666,7 +666,7 @@ public func channelPermissionsController(context: AccountContext, peerId origina
|
||||
}), ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
})
|
||||
}, openPeerInfo: { peer in
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
pushControllerImpl?(controller)
|
||||
}
|
||||
}, openKicked: {
|
||||
|
||||
@ -599,7 +599,7 @@ private enum GroupInfoEntry: ItemListNodeEntry {
|
||||
}))
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer, presence: presence, text: .presence, label: label == nil ? .none : .text(label!, .standard), editing: editing, revealOptions: ItemListPeerItemRevealOptions(options: options), switchValue: nil, enabled: enabled, selectable: selectable, sectionId: self.section, action: {
|
||||
if let infoController = arguments.context.sharedContext.makePeerInfoController(context: arguments.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false), selectable {
|
||||
if let infoController = arguments.context.sharedContext.makePeerInfoController(context: arguments.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false), selectable {
|
||||
arguments.pushController(infoController)
|
||||
}
|
||||
}, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
||||
@ -2342,7 +2342,7 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId:
|
||||
return state.withUpdatedSearchingMembers(false)
|
||||
}
|
||||
}, openPeer: { peer, _ in
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
arguments.pushController(infoController)
|
||||
}
|
||||
}, pushController: { c in
|
||||
|
||||
@ -101,19 +101,10 @@ public func presentPeerReportOptions(context: AccountContext, parent: ViewContro
|
||||
}
|
||||
}
|
||||
|
||||
public func peerReportOptionsController(context: AccountContext, subject: PeerReportSubject, present: @escaping (ViewController, Any?) -> Void, push: @escaping (ViewController) -> Void, completion: @escaping (Bool) -> Void) -> ViewController {
|
||||
public func peerReportOptionsController(context: AccountContext, subject: PeerReportSubject, options: [PeerReportOption] = [.spam, .violence, .pornography, .childAbuse, .copyright, .other], present: @escaping (ViewController, Any?) -> Void, push: @escaping (ViewController) -> Void, completion: @escaping (Bool) -> Void) -> ViewController {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = ActionSheetController(theme: ActionSheetControllerTheme(presentationData: presentationData))
|
||||
|
||||
let options: [PeerReportOption] = [
|
||||
.spam,
|
||||
.violence,
|
||||
.pornography,
|
||||
.childAbuse,
|
||||
.copyright,
|
||||
.other
|
||||
]
|
||||
|
||||
|
||||
var items: [ActionSheetItem] = []
|
||||
for option in options {
|
||||
let title: String
|
||||
|
||||
@ -636,7 +636,7 @@ public func peersNearbyController(context: AccountContext) -> ViewController {
|
||||
controller?.clearItemNodesHighlight(animated: true)
|
||||
}
|
||||
navigateToProfileImpl = { [weak controller] peer in
|
||||
if let navigationController = controller?.navigationController as? NavigationController, let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: peer.largeProfileImage != nil, fromChat: false, suggestSendMessage: true) {
|
||||
if let navigationController = controller?.navigationController as? NavigationController, let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .nearbyPeer, avatarInitiallyExpanded: peer.largeProfileImage != nil, fromChat: false) {
|
||||
(navigationController as? NavigationController)?.pushViewController(controller)
|
||||
}
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ public func blockedPeersController(context: AccountContext, blockedPeersContext:
|
||||
}
|
||||
}))
|
||||
}, openPeer: { peer in
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
pushControllerImpl?(controller)
|
||||
}
|
||||
})
|
||||
|
||||
@ -341,7 +341,7 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
|
||||
return transaction.getPeer(peerId)
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
guard let peer = peer, let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) else {
|
||||
guard let peer = peer, let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) else {
|
||||
return
|
||||
}
|
||||
pushControllerImpl?(controller)
|
||||
|
||||
@ -5397,7 +5397,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
if peer.smallProfileImage == nil {
|
||||
expandAvatar = false
|
||||
}
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: expandAvatar, fromChat: true, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: expandAvatar, fromChat: true) {
|
||||
strongSelf.effectiveNavigationController?.pushViewController(infoController)
|
||||
}
|
||||
}
|
||||
@ -7154,7 +7154,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
self.navigationActionDisposable.set((peerSignal |> take(1) |> deliverOnMainQueue).start(next: { [weak self] peer in
|
||||
if let strongSelf = self, let peer = peer {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: expandAvatar, fromChat: true, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: expandAvatar, fromChat: true) {
|
||||
strongSelf.effectiveNavigationController?.pushViewController(infoController)
|
||||
}
|
||||
}
|
||||
@ -7571,7 +7571,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peer in
|
||||
if let strongSelf = self, peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
strongSelf.effectiveNavigationController?.pushViewController(infoController)
|
||||
}
|
||||
}
|
||||
|
||||
@ -661,7 +661,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
||||
if peer is TelegramChannel, let navigationController = strongSelf.getNavigationController() {
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer.id), animated: true))
|
||||
} else {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
strongSelf.pushController(infoController)
|
||||
}
|
||||
}
|
||||
@ -683,7 +683,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peer in
|
||||
if let strongSelf = self {
|
||||
if let peer = peer {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
strongSelf.pushController(infoController)
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ func openAddContactImpl(context: AccountContext, firstName: String = "", lastNam
|
||||
let contactData = DeviceContactExtendedData(basicData: DeviceContactBasicData(firstName: firstName, lastName: lastName, phoneNumbers: [DeviceContactPhoneNumberData(label: label, value: phoneNumber)]), middleName: "", prefix: "", suffix: "", organization: "", jobTitle: "", department: "", emailAddresses: [], urls: [], addresses: [], birthdayDate: nil, socialProfiles: [], instantMessagingProfiles: [], note: "")
|
||||
present(deviceContactInfoController(context: context, subject: .create(peer: nil, contactData: contactData, isSharing: false, shareViaException: false, completion: { peer, stableId, contactData in
|
||||
if let peer = peer {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
pushController(infoController)
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -213,7 +213,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
case .info:
|
||||
let _ = (context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
context.sharedContext.applicationBindings.dismissNativeController()
|
||||
navigationController?.pushViewController(infoController)
|
||||
}
|
||||
@ -495,7 +495,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
return transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: idValue))
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
if let peer = peer, let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let peer = peer, let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
navigationController?.pushViewController(controller)
|
||||
}
|
||||
})
|
||||
|
||||
@ -475,7 +475,7 @@ private final class PeerInfoInteraction {
|
||||
let requestDeleteContact: () -> Void
|
||||
let openAddContact: () -> Void
|
||||
let updateBlocked: (Bool) -> Void
|
||||
let openReport: () -> Void
|
||||
let openReport: (Bool) -> Void
|
||||
let openShareBot: () -> Void
|
||||
let openAddBotToGroup: () -> Void
|
||||
let performBotCommand: (PeerInfoBotCommand) -> Void
|
||||
@ -494,16 +494,16 @@ private final class PeerInfoInteraction {
|
||||
let performBioLinkAction: (TextLinkItemActionType, TextLinkItem) -> Void
|
||||
|
||||
init(
|
||||
openChat: @escaping () -> Void,
|
||||
openUsername: @escaping (String) -> Void,
|
||||
openPhone: @escaping (String) -> Void,
|
||||
editingOpenNotificationSettings: @escaping () -> Void,
|
||||
editingOpenSoundSettings: @escaping () -> Void,
|
||||
editingToggleShowMessageText: @escaping (Bool) -> Void,
|
||||
requestDeleteContact: @escaping () -> Void,
|
||||
openChat: @escaping () -> Void,
|
||||
openAddContact: @escaping () -> Void,
|
||||
updateBlocked: @escaping (Bool) -> Void,
|
||||
openReport: @escaping () -> Void,
|
||||
openReport: @escaping (Bool) -> Void,
|
||||
openShareBot: @escaping () -> Void,
|
||||
openAddBotToGroup: @escaping () -> Void,
|
||||
performBotCommand: @escaping (PeerInfoBotCommand) -> Void,
|
||||
@ -521,13 +521,13 @@ private final class PeerInfoInteraction {
|
||||
openPeerInfoContextMenu: @escaping (PeerInfoContextSubject, ASDisplayNode) -> Void,
|
||||
performBioLinkAction: @escaping (TextLinkItemActionType, TextLinkItem) -> Void
|
||||
) {
|
||||
self.openChat = openChat
|
||||
self.openUsername = openUsername
|
||||
self.openPhone = openPhone
|
||||
self.editingOpenNotificationSettings = editingOpenNotificationSettings
|
||||
self.editingOpenSoundSettings = editingOpenSoundSettings
|
||||
self.editingToggleShowMessageText = editingToggleShowMessageText
|
||||
self.requestDeleteContact = requestDeleteContact
|
||||
self.openChat = openChat
|
||||
self.openAddContact = openAddContact
|
||||
self.updateBlocked = updateBlocked
|
||||
self.openReport = openReport
|
||||
@ -552,7 +552,7 @@ private final class PeerInfoInteraction {
|
||||
|
||||
private let enabledBioEntities: EnabledEntityTypes = [.url, .mention, .hashtag]
|
||||
|
||||
private func infoItems(data: PeerInfoScreenData?, mainAction: PeerInfoScreenMainAction, context: AccountContext, presentationData: PresentationData, interaction: PeerInfoInteraction) -> [(AnyHashable, [PeerInfoScreenItem])] {
|
||||
private func infoItems(data: PeerInfoScreenData?, context: AccountContext, presentationData: PresentationData, interaction: PeerInfoInteraction, nearbyPeer: Bool) -> [(AnyHashable, [PeerInfoScreenItem])] {
|
||||
guard let data = data else {
|
||||
return []
|
||||
}
|
||||
@ -598,38 +598,42 @@ private func infoItems(data: PeerInfoScreenData?, mainAction: PeerInfoScreenMain
|
||||
items[.peerInfo]!.append(PeerInfoScreenLabeledValueItem(id: 0, label: user.botInfo == nil ? presentationData.strings.Profile_About : presentationData.strings.Channel_AboutItem, text: about, textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: enabledBioEntities), action: nil, longTapAction: bioContextAction, linkItemAction: bioLinkAction))
|
||||
}
|
||||
}
|
||||
if !data.isContact {
|
||||
if user.botInfo == nil {
|
||||
switch mainAction {
|
||||
case .addContact:
|
||||
if nearbyPeer {
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 3, text: presentationData.strings.UserInfo_SendMessage, action: {
|
||||
interaction.openChat()
|
||||
}))
|
||||
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 4, text: presentationData.strings.ReportPeer_Report, color: .destructive, action: {
|
||||
interaction.openReport(true)
|
||||
}))
|
||||
} else {
|
||||
if !data.isContact {
|
||||
if user.botInfo == nil {
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 3, text: presentationData.strings.UserInfo_AddContact, action: {
|
||||
interaction.openAddContact()
|
||||
}))
|
||||
case .message:
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 3, text: presentationData.strings.UserInfo_SendMessage, action: {
|
||||
interaction.openChat()
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
if let cachedData = data.cachedData as? CachedUserData {
|
||||
if cachedData.isBlocked {
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 4, text: user.botInfo != nil ? presentationData.strings.Bot_Unblock : presentationData.strings.Conversation_Unblock, action: {
|
||||
interaction.updateBlocked(false)
|
||||
}))
|
||||
} else {
|
||||
if user.flags.contains(.isSupport) || data.isContact {
|
||||
} else {
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 4, text: user.botInfo != nil ? presentationData.strings.Bot_Stop : presentationData.strings.Conversation_BlockUser, color: .destructive, action: {
|
||||
interaction.updateBlocked(true)
|
||||
|
||||
if let cachedData = data.cachedData as? CachedUserData {
|
||||
if cachedData.isBlocked {
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 4, text: user.botInfo != nil ? presentationData.strings.Bot_Unblock : presentationData.strings.Conversation_Unblock, action: {
|
||||
interaction.updateBlocked(false)
|
||||
}))
|
||||
} else {
|
||||
if user.flags.contains(.isSupport) || data.isContact {
|
||||
} else {
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 4, text: user.botInfo != nil ? presentationData.strings.Bot_Stop : presentationData.strings.Conversation_BlockUser, color: .destructive, action: {
|
||||
interaction.updateBlocked(true)
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if user.botInfo != nil, !user.isVerified {
|
||||
items[.peerInfo]!.append(PeerInfoScreenActionItem(id: 5, text: presentationData.strings.ReportPeer_Report, action: {
|
||||
interaction.openReport()
|
||||
interaction.openReport(false)
|
||||
}))
|
||||
}
|
||||
} else if let channel = data.peer as? TelegramChannel {
|
||||
@ -997,7 +1001,6 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
|
||||
private let context: AccountContext
|
||||
private let peerId: PeerId
|
||||
private let mainAction: PeerInfoScreenMainAction
|
||||
|
||||
private var presentationData: PresentationData
|
||||
|
||||
@ -1031,6 +1034,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
selectedMessageIds: nil,
|
||||
updatingAvatar: nil
|
||||
)
|
||||
private let nearbyPeer: Bool
|
||||
private var dataDisposable: Disposable?
|
||||
|
||||
private let activeActionDisposable = MetaDisposable()
|
||||
@ -1048,12 +1052,12 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
}
|
||||
private var didSetReady = false
|
||||
|
||||
init(controller: PeerInfoScreen, context: AccountContext, peerId: PeerId, avatarInitiallyExpanded: Bool, keepExpandedButtons: PeerInfoScreenKeepExpandedButtons, mainAction: PeerInfoScreenMainAction) {
|
||||
init(controller: PeerInfoScreen, context: AccountContext, peerId: PeerId, avatarInitiallyExpanded: Bool, keepExpandedButtons: PeerInfoScreenKeepExpandedButtons, nearbyPeer: Bool) {
|
||||
self.controller = controller
|
||||
self.context = context
|
||||
self.peerId = peerId
|
||||
self.mainAction = mainAction
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
self.nearbyPeer = nearbyPeer
|
||||
|
||||
self.scrollNode = ASScrollNode()
|
||||
self.scrollNode.view.delaysContentTouches = false
|
||||
@ -1064,9 +1068,6 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
super.init()
|
||||
|
||||
self._interaction = PeerInfoInteraction(
|
||||
openChat: { [weak self] in
|
||||
self?.performButtonAction(key: .message)
|
||||
},
|
||||
openUsername: { [weak self] value in
|
||||
self?.openUsername(value: value)
|
||||
},
|
||||
@ -1085,14 +1086,17 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
requestDeleteContact: { [weak self] in
|
||||
self?.requestDeleteContact()
|
||||
},
|
||||
openChat: { [weak self] in
|
||||
self?.openChat()
|
||||
},
|
||||
openAddContact: { [weak self] in
|
||||
self?.openAddContact()
|
||||
},
|
||||
updateBlocked: { [weak self] block in
|
||||
self?.updateBlocked(block: block)
|
||||
},
|
||||
openReport: { [weak self] in
|
||||
self?.openReport()
|
||||
openReport: { [weak self] user in
|
||||
self?.openReport(user: user)
|
||||
},
|
||||
openShareBot: { [weak self] in
|
||||
self?.openShareBot()
|
||||
@ -1928,7 +1932,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peer in
|
||||
if let strongSelf = self, peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
(strongSelf.controller?.navigationController as? NavigationController)?.pushViewController(infoController)
|
||||
}
|
||||
}
|
||||
@ -2037,7 +2041,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
if canReport {
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.ReportPeer_Report, color: .destructive, action: { [weak self] in
|
||||
dismissAction()
|
||||
self?.openReport()
|
||||
self?.openReport(user: false)
|
||||
}))
|
||||
}
|
||||
|
||||
@ -2406,6 +2410,12 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
self.controller?.present(actionSheet, in: .window(.root))
|
||||
}
|
||||
|
||||
private func openChat() {
|
||||
if let navigationController = self.controller?.navigationController as? NavigationController {
|
||||
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(self.peerId)))
|
||||
}
|
||||
}
|
||||
|
||||
private func openAddContact() {
|
||||
let _ = (getUserPeer(postbox: self.context.account.postbox, peerId: self.peerId)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peer, _ in
|
||||
@ -2488,12 +2498,19 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
})
|
||||
}
|
||||
|
||||
private func openReport() {
|
||||
private func openReport(user: Bool) {
|
||||
guard let controller = self.controller else {
|
||||
return
|
||||
}
|
||||
self.view.endEditing(true)
|
||||
controller.present(peerReportOptionsController(context: self.context, subject: .peer(self.peerId), present: { [weak controller] c, a in
|
||||
|
||||
let options: [PeerReportOption]
|
||||
if user {
|
||||
options = [.spam, .violence, .pornography, .childAbuse]
|
||||
} else {
|
||||
options = [.spam, .violence, .pornography, .childAbuse, .copyright, .other]
|
||||
}
|
||||
controller.present(peerReportOptionsController(context: self.context, subject: .peer(self.peerId), options: options, present: { [weak controller] c, a in
|
||||
controller?.present(c, in: .window(.root), with: a)
|
||||
}, push: { [weak controller] c in
|
||||
controller?.push(c)
|
||||
@ -2658,7 +2675,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
}
|
||||
|
||||
private func openPeerInfo(peer: Peer) {
|
||||
if let infoController = self.context.sharedContext.makePeerInfoController(context: self.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = self.context.sharedContext.makePeerInfoController(context: self.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
(self.controller?.navigationController as? NavigationController)?.pushViewController(infoController)
|
||||
}
|
||||
}
|
||||
@ -3469,7 +3486,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
contentHeight += sectionSpacing
|
||||
|
||||
var validRegularSections: [AnyHashable] = []
|
||||
for (sectionId, sectionItems) in infoItems(data: self.data, mainAction: self.mainAction, context: self.context, presentationData: self.presentationData, interaction: self.interaction) {
|
||||
for (sectionId, sectionItems) in infoItems(data: self.data, context: self.context, presentationData: self.presentationData, interaction: self.interaction, nearbyPeer: self.nearbyPeer) {
|
||||
validRegularSections.append(sectionId)
|
||||
|
||||
let sectionNode: PeerInfoScreenItemSectionContainerNode
|
||||
@ -3896,17 +3913,12 @@ public enum PeerInfoScreenKeepExpandedButtons {
|
||||
case mute
|
||||
}
|
||||
|
||||
public enum PeerInfoScreenMainAction {
|
||||
case addContact
|
||||
case message
|
||||
}
|
||||
|
||||
public final class PeerInfoScreen: ViewController {
|
||||
private let context: AccountContext
|
||||
private let peerId: PeerId
|
||||
private let avatarInitiallyExpanded: Bool
|
||||
private let keepExpandedButtons: PeerInfoScreenKeepExpandedButtons
|
||||
private let mainAction: PeerInfoScreenMainAction
|
||||
private let nearbyPeer: Bool
|
||||
|
||||
private var presentationData: PresentationData
|
||||
private var presentationDataDisposable: Disposable?
|
||||
@ -3922,12 +3934,12 @@ public final class PeerInfoScreen: ViewController {
|
||||
|
||||
private var validLayout: (layout: ContainerViewLayout, navigationHeight: CGFloat)?
|
||||
|
||||
public init(context: AccountContext, peerId: PeerId, avatarInitiallyExpanded: Bool = false, keepExpandedButtons: PeerInfoScreenKeepExpandedButtons = .message, mainAction: PeerInfoScreenMainAction = .addContact) {
|
||||
public init(context: AccountContext, peerId: PeerId, avatarInitiallyExpanded: Bool = false, keepExpandedButtons: PeerInfoScreenKeepExpandedButtons = .message, nearbyPeer: Bool = false) {
|
||||
self.context = context
|
||||
self.peerId = peerId
|
||||
self.avatarInitiallyExpanded = avatarInitiallyExpanded
|
||||
self.keepExpandedButtons = keepExpandedButtons
|
||||
self.mainAction = mainAction
|
||||
self.nearbyPeer = nearbyPeer
|
||||
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
@ -3995,7 +4007,7 @@ public final class PeerInfoScreen: ViewController {
|
||||
}
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = PeerInfoScreenNode(controller: self, context: self.context, peerId: self.peerId, avatarInitiallyExpanded: self.avatarInitiallyExpanded, keepExpandedButtons: self.keepExpandedButtons, mainAction: self.mainAction)
|
||||
self.displayNode = PeerInfoScreenNode(controller: self, context: self.context, peerId: self.peerId, avatarInitiallyExpanded: self.avatarInitiallyExpanded, keepExpandedButtons: self.keepExpandedButtons, nearbyPeer: self.nearbyPeer)
|
||||
|
||||
self._ready.set(self.controllerNode.ready.get())
|
||||
|
||||
|
||||
@ -759,7 +759,7 @@ public class PeerMediaCollectionController: TelegramBaseController {
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peer in
|
||||
if let strongSelf = self, peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
(strongSelf.navigationController as? NavigationController)?.pushViewController(infoController)
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ public func pollResultsController(context: AccountContext, messageId: MessageId,
|
||||
})
|
||||
}, openPeer: { peer in
|
||||
if let peer = peer.peers[peer.peerId] {
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let controller = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
pushControllerImpl?(controller)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1006,8 +1006,8 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
handleTextLinkActionImpl(context: context, peerId: peerId, navigateDisposable: navigateDisposable, controller: controller, action: action, itemLink: itemLink)
|
||||
}
|
||||
|
||||
public func makePeerInfoController(context: AccountContext, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, fromChat: Bool, suggestSendMessage: Bool) -> ViewController? {
|
||||
let controller = peerInfoControllerImpl(context: context, peer: peer, mode: mode, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: fromChat ? .mute : .message, mainAction: suggestSendMessage ? .message : .addContact)
|
||||
public func makePeerInfoController(context: AccountContext, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, fromChat: Bool) -> ViewController? {
|
||||
let controller = peerInfoControllerImpl(context: context, peer: peer, mode: mode, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: fromChat ? .mute : .message)
|
||||
controller?.navigationPresentation = .modalInLargeLayout
|
||||
return controller
|
||||
}
|
||||
@ -1249,13 +1249,17 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
|
||||
private let defaultChatControllerInteraction = ChatControllerInteraction.default
|
||||
|
||||
private func peerInfoControllerImpl(context: AccountContext, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, keepExpandedButtons: PeerInfoScreenKeepExpandedButtons, mainAction: PeerInfoScreenMainAction) -> ViewController? {
|
||||
private func peerInfoControllerImpl(context: AccountContext, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, keepExpandedButtons: PeerInfoScreenKeepExpandedButtons) -> ViewController? {
|
||||
if let _ = peer as? TelegramGroup {
|
||||
return PeerInfoScreen(context: context, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: keepExpandedButtons, mainAction: mainAction)
|
||||
return PeerInfoScreen(context: context, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: keepExpandedButtons)
|
||||
} else if let channel = peer as? TelegramChannel {
|
||||
return PeerInfoScreen(context: context, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: keepExpandedButtons, mainAction: mainAction)
|
||||
return PeerInfoScreen(context: context, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: keepExpandedButtons)
|
||||
} else if peer is TelegramUser {
|
||||
return PeerInfoScreen(context: context, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: keepExpandedButtons, mainAction: mainAction)
|
||||
var nearbyPeer = false
|
||||
if case .nearbyPeer = mode {
|
||||
nearbyPeer = true
|
||||
}
|
||||
return PeerInfoScreen(context: context, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, keepExpandedButtons: keepExpandedButtons, nearbyPeer: nearbyPeer)
|
||||
} else if peer is TelegramSecretChat {
|
||||
return userInfoController(context: context, peerId: peer.id, mode: mode)
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: PeerId?, navigate
|
||||
peerSignal = context.account.postbox.loadedPeerWithId(peerId) |> map(Optional.init)
|
||||
navigateDisposable.set((peerSignal |> take(1) |> deliverOnMainQueue).start(next: { peer in
|
||||
if let controller = controller, let peer = peer {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false, suggestSendMessage: false) {
|
||||
if let infoController = context.sharedContext.makePeerInfoController(context: context, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) {
|
||||
(controller.navigationController as? NavigationController)?.pushViewController(infoController)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user