mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Merge commit '72a31f187c7b6711c5547039fb124dc56b5e5d1e'
# Conflicts: # submodules/DebugSettingsUI/Sources/DebugController.swift # submodules/TelegramCore/Sources/ApiUtils/ReactionsMessageAttribute.swift # submodules/TelegramCore/Sources/Network/Network.swift # submodules/TelegramCore/Sources/State/MessageReactions.swift
This commit is contained in:
@@ -526,7 +526,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
|
||||
private var translationStateDisposable: Disposable?
|
||||
|
||||
private var premiumGiftSuggestionDisposable: Disposable?
|
||||
|
||||
private var nextChannelToReadDisposable: Disposable?
|
||||
private var offerNextChannelToRead = false
|
||||
|
||||
@@ -1511,13 +1512,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
availableReactions: availableReactions,
|
||||
animationCache: strongSelf.controllerInteraction!.presentationContext.animationCache,
|
||||
animationRenderer: strongSelf.controllerInteraction!.presentationContext.animationRenderer,
|
||||
message: EngineMessage(message), reaction: value, readStats: nil, back: nil, openPeer: { peer in
|
||||
message: EngineMessage(message), reaction: value, readStats: nil, back: nil, openPeer: { peer, hasReaction in
|
||||
dismissController?({
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
strongSelf.openPeer(peer: peer, navigation: .default, fromMessage: MessageReference(message), fromReactionMessageId: message.id)
|
||||
strongSelf.openPeer(peer: peer, navigation: .default, fromMessage: MessageReference(message), fromReactionMessageId: hasReaction ? message.id : nil)
|
||||
})
|
||||
})))
|
||||
|
||||
@@ -6023,6 +6024,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.preloadAttachBotIconsDisposables?.dispose()
|
||||
self.keepMessageCountersSyncrhonizedDisposable?.dispose()
|
||||
self.translationStateDisposable?.dispose()
|
||||
self.premiumGiftSuggestionDisposable?.dispose()
|
||||
self.powerSavingMonitoringDisposable?.dispose()
|
||||
}
|
||||
deallocate()
|
||||
@@ -6739,7 +6741,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
let isTopReplyThreadMessageShown: Signal<Bool, NoError> = self.chatDisplayNode.historyNode.isTopReplyThreadMessageShown.get()
|
||||
|> distinctUntilChanged
|
||||
|
||||
let topPinnedMessage: Signal<ChatPinnedMessage?, NoError> = self.topPinnedMessageSignal(latest: false)
|
||||
let topPinnedMessage: Signal<ChatPinnedMessage?, NoError>
|
||||
if let subject = self.subject {
|
||||
switch subject {
|
||||
case .forwardedMessages, .pinnedMessages, .scheduledMessages:
|
||||
topPinnedMessage = .single(nil)
|
||||
default:
|
||||
topPinnedMessage = self.topPinnedMessageSignal(latest: false)
|
||||
}
|
||||
} else {
|
||||
topPinnedMessage = self.topPinnedMessageSignal(latest: false)
|
||||
}
|
||||
|
||||
if let peerId = self.chatLocation.peerId {
|
||||
self.themeEmoticonPromise.set(self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.ThemeEmoticon(id: peerId)))
|
||||
@@ -6816,6 +6828,15 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
if case .standard(previewing: true) = self.presentationInterfaceState.mode {
|
||||
|
||||
} else if peerId.namespace != Namespaces.Peer.SecretChat && peerId != context.account.peerId && self.subject != .scheduledMessages {
|
||||
self.premiumGiftSuggestionDisposable = (ApplicationSpecificNotice.dismissedPremiumGiftSuggestion(accountManager: self.context.sharedContext.accountManager, peerId: peerId)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] counter in
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: strongSelf.willAppear, interactive: strongSelf.willAppear, { state in
|
||||
return state.updatedSuggestPremiumGift(counter == 0)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
var baseLanguageCode = self.presentationData.strings.baseLanguageCode
|
||||
if baseLanguageCode.contains("-") {
|
||||
baseLanguageCode = baseLanguageCode.components(separatedBy: "-").first ?? baseLanguageCode
|
||||
@@ -6893,6 +6914,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var slowmodeState: ChatSlowmodeState?
|
||||
var activeGroupCallInfo: ChatActiveGroupCallInfo?
|
||||
var inviteRequestsPending: Int32?
|
||||
var premiumGiftOptions: [CachedPremiumGiftOption] = []
|
||||
if let cachedData = cachedData as? CachedChannelData {
|
||||
pinnedMessageId = cachedData.pinnedMessageId
|
||||
if let channel = strongSelf.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isRestrictedBySlowmode, let timeout = cachedData.slowModeTimeout {
|
||||
@@ -6912,6 +6934,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
callsPrivate = cachedData.callsPrivate
|
||||
pinnedMessageId = cachedData.pinnedMessageId
|
||||
voiceMessagesAvailable = cachedData.voiceMessagesAvailable
|
||||
premiumGiftOptions = cachedData.premiumGiftOptions
|
||||
} else if let cachedData = cachedData as? CachedGroupData {
|
||||
pinnedMessageId = cachedData.pinnedMessageId
|
||||
if let activeCall = cachedData.activeCall {
|
||||
@@ -7042,7 +7065,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
|
||||
if strongSelf.presentationInterfaceState.pinnedMessageId != pinnedMessageId || strongSelf.presentationInterfaceState.pinnedMessage != pinnedMessage || strongSelf.presentationInterfaceState.peerIsBlocked != peerIsBlocked || pinnedMessageUpdated || callsDataUpdated || voiceMessagesAvailableUpdated || strongSelf.presentationInterfaceState.slowmodeState != slowmodeState || strongSelf.presentationInterfaceState.activeGroupCallInfo != activeGroupCallInfo || customEmojiAvailable != strongSelf.presentationInterfaceState.customEmojiAvailable || threadData != strongSelf.presentationInterfaceState.threadData || isGeneralThreadClosed != strongSelf.presentationInterfaceState.isGeneralThreadClosed {
|
||||
if strongSelf.presentationInterfaceState.pinnedMessageId != pinnedMessageId || strongSelf.presentationInterfaceState.pinnedMessage != pinnedMessage || strongSelf.presentationInterfaceState.peerIsBlocked != peerIsBlocked || pinnedMessageUpdated || callsDataUpdated || voiceMessagesAvailableUpdated || strongSelf.presentationInterfaceState.slowmodeState != slowmodeState || strongSelf.presentationInterfaceState.activeGroupCallInfo != activeGroupCallInfo || customEmojiAvailable != strongSelf.presentationInterfaceState.customEmojiAvailable || threadData != strongSelf.presentationInterfaceState.threadData || isGeneralThreadClosed != strongSelf.presentationInterfaceState.isGeneralThreadClosed || premiumGiftOptions != strongSelf.presentationInterfaceState.premiumGiftOptions {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: strongSelf.willAppear, interactive: strongSelf.willAppear, { state in
|
||||
return state
|
||||
.updatedPinnedMessageId(pinnedMessageId)
|
||||
@@ -7055,6 +7078,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
.updatedCustomEmojiAvailable(customEmojiAvailable)
|
||||
.updatedThreadData(threadData)
|
||||
.updatedIsGeneralThreadClosed(isGeneralThreadClosed)
|
||||
.updatedPremiumGiftOptions(premiumGiftOptions)
|
||||
.updatedTitlePanelContext({ context in
|
||||
if pinnedMessageId != nil {
|
||||
if !context.contains(where: {
|
||||
@@ -7471,7 +7495,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.oldPresentAttachmentMenu(editMediaOptions: options, editMediaReference: originalMediaReference)
|
||||
})
|
||||
} else {
|
||||
strongSelf.presentAttachmentMenu(editMediaOptions: nil, editMediaReference: nil)
|
||||
strongSelf.presentAttachmentMenu(subject: .default)
|
||||
}
|
||||
}
|
||||
self.chatDisplayNode.paste = { [weak self] data in
|
||||
@@ -9783,7 +9807,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
let _ = ApplicationSpecificNotice.incrementChatMessageOptionsTip(accountManager: strongSelf.context.sharedContext.accountManager, count: 4).start()
|
||||
|
||||
let controller = ChatSendMessageActionSheetController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, interfaceState: strongSelf.presentationInterfaceState, gesture: gesture, sourceSendButton: node, textInputNode: textInputNode, completion: { [weak self] in
|
||||
var hasEntityKeyboard = false
|
||||
if case .media = strongSelf.presentationInterfaceState.inputMode {
|
||||
hasEntityKeyboard = true
|
||||
}
|
||||
|
||||
let controller = ChatSendMessageActionSheetController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peerId: strongSelf.presentationInterfaceState.chatLocation.peerId, forwardMessageIds: strongSelf.presentationInterfaceState.interfaceState.forwardMessageIds, hasEntityKeyboard: hasEntityKeyboard, gesture: gesture, sourceSendButton: node, textInputNode: textInputNode, completion: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.supportedOrientations = previousSupportedOrientations
|
||||
}
|
||||
@@ -10229,6 +10258,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
return true
|
||||
}), in: .current)
|
||||
}, openPremiumGift: { [weak self] in
|
||||
guard let strongSelf = self, let peerId = strongSelf.chatLocation.peerId else {
|
||||
return
|
||||
}
|
||||
strongSelf.presentAttachmentPremiumGift()
|
||||
let _ = ApplicationSpecificNotice.incrementDismissedPremiumGiftSuggestion(accountManager: strongSelf.context.sharedContext.accountManager, peerId: peerId).start()
|
||||
}, requestLayout: { [weak self] transition in
|
||||
if let strongSelf = self, let layout = strongSelf.validLayout {
|
||||
strongSelf.containerLayoutUpdated(layout, transition: transition)
|
||||
@@ -12533,7 +12568,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
public func presentAttachmentBot(botId: PeerId, payload: String?, justInstalled: Bool) {
|
||||
self.attachmentController?.dismiss(animated: true, completion: nil)
|
||||
self.presentAttachmentMenu(editMediaOptions: nil, editMediaReference: nil, botId: botId, botPayload: payload, botJustInstalled: justInstalled)
|
||||
self.presentAttachmentMenu(subject: .bot(id: botId, payload: payload, justInstalled: justInstalled))
|
||||
}
|
||||
|
||||
public func presentBotApp(botApp: BotApp, payload: String?) {
|
||||
@@ -12611,7 +12646,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}))
|
||||
}
|
||||
|
||||
private func presentAttachmentMenu(editMediaOptions: MessageMediaEditingOptions?, editMediaReference: AnyMediaReference?, botId: PeerId? = nil, botPayload: String? = nil, botJustInstalled: Bool = false) {
|
||||
private func presentAttachmentPremiumGift() {
|
||||
self.presentAttachmentMenu(subject: .gift)
|
||||
}
|
||||
|
||||
private enum AttachMenuSubject {
|
||||
case `default`
|
||||
case edit(mediaOptions: MessageMediaEditingOptions, mediaReference: AnyMediaReference)
|
||||
case bot(id: PeerId, payload: String?, justInstalled: Bool)
|
||||
case gift
|
||||
}
|
||||
//editMediaOptions: MessageMediaEditingOptions?, editMediaReference: AnyMediaReference?, botId: PeerId? = nil, botPayload: String? = nil, botJustInstalled: Bool = false
|
||||
private func presentAttachmentMenu(subject: AttachMenuSubject) {
|
||||
guard let peer = self.presentationInterfaceState.renderedPeer?.peer else {
|
||||
return
|
||||
}
|
||||
@@ -12705,28 +12751,31 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|> map { attachMenuBots in
|
||||
var buttons = availableButtons
|
||||
var allButtons = availableButtons
|
||||
|
||||
var initialButton: AttachmentButtonType?
|
||||
if botId == nil {
|
||||
switch subject {
|
||||
case .default:
|
||||
initialButton = .gallery
|
||||
}
|
||||
|
||||
for bot in attachMenuBots.reversed() {
|
||||
var peerType = peerType
|
||||
if bot.peer.id == peer.id {
|
||||
peerType.insert(.sameBot)
|
||||
peerType.remove(.bot)
|
||||
}
|
||||
|
||||
let button: AttachmentButtonType = .app(bot.peer, bot.shortName, bot.icons)
|
||||
if !bot.peerTypes.intersection(peerType).isEmpty {
|
||||
buttons.insert(button, at: 1)
|
||||
|
||||
if initialButton == nil && bot.peer.id == botId {
|
||||
initialButton = button
|
||||
case .edit:
|
||||
break
|
||||
case .gift:
|
||||
initialButton = .gift
|
||||
case let .bot(botId, _, _):
|
||||
for bot in attachMenuBots.reversed() {
|
||||
var peerType = peerType
|
||||
if bot.peer.id == peer.id {
|
||||
peerType.insert(.sameBot)
|
||||
peerType.remove(.bot)
|
||||
}
|
||||
let button: AttachmentButtonType = .app(bot.peer, bot.shortName, bot.icons)
|
||||
if !bot.peerTypes.intersection(peerType).isEmpty {
|
||||
buttons.insert(button, at: 1)
|
||||
|
||||
if initialButton == nil && bot.peer.id == botId {
|
||||
initialButton = button
|
||||
}
|
||||
}
|
||||
allButtons.insert(button, at: 1)
|
||||
}
|
||||
allButtons.insert(button, at: 1)
|
||||
}
|
||||
return (buttons, allButtons, initialButton)
|
||||
}
|
||||
@@ -12739,15 +12788,26 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return entry ?? GeneratedMediaStoreSettings.defaultSettings
|
||||
}
|
||||
|
||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: self.context.currentAppConfiguration.with { $0 })
|
||||
let premiumGiftOptions: [CachedPremiumGiftOption]
|
||||
if !premiumConfiguration.isPremiumDisabled && premiumConfiguration.showPremiumGiftInAttachMenu, let user = peer as? TelegramUser, !user.isPremium && !user.isDeleted && user.botInfo == nil && !user.flags.contains(.isSupport) {
|
||||
premiumGiftOptions = self.presentationInterfaceState.premiumGiftOptions
|
||||
} else {
|
||||
premiumGiftOptions = []
|
||||
}
|
||||
|
||||
let _ = combineLatest(queue: Queue.mainQueue(), buttons, dataSettings).start(next: { [weak self] buttonsAndInitialButton, dataSettings in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
let (buttons, allButtons, initialButton) = buttonsAndInitialButton
|
||||
var (buttons, allButtons, initialButton) = buttonsAndInitialButton
|
||||
if !premiumGiftOptions.isEmpty {
|
||||
buttons.insert(.gift, at: 1)
|
||||
}
|
||||
|
||||
guard let initialButton = initialButton else {
|
||||
if let botId = botId {
|
||||
if case let .bot(botId, botPayload, botJustInstalled) = subject {
|
||||
if let button = allButtons.first(where: { button in
|
||||
if case let .app(botPeer, _, _) = button, botPeer.id == botId {
|
||||
return true
|
||||
@@ -12847,7 +12907,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: mediaReference, replyToMessageId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])
|
||||
let _ = (enqueueMessages(account: strongSelf.context.account, peerId: peerId, messages: strongSelf.transformEnqueueMessages([message]))
|
||||
|> deliverOnMainQueue).start(next: { [weak self] _ in
|
||||
|> deliverOnMainQueue).start(next: { [weak self] _ in
|
||||
if let strongSelf = self, strongSelf.presentationInterfaceState.subject != .scheduledMessages {
|
||||
strongSelf.chatDisplayNode.historyNode.scrollToEndOfHistory()
|
||||
}
|
||||
@@ -12872,7 +12932,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
selfPeerId = strongSelf.context.account.peerId
|
||||
}
|
||||
let _ = (strongSelf.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: selfPeerId))
|
||||
|> deliverOnMainQueue).start(next: { [weak self] selfPeer in
|
||||
|> deliverOnMainQueue).start(next: { [weak self] selfPeer in
|
||||
guard let strongSelf = self, let selfPeer = selfPeer else {
|
||||
return
|
||||
}
|
||||
@@ -12908,7 +12968,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
contactsController.navigationPresentation = .modal
|
||||
completion(contactsController, contactsController.mediaPickerContext)
|
||||
strongSelf.controllerNavigationDisposable.set((contactsController.result
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peers in
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peers in
|
||||
if let strongSelf = self, let (peers, _, silent, scheduleTime, text) = peers {
|
||||
var textEnqueueMessage: EnqueueMessage?
|
||||
if let text = text, text.length > 0 {
|
||||
@@ -12927,24 +12987,24 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
for peer in peers {
|
||||
var media: TelegramMediaContact?
|
||||
switch peer {
|
||||
case let .peer(contact, _, _):
|
||||
guard let contact = contact as? TelegramUser, let phoneNumber = contact.phone else {
|
||||
continue
|
||||
}
|
||||
let contactData = DeviceContactExtendedData(basicData: DeviceContactBasicData(firstName: contact.firstName ?? "", lastName: contact.lastName ?? "", phoneNumbers: [DeviceContactPhoneNumberData(label: "_$!<Mobile>!$_", value: phoneNumber)]), middleName: "", prefix: "", suffix: "", organization: "", jobTitle: "", department: "", emailAddresses: [], urls: [], addresses: [], birthdayDate: nil, socialProfiles: [], instantMessagingProfiles: [], note: "")
|
||||
|
||||
let phone = contactData.basicData.phoneNumbers[0].value
|
||||
media = TelegramMediaContact(firstName: contactData.basicData.firstName, lastName: contactData.basicData.lastName, phoneNumber: phone, peerId: contact.id, vCardData: nil)
|
||||
case let .deviceContact(_, basicData):
|
||||
guard !basicData.phoneNumbers.isEmpty else {
|
||||
continue
|
||||
}
|
||||
let contactData = DeviceContactExtendedData(basicData: basicData, middleName: "", prefix: "", suffix: "", organization: "", jobTitle: "", department: "", emailAddresses: [], urls: [], addresses: [], birthdayDate: nil, socialProfiles: [], instantMessagingProfiles: [], note: "")
|
||||
|
||||
let phone = contactData.basicData.phoneNumbers[0].value
|
||||
media = TelegramMediaContact(firstName: contactData.basicData.firstName, lastName: contactData.basicData.lastName, phoneNumber: phone, peerId: nil, vCardData: nil)
|
||||
case let .peer(contact, _, _):
|
||||
guard let contact = contact as? TelegramUser, let phoneNumber = contact.phone else {
|
||||
continue
|
||||
}
|
||||
let contactData = DeviceContactExtendedData(basicData: DeviceContactBasicData(firstName: contact.firstName ?? "", lastName: contact.lastName ?? "", phoneNumbers: [DeviceContactPhoneNumberData(label: "_$!<Mobile>!$_", value: phoneNumber)]), middleName: "", prefix: "", suffix: "", organization: "", jobTitle: "", department: "", emailAddresses: [], urls: [], addresses: [], birthdayDate: nil, socialProfiles: [], instantMessagingProfiles: [], note: "")
|
||||
|
||||
let phone = contactData.basicData.phoneNumbers[0].value
|
||||
media = TelegramMediaContact(firstName: contactData.basicData.firstName, lastName: contactData.basicData.lastName, phoneNumber: phone, peerId: contact.id, vCardData: nil)
|
||||
case let .deviceContact(_, basicData):
|
||||
guard !basicData.phoneNumbers.isEmpty else {
|
||||
continue
|
||||
}
|
||||
let contactData = DeviceContactExtendedData(basicData: basicData, middleName: "", prefix: "", suffix: "", organization: "", jobTitle: "", department: "", emailAddresses: [], urls: [], addresses: [], birthdayDate: nil, socialProfiles: [], instantMessagingProfiles: [], note: "")
|
||||
|
||||
let phone = contactData.basicData.phoneNumbers[0].value
|
||||
media = TelegramMediaContact(firstName: contactData.basicData.firstName, lastName: contactData.basicData.lastName, phoneNumber: phone, peerId: nil, vCardData: nil)
|
||||
}
|
||||
|
||||
|
||||
if let media = media {
|
||||
let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId
|
||||
strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({
|
||||
@@ -12964,45 +13024,45 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
} else if let peer = peers.first {
|
||||
let dataSignal: Signal<(Peer?, DeviceContactExtendedData?), NoError>
|
||||
switch peer {
|
||||
case let .peer(contact, _, _):
|
||||
guard let contact = contact as? TelegramUser, let phoneNumber = contact.phone else {
|
||||
return
|
||||
}
|
||||
let contactData = DeviceContactExtendedData(basicData: DeviceContactBasicData(firstName: contact.firstName ?? "", lastName: contact.lastName ?? "", phoneNumbers: [DeviceContactPhoneNumberData(label: "_$!<Mobile>!$_", value: phoneNumber)]), middleName: "", prefix: "", suffix: "", organization: "", jobTitle: "", department: "", emailAddresses: [], urls: [], addresses: [], birthdayDate: nil, socialProfiles: [], instantMessagingProfiles: [], note: "")
|
||||
let context = strongSelf.context
|
||||
dataSignal = (strongSelf.context.sharedContext.contactDataManager?.basicData() ?? .single([:]))
|
||||
|> take(1)
|
||||
|> mapToSignal { basicData -> Signal<(Peer?, DeviceContactExtendedData?), NoError> in
|
||||
var stableId: String?
|
||||
let queryPhoneNumber = formatPhoneNumber(context: context, number: phoneNumber)
|
||||
outer: for (id, data) in basicData {
|
||||
for phoneNumber in data.phoneNumbers {
|
||||
if formatPhoneNumber(context: context, number: phoneNumber.value) == queryPhoneNumber {
|
||||
stableId = id
|
||||
break outer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let stableId = stableId {
|
||||
return (context.sharedContext.contactDataManager?.extendedData(stableId: stableId) ?? .single(nil))
|
||||
|> take(1)
|
||||
|> map { extendedData -> (Peer?, DeviceContactExtendedData?) in
|
||||
return (contact, extendedData)
|
||||
}
|
||||
} else {
|
||||
return .single((contact, contactData))
|
||||
case let .peer(contact, _, _):
|
||||
guard let contact = contact as? TelegramUser, let phoneNumber = contact.phone else {
|
||||
return
|
||||
}
|
||||
let contactData = DeviceContactExtendedData(basicData: DeviceContactBasicData(firstName: contact.firstName ?? "", lastName: contact.lastName ?? "", phoneNumbers: [DeviceContactPhoneNumberData(label: "_$!<Mobile>!$_", value: phoneNumber)]), middleName: "", prefix: "", suffix: "", organization: "", jobTitle: "", department: "", emailAddresses: [], urls: [], addresses: [], birthdayDate: nil, socialProfiles: [], instantMessagingProfiles: [], note: "")
|
||||
let context = strongSelf.context
|
||||
dataSignal = (strongSelf.context.sharedContext.contactDataManager?.basicData() ?? .single([:]))
|
||||
|> take(1)
|
||||
|> mapToSignal { basicData -> Signal<(Peer?, DeviceContactExtendedData?), NoError> in
|
||||
var stableId: String?
|
||||
let queryPhoneNumber = formatPhoneNumber(context: context, number: phoneNumber)
|
||||
outer: for (id, data) in basicData {
|
||||
for phoneNumber in data.phoneNumbers {
|
||||
if formatPhoneNumber(context: context, number: phoneNumber.value) == queryPhoneNumber {
|
||||
stableId = id
|
||||
break outer
|
||||
}
|
||||
}
|
||||
case let .deviceContact(id, _):
|
||||
dataSignal = (strongSelf.context.sharedContext.contactDataManager?.extendedData(stableId: id) ?? .single(nil))
|
||||
|> take(1)
|
||||
|> map { extendedData -> (Peer?, DeviceContactExtendedData?) in
|
||||
return (nil, extendedData)
|
||||
}
|
||||
|
||||
if let stableId = stableId {
|
||||
return (context.sharedContext.contactDataManager?.extendedData(stableId: stableId) ?? .single(nil))
|
||||
|> take(1)
|
||||
|> map { extendedData -> (Peer?, DeviceContactExtendedData?) in
|
||||
return (contact, extendedData)
|
||||
}
|
||||
} else {
|
||||
return .single((contact, contactData))
|
||||
}
|
||||
}
|
||||
case let .deviceContact(id, _):
|
||||
dataSignal = (strongSelf.context.sharedContext.contactDataManager?.extendedData(stableId: id) ?? .single(nil))
|
||||
|> take(1)
|
||||
|> map { extendedData -> (Peer?, DeviceContactExtendedData?) in
|
||||
return (nil, extendedData)
|
||||
}
|
||||
}
|
||||
strongSelf.controllerNavigationDisposable.set((dataSignal
|
||||
|> deliverOnMainQueue).start(next: { peerAndContactData in
|
||||
|> deliverOnMainQueue).start(next: { peerAndContactData in
|
||||
if let strongSelf = self, let contactData = peerAndContactData.1, contactData.basicData.phoneNumbers.count != 0 {
|
||||
if contactData.isPrimitive {
|
||||
let phone = contactData.basicData.phoneNumbers[0].value
|
||||
@@ -13062,8 +13122,30 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
let controller = strongSelf.configurePollCreation()
|
||||
completion(controller, controller?.mediaPickerContext)
|
||||
strongSelf.controllerNavigationDisposable.set(nil)
|
||||
case .gift:
|
||||
let premiumGiftOptions = strongSelf.presentationInterfaceState.premiumGiftOptions
|
||||
if !premiumGiftOptions.isEmpty {
|
||||
let controller = PremiumGiftScreen(context: context, peerId: peer.id, options: premiumGiftOptions, source: .attachMenu, pushController: { [weak self] c in
|
||||
if let strongSelf = self {
|
||||
strongSelf.push(c)
|
||||
}
|
||||
}, completion: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.hintPlayNextOutgoingGift()
|
||||
strongSelf.attachmentController?.dismiss(animated: true)
|
||||
}
|
||||
})
|
||||
completion(controller, controller.mediaPickerContext)
|
||||
strongSelf.controllerNavigationDisposable.set(nil)
|
||||
|
||||
let _ = ApplicationSpecificNotice.incrementDismissedPremiumGiftSuggestion(accountManager: context.sharedContext.accountManager, peerId: peer.id).start()
|
||||
}
|
||||
case let .app(bot, botName, _):
|
||||
let params = WebAppParameters(peerId: peer.id, botId: bot.id, botName: botName, url: nil, queryId: nil, payload: botPayload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, isInline: false, isSimple: false)
|
||||
var payload: String?
|
||||
if case let .bot(_, botPayload, _) = subject {
|
||||
payload = botPayload
|
||||
}
|
||||
let params = WebAppParameters(peerId: peer.id, botId: bot.id, botName: botName, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, isInline: false, isSimple: false)
|
||||
let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId
|
||||
let controller = WebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, replyToMessageId: replyMessageId, threadId: strongSelf.chatLocation.threadId)
|
||||
controller.openUrl = { [weak self] url in
|
||||
@@ -16389,7 +16471,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
$0.updatedBotStartPayload(botStart.payload)
|
||||
})
|
||||
case .withAttachBot:
|
||||
self.presentAttachmentMenu(editMediaOptions: nil, editMediaReference: nil)
|
||||
self.presentAttachmentMenu(subject: .default)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user