mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add multiple reactions premium suggestion
This commit is contained in:
parent
546a19834f
commit
a1df141c67
@ -10594,3 +10594,5 @@ Sorry for the inconvenience.";
|
|||||||
"Chat.TopicIsClosedLabel" = "Topic \"%1$@\" is closed";
|
"Chat.TopicIsClosedLabel" = "Topic \"%1$@\" is closed";
|
||||||
"Chat.InputPlaceholderReplyInTopic" = "Reply in %1$@";
|
"Chat.InputPlaceholderReplyInTopic" = "Reply in %1$@";
|
||||||
"Chat.InputPlaceholderMessageInTopic" = "Message in %1$@";
|
"Chat.InputPlaceholderMessageInTopic" = "Message in %1$@";
|
||||||
|
|
||||||
|
"Chat.Reactions.MultiplePremiumTooltip" = "You can set multiple reactions with [Telegram Premium]().";
|
||||||
|
@ -187,6 +187,7 @@ private enum ApplicationSpecificGlobalNotice: Int32 {
|
|||||||
case replyQuoteTextSelectionTip = 53
|
case replyQuoteTextSelectionTip = 53
|
||||||
case dismissedPremiumWallpapersBadge = 54
|
case dismissedPremiumWallpapersBadge = 54
|
||||||
case dismissedPremiumColorsBadge = 55
|
case dismissedPremiumColorsBadge = 55
|
||||||
|
case multipleReactionsSuggestion = 56
|
||||||
|
|
||||||
var key: ValueBoxKey {
|
var key: ValueBoxKey {
|
||||||
let v = ValueBoxKey(length: 4)
|
let v = ValueBoxKey(length: 4)
|
||||||
@ -461,6 +462,9 @@ private struct ApplicationSpecificNoticeKeys {
|
|||||||
static func dismissedPremiumColorsBadge() -> NoticeEntryKey {
|
static func dismissedPremiumColorsBadge() -> NoticeEntryKey {
|
||||||
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.dismissedPremiumColorsBadge.key)
|
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 {
|
public struct ApplicationSpecificNotice {
|
||||||
@ -1821,4 +1825,31 @@ public struct ApplicationSpecificNotice {
|
|||||||
}
|
}
|
||||||
|> take(1)
|
|> take(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static func getMultipleReactionsSuggestion(accountManager: AccountManager<TelegramAccountManagerTypes>) -> Signal<Int32, NoError> {
|
||||||
|
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<TelegramAccountManagerTypes>, count: Int = 1) -> Signal<Int, NoError> {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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()
|
let _ = updateMessageReactionsInteractively(account: strongSelf.context.account, messageId: message.id, reactions: mappedUpdatedReactions, isLarge: false, storeAsRecentlyUsed: false).startStandalone()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user