diff --git a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift index 8c66c43bae..8758b43e1c 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift @@ -404,6 +404,19 @@ public func resendMessages(account: Account, messageIds: [MessageId]) -> Signal< return account.postbox.transaction { transaction -> Void in var removeMessageIds: [MessageId] = [] for (peerId, ids) in messagesIdsGroupedByPeerId(messageIds) { + var sendPaidMessageStars: StarsAmount? + let peer = transaction.getPeer(peerId) + if let user = peer as? TelegramUser, user.flags.contains(.requireStars) { + if let cachedUserData = transaction.getPeerCachedData(peerId: user.id) as? CachedUserData { + sendPaidMessageStars = cachedUserData.sendPaidMessageStars + } + } else if let channel = peer as? TelegramChannel { + if channel.flags.contains(.isCreator) || channel.adminRights != nil { + } else { + sendPaidMessageStars = channel.sendPaidMessageStars + } + } + var messages: [EnqueueMessage] = [] for id in ids { if let message = transaction.getMessage(id), !message.flags.contains(.Incoming) { @@ -425,9 +438,16 @@ public func resendMessages(account: Account, messageIds: [MessageId]) -> Signal< } else if let attribute = attribute as? ForwardSourceInfoAttribute { forwardSource = attribute.messageId } else { - filteredAttributes.append(attribute) + if attribute is PaidStarsMessageAttribute { + } else { + filteredAttributes.append(attribute) + } } } + + if let sendPaidMessageStars { + filteredAttributes.append(PaidStarsMessageAttribute(stars: sendPaidMessageStars, postponeSending: false)) + } if let forwardSource = forwardSource { messages.append(.forward(source: forwardSource, threadId: nil, grouping: .auto, attributes: filteredAttributes, correlationId: nil)) diff --git a/submodules/TelegramUI/Components/Chat/ChatUserInfoItem/Sources/ChatUserInfoItem.swift b/submodules/TelegramUI/Components/Chat/ChatUserInfoItem/Sources/ChatUserInfoItem.swift index b20939179e..9bf11f830f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatUserInfoItem/Sources/ChatUserInfoItem.swift +++ b/submodules/TelegramUI/Components/Chat/ChatUserInfoItem/Sources/ChatUserInfoItem.swift @@ -311,10 +311,10 @@ public final class ChatUserInfoItemNode: ListViewItemNode, ASGestureRecognizerDe } else { var countryName = "" let countriesConfiguration = item.context.currentCountriesConfiguration.with { $0 } - if let country = countriesConfiguration.countries.first(where: { $0.id == phoneCountry }) { - countryName = country.localizedName ?? country.name - } else if phoneCountry == "FT" { + if phoneCountry == "FT" { countryName = item.presentationData.strings.Chat_NonContactUser_AnonymousNumber + } else if let country = countriesConfiguration.countries.first(where: { $0.id == phoneCountry }) { + countryName = country.localizedName ?? country.name } else if phoneCountry == "TS" { countryName = "Test" } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerPaidMessage.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerPaidMessage.swift index ae7516293a..cae3d5b3d9 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerPaidMessage.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerPaidMessage.swift @@ -15,7 +15,7 @@ import TelegramPresentationData import TelegramNotices extension ChatControllerImpl { - func presentPaidMessageAlertIfNeeded(count: Int32 = 1, forceDark: Bool = false, completion: @escaping (Bool) -> Void) { + func presentPaidMessageAlertIfNeeded(count: Int32 = 1, forceDark: Bool = false, alwaysAsk: Bool = false, completion: @escaping (Bool) -> Void) { guard let peer = self.presentationInterfaceState.renderedPeer?.peer.flatMap(EnginePeer.init) else { completion(false) return @@ -24,11 +24,12 @@ extension ChatControllerImpl { let totalAmount = sendPaidMessageStars.value * Int64(count) let _ = (ApplicationSpecificNotice.dismissedPaidMessageWarningNamespace(accountManager: self.context.sharedContext.accountManager, peerId: peer.id) + |> take(1) |> deliverOnMainQueue).start(next: { [weak self] dismissedAmount in guard let self, let starsContext = self.context.starsContext else { return } - if let dismissedAmount, dismissedAmount == sendPaidMessageStars.value, let currentState = starsContext.currentState, currentState.balance.value > totalAmount { + if !alwaysAsk, let dismissedAmount, dismissedAmount == sendPaidMessageStars.value, let currentState = starsContext.currentState, currentState.balance.value > totalAmount { if count < 3 && totalAmount < 100 { completion(false) } else { @@ -52,6 +53,7 @@ extension ChatControllerImpl { count: count, amount: sendPaidMessageStars, totalAmount: nil, + hasCheck: !alwaysAsk, navigationController: self.navigationController as? NavigationController, completion: { [weak self] dontAskAgain in guard let self else { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index fda440a9a1..f61918c4e7 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -3140,19 +3140,29 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G actions.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_MessageDialogRetry, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor) }, action: { [weak self] _, f in - if let strongSelf = self { - let _ = resendMessages(account: strongSelf.context.account, messageIds: selectedGroup.map({ $0.id })).startStandalone() + if let self { + self.presentPaidMessageAlertIfNeeded(count: Int32(selectedGroup.count), alwaysAsk: true, completion: { [weak self] _ in + guard let self else { + return + } + let _ = resendMessages(account: self.context.account, messageIds: selectedGroup.map({ $0.id })).startStandalone() + }) + f(self.presentationInterfaceState.sendPaidMessageStars == nil ? .dismissWithoutContent : .default) } - f(.dismissWithoutContent) }))) if totalGroupCount != 1 { actions.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_MessageDialogRetryAll(totalGroupCount).string, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor) }, action: { [weak self] _, f in - if let strongSelf = self { - let _ = resendMessages(account: strongSelf.context.account, messageIds: messages.map({ $0.id })).startStandalone() + if let self { + self.presentPaidMessageAlertIfNeeded(count: Int32(messages.count), alwaysAsk: true, completion: { [weak self] _ in + guard let self else { + return + } + let _ = resendMessages(account: self.context.account, messageIds: messages.map({ $0.id })).startStandalone() + }) + f(self.presentationInterfaceState.sendPaidMessageStars == nil ? .dismissWithoutContent : .default) } - f(.dismissWithoutContent) }))) } actions.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_ContextMenuDelete, textColor: .destructive, icon: { theme in