diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 7f7fa285e1..dfab72c269 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -10594,3 +10594,5 @@ Sorry for the inconvenience."; "Chat.TopicIsClosedLabel" = "Topic \"%1$@\" is closed"; "Chat.InputPlaceholderReplyInTopic" = "Reply in %1$@"; "Chat.InputPlaceholderMessageInTopic" = "Message in %1$@"; + +"Chat.Reactions.MultiplePremiumTooltip" = "You can set multiple reactions with [Telegram Premium]()."; diff --git a/submodules/TelegramNotices/Sources/Notices.swift b/submodules/TelegramNotices/Sources/Notices.swift index 800d91231e..96bb4d1af1 100644 --- a/submodules/TelegramNotices/Sources/Notices.swift +++ b/submodules/TelegramNotices/Sources/Notices.swift @@ -187,6 +187,7 @@ private enum ApplicationSpecificGlobalNotice: Int32 { case replyQuoteTextSelectionTip = 53 case dismissedPremiumWallpapersBadge = 54 case dismissedPremiumColorsBadge = 55 + case multipleReactionsSuggestion = 56 var key: ValueBoxKey { let v = ValueBoxKey(length: 4) @@ -461,6 +462,9 @@ private struct ApplicationSpecificNoticeKeys { static func dismissedPremiumColorsBadge() -> NoticeEntryKey { return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.dismissedPremiumColorsBadge.key) } + static func multipleReactionsSuggestion() -> NoticeEntryKey { + return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.multipleReactionsSuggestion.key) + } } public struct ApplicationSpecificNotice { @@ -1821,4 +1825,31 @@ public struct ApplicationSpecificNotice { } |> take(1) } + + public static func getMultipleReactionsSuggestion(accountManager: AccountManager) -> Signal { + return accountManager.transaction { transaction -> Int32 in + if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.multipleReactionsSuggestion())?.get(ApplicationSpecificCounterNotice.self) { + return value.value + } else { + return 0 + } + } + } + + public static func incrementMultipleReactionsSuggestion(accountManager: AccountManager, count: Int = 1) -> Signal { + return accountManager.transaction { transaction -> Int in + var currentValue: Int32 = 0 + if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.multipleReactionsSuggestion())?.get(ApplicationSpecificCounterNotice.self) { + currentValue = value.value + } + let previousValue = currentValue + currentValue += Int32(count) + + if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + transaction.setNotice(ApplicationSpecificNoticeKeys.multipleReactionsSuggestion(), entry) + } + + return Int(previousValue) + } + } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 96c8520309..2e54746eb9 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1607,6 +1607,33 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } + if !strongSelf.presentationInterfaceState.isPremium && mappedUpdatedReactions.count > strongSelf.context.userLimits.maxReactionsPerMessage { + let _ = (ApplicationSpecificNotice.incrementMultipleReactionsSuggestion(accountManager: strongSelf.context.sharedContext.accountManager) + |> deliverOnMainQueue).startStandalone(next: { [weak self] count in + guard let self else { + return + } + if count < 1 { + let context = self.context + let controller = UndoOverlayController( + presentationData: self.presentationData, + content: .premiumPaywall(title: nil, text: self.presentationData.strings.Chat_Reactions_MultiplePremiumTooltip, customUndoText: nil, timeout: nil, linkAction: nil), + elevatedLayout: false, + action: { [weak self] action in + if case .info = action { + if let self { + let controller = context.sharedContext.makePremiumIntroController(context: context, source: .reactions, forceDark: false, dismissed: nil) + self.push(controller) + } + } + return true + } + ) + self.present(controller, in: .current) + } + }) + } + let _ = updateMessageReactionsInteractively(account: strongSelf.context.account, messageId: message.id, reactions: mappedUpdatedReactions, isLarge: false, storeAsRecentlyUsed: false).startStandalone() } })