Group boosts

This commit is contained in:
Ilya Laktyushin 2024-02-07 20:56:13 +04:00
parent 714bcf7af3
commit 6af485cff1
7 changed files with 23 additions and 14 deletions

View File

@ -11224,3 +11224,5 @@ Sorry for the inconvenience.";
"GroupBoost.Info" = "Members of your group can **boost** it so that it **levels up** and gets **exclusive features**."; "GroupBoost.Info" = "Members of your group can **boost** it so that it **levels up** and gets **exclusive features**.";
"Chat.GroupEmojiTooltip" = "All members of this group can\nuse the # **%@** pack"; "Chat.GroupEmojiTooltip" = "All members of this group can\nuse the # **%@** pack";
"GroupBoost.AskToBoost" = "Ask your **Premium** members to boost your group with this link:";

View File

@ -18,13 +18,16 @@ public final class ChatMessageItemAssociatedData: Equatable {
public struct DisplayTranscribeButton: Equatable { public struct DisplayTranscribeButton: Equatable {
public let canBeDisplayed: Bool public let canBeDisplayed: Bool
public let displayForNotConsumed: Bool public let displayForNotConsumed: Bool
public let providedByGroupBoost: Bool
public init( public init(
canBeDisplayed: Bool, canBeDisplayed: Bool,
displayForNotConsumed: Bool displayForNotConsumed: Bool,
providedByGroupBoost: Bool
) { ) {
self.canBeDisplayed = canBeDisplayed self.canBeDisplayed = canBeDisplayed
self.displayForNotConsumed = displayForNotConsumed self.displayForNotConsumed = displayForNotConsumed
self.providedByGroupBoost = providedByGroupBoost
} }
} }
@ -77,7 +80,7 @@ public final class ChatMessageItemAssociatedData: Equatable {
isPremium: Bool, isPremium: Bool,
accountPeer: EnginePeer?, accountPeer: EnginePeer?,
forceInlineReactions: Bool = false, forceInlineReactions: Bool = false,
alwaysDisplayTranscribeButton: DisplayTranscribeButton = DisplayTranscribeButton(canBeDisplayed: false, displayForNotConsumed: false), alwaysDisplayTranscribeButton: DisplayTranscribeButton = DisplayTranscribeButton(canBeDisplayed: false, displayForNotConsumed: false, providedByGroupBoost: false),
topicAuthorId: EnginePeer.Id? = nil, topicAuthorId: EnginePeer.Id? = nil,
hasBots: Bool = false, hasBots: Bool = false,
translateToLanguage: String? = nil, translateToLanguage: String? = nil,

View File

@ -205,7 +205,7 @@ public struct PremiumConfiguration {
minChannelEmojiStatusLevel: get(data["channel_emoji_status_level_min"]) ?? defaultValue.minChannelEmojiStatusLevel, minChannelEmojiStatusLevel: get(data["channel_emoji_status_level_min"]) ?? defaultValue.minChannelEmojiStatusLevel,
minChannelWallpaperLevel: get(data["channel_wallpaper_level_min"]) ?? defaultValue.minChannelWallpaperLevel, minChannelWallpaperLevel: get(data["channel_wallpaper_level_min"]) ?? defaultValue.minChannelWallpaperLevel,
minChannelCustomWallpaperLevel: get(data["channel_custom_wallpaper_level_min"]) ?? defaultValue.minChannelCustomWallpaperLevel, minChannelCustomWallpaperLevel: get(data["channel_custom_wallpaper_level_min"]) ?? defaultValue.minChannelCustomWallpaperLevel,
minGroupProfileIconLevel: get(data["group_profile_bg_icon_level_min "]) ?? defaultValue.minGroupProfileIconLevel, minGroupProfileIconLevel: get(data["group_profile_bg_icon_level_min"]) ?? defaultValue.minGroupProfileIconLevel,
minGroupEmojiStatusLevel: get(data["group_emoji_status_level_min"]) ?? defaultValue.minGroupEmojiStatusLevel, minGroupEmojiStatusLevel: get(data["group_emoji_status_level_min"]) ?? defaultValue.minGroupEmojiStatusLevel,
minGroupWallpaperLevel: get(data["group_wallpaper_level_min"]) ?? defaultValue.minGroupWallpaperLevel, minGroupWallpaperLevel: get(data["group_wallpaper_level_min"]) ?? defaultValue.minGroupWallpaperLevel,
minGroupCustomWallpaperLevel: get(data["group_custom_wallpaper_level_min"]) ?? defaultValue.minGroupCustomWallpaperLevel, minGroupCustomWallpaperLevel: get(data["group_custom_wallpaper_level_min"]) ?? defaultValue.minGroupCustomWallpaperLevel,

View File

@ -644,7 +644,7 @@ private final class SheetContent: CombinedComponent {
} }
if needsSecondParagraph { if needsSecondParagraph {
textString += "\n\n\(strings.ChannelBoost_AskToBoost)" textString += "\n\n\(isGroup ? strings.GroupBoost_AskToBoost : strings.ChannelBoost_AskToBoost)"
} }
} else { } else {
textString = strings.ChannelBoost_MaxLevelReached_Text(peerName, "\(level)").string textString = strings.ChannelBoost_MaxLevelReached_Text(peerName, "\(level)").string
@ -1102,10 +1102,6 @@ private final class SheetContent: CombinedComponent {
perks.append(.nameColor(nameColorsCount)) perks.append(.nameColor(nameColorsCount))
} }
if isGroup && level >= requiredBoostSubjectLevel(subject: .audioTranscription, group: isGroup, context: component.context, configuration: premiumConfiguration) {
perks.append(.audioTranscription)
}
var profileColorsCount: Int32 = 0 var profileColorsCount: Int32 = 0
for (colorLevel, count) in profileColorsAtLevel { for (colorLevel, count) in profileColorsAtLevel {
if level >= colorLevel { if level >= colorLevel {
@ -1115,13 +1111,17 @@ private final class SheetContent: CombinedComponent {
if profileColorsCount > 0 { if profileColorsCount > 0 {
perks.append(.profileColor(profileColorsCount)) perks.append(.profileColor(profileColorsCount))
} }
if isGroup && level >= requiredBoostSubjectLevel(subject: .emojiPack, group: isGroup, context: component.context, configuration: premiumConfiguration) {
perks.append(.emojiPack)
}
if level >= requiredBoostSubjectLevel(subject: .profileIcon, group: isGroup, context: component.context, configuration: premiumConfiguration) { if level >= requiredBoostSubjectLevel(subject: .profileIcon, group: isGroup, context: component.context, configuration: premiumConfiguration) {
perks.append(.profileIcon) perks.append(.profileIcon)
} }
if isGroup && level >= requiredBoostSubjectLevel(subject: .audioTranscription, group: isGroup, context: component.context, configuration: premiumConfiguration) { if isGroup && level >= requiredBoostSubjectLevel(subject: .audioTranscription, group: isGroup, context: component.context, configuration: premiumConfiguration) {
perks.append(.emojiPack) perks.append(.audioTranscription)
} }
var linkColorsCount: Int32 = 0 var linkColorsCount: Int32 = 0

View File

@ -361,7 +361,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
} }
} }
} else { } else {
guard arguments.associatedData.isPremium else { guard arguments.associatedData.isPremium || arguments.associatedData.alwaysDisplayTranscribeButton.providedByGroupBoost else {
if self.hapticFeedback == nil { if self.hapticFeedback == nil {
self.hapticFeedback = HapticFeedback() self.hapticFeedback = HapticFeedback()
} }
@ -771,6 +771,8 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
} else if arguments.incoming && isConsumed == false && arguments.associatedData.alwaysDisplayTranscribeButton.displayForNotConsumed { } else if arguments.incoming && isConsumed == false && arguments.associatedData.alwaysDisplayTranscribeButton.displayForNotConsumed {
displayTranscribe = true displayTranscribe = true
} }
} else if arguments.associatedData.alwaysDisplayTranscribeButton.providedByGroupBoost {
displayTranscribe = true
} }
} }

View File

@ -841,6 +841,8 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
} else { } else {
displayTranscribe = false displayTranscribe = false
} }
} else if item.associatedData.alwaysDisplayTranscribeButton.providedByGroupBoost {
displayTranscribe = true
} }
} }
@ -1813,13 +1815,12 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
} }
} }
} else { } else {
guard item.associatedData.isPremium else { guard item.associatedData.isPremium || item.associatedData.alwaysDisplayTranscribeButton.providedByGroupBoost else {
if self.hapticFeedback == nil { if self.hapticFeedback == nil {
self.hapticFeedback = HapticFeedback() self.hapticFeedback = HapticFeedback()
} }
self.hapticFeedback?.impact(.medium) self.hapticFeedback?.impact(.medium)
let tipController = UndoOverlayController(presentationData: presentationData, content: .universal(animation: "anim_voiceToText", scale: 0.065, colors: [:], title: nil, text: presentationData.strings.Message_AudioTranscription_SubscribeToPremium, customUndoText: presentationData.strings.Message_AudioTranscription_SubscribeToPremiumAction, timeout: nil), elevatedLayout: false, position: .top, animateInAsReplacement: false, action: { action in let tipController = UndoOverlayController(presentationData: presentationData, content: .universal(animation: "anim_voiceToText", scale: 0.065, colors: [:], title: nil, text: presentationData.strings.Message_AudioTranscription_SubscribeToPremium, customUndoText: presentationData.strings.Message_AudioTranscription_SubscribeToPremiumAction, timeout: nil), elevatedLayout: false, position: .top, animateInAsReplacement: false, action: { action in
if case .undo = action { if case .undo = action {
let context = item.context let context = item.context

View File

@ -1690,7 +1690,8 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
let alwaysDisplayTranscribeButton = ChatMessageItemAssociatedData.DisplayTranscribeButton( let alwaysDisplayTranscribeButton = ChatMessageItemAssociatedData.DisplayTranscribeButton(
canBeDisplayed: suggestAudioTranscription.0 < 2, canBeDisplayed: suggestAudioTranscription.0 < 2,
displayForNotConsumed: suggestAudioTranscription.1 displayForNotConsumed: suggestAudioTranscription.1,
providedByGroupBoost: false
) )
var translateToLanguage: String? var translateToLanguage: String?