Group boosts

This commit is contained in:
Ilya Laktyushin 2024-02-09 13:12:17 +04:00
parent b4ca0637a6
commit cd7c9ea73c
3 changed files with 19 additions and 18 deletions

View File

@ -601,6 +601,8 @@ private final class SheetContent: CombinedComponent {
var needsSecondParagraph = true var needsSecondParagraph = true
if let subject { if let subject {
let requiredLevel = subject.requiredLevel(group: isGroup, context: context.component.context, configuration: premiumConfiguration)
let storiesString = strings.ChannelBoost_StoriesPerDay(Int32(level) + 1) let storiesString = strings.ChannelBoost_StoriesPerDay(Int32(level) + 1)
let valueString = strings.ChannelBoost_MoreBoosts(Int32(remaining)) let valueString = strings.ChannelBoost_MoreBoosts(Int32(remaining))
switch subject { switch subject {
@ -615,24 +617,23 @@ private final class SheetContent: CombinedComponent {
textString = strings.ChannelBoost_CustomReactionsText("\(reactionCount)", "\(reactionCount)").string textString = strings.ChannelBoost_CustomReactionsText("\(reactionCount)", "\(reactionCount)").string
needsSecondParagraph = false needsSecondParagraph = false
case .nameColors: case .nameColors:
let colorLevel = subject.requiredLevel(group: isGroup, context: context.component.context, configuration: premiumConfiguration) textString = strings.ChannelBoost_EnableNameColorLevelText("\(requiredLevel)").string
textString = strings.ChannelBoost_EnableNameColorLevelText("\(colorLevel)").string
case .nameIcon: case .nameIcon:
textString = strings.ChannelBoost_EnableNameIconLevelText("\(premiumConfiguration.minChannelNameIconLevel)").string textString = strings.ChannelBoost_EnableNameIconLevelText("\(requiredLevel)").string
case .profileColors: case .profileColors:
textString = isGroup ? strings.GroupBoost_EnableProfileColorLevelText("\(premiumConfiguration.minChannelProfileColorLevel)").string : strings.ChannelBoost_EnableProfileColorLevelText("\(premiumConfiguration.minChannelProfileColorLevel)").string textString = isGroup ? strings.GroupBoost_EnableProfileColorLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableProfileColorLevelText("\(requiredLevel)").string
case .profileIcon: case .profileIcon:
textString = isGroup ? strings.GroupBoost_EnableProfileIconLevelText("\(premiumConfiguration.minChannelProfileIconLevel)").string : strings.ChannelBoost_EnableProfileIconLevelText("\(premiumConfiguration.minChannelProfileIconLevel)").string textString = isGroup ? strings.GroupBoost_EnableProfileIconLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableProfileIconLevelText("\(premiumConfiguration.minChannelProfileIconLevel)").string
case .emojiStatus: case .emojiStatus:
textString = isGroup ? strings.GroupBoost_EnableEmojiStatusLevelText("\(premiumConfiguration.minChannelEmojiStatusLevel)").string : strings.ChannelBoost_EnableEmojiStatusLevelText("\(premiumConfiguration.minChannelEmojiStatusLevel)").string textString = isGroup ? strings.GroupBoost_EnableEmojiStatusLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableEmojiStatusLevelText("\(requiredLevel)").string
case .wallpaper: case .wallpaper:
textString = isGroup ? strings.GroupBoost_EnableWallpaperLevelText("\(premiumConfiguration.minChannelWallpaperLevel)").string : strings.ChannelBoost_EnableWallpaperLevelText("\(premiumConfiguration.minChannelWallpaperLevel)").string textString = isGroup ? strings.GroupBoost_EnableWallpaperLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableWallpaperLevelText("\(requiredLevel)").string
case .customWallpaper: case .customWallpaper:
textString = isGroup ? strings.GroupBoost_EnableCustomWallpaperLevelText("\(premiumConfiguration.minChannelCustomWallpaperLevel)").string : strings.ChannelBoost_EnableCustomWallpaperLevelText("\(premiumConfiguration.minChannelCustomWallpaperLevel)").string textString = isGroup ? strings.GroupBoost_EnableCustomWallpaperLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableCustomWallpaperLevelText("\(requiredLevel)").string
case .audioTranscription: case .audioTranscription:
textString = "" textString = ""
case .emojiPack: case .emojiPack:
textString = strings.GroupBoost_EnableEmojiPackLevelText("\(premiumConfiguration.minGroupEmojiPackLevel)").string textString = strings.GroupBoost_EnableEmojiPackLevelText("\(requiredLevel)").string
} }
} else { } else {
let boostsString = strings.ChannelBoost_MoreBoostsNeeded_Boosts(Int32(remaining)) let boostsString = strings.ChannelBoost_MoreBoostsNeeded_Boosts(Int32(remaining))
@ -2296,7 +2297,7 @@ public class PremiumBoostLevelsScreen: ViewController {
sharedContext: context.sharedContext, sharedContext: context.sharedContext,
updatedPresentationData: nil, updatedPresentationData: nil,
title: presentationData.strings.ChannelBoost_Error_BoostTooOftenTitle, title: presentationData.strings.ChannelBoost_Error_BoostTooOftenTitle,
text: presentationData.strings.ChannelBoost_Error_BoostTooOftenText(valueText).string, text: self.containerExternalState.isGroup ? presentationData.strings.GroupBoost_Error_BoostTooOftenText(valueText).string : presentationData.strings.ChannelBoost_Error_BoostTooOftenText(valueText).string,
actions: [ actions: [
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {}) TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})
], ],
@ -2375,7 +2376,7 @@ public class PremiumBoostLevelsScreen: ViewController {
sharedContext: context.sharedContext, sharedContext: context.sharedContext,
updatedPresentationData: nil, updatedPresentationData: nil,
title: presentationData.strings.ChannelBoost_Error_PremiumNeededTitle, title: presentationData.strings.ChannelBoost_Error_PremiumNeededTitle,
text: presentationData.strings.ChannelBoost_Error_PremiumNeededText, text: self.containerExternalState.isGroup ? presentationData.strings.GroupBoost_Error_PremiumNeededText : presentationData.strings.ChannelBoost_Error_PremiumNeededText,
actions: [ actions: [
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}),
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Yes, action: { [weak controller] in TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Yes, action: { [weak controller] in

View File

@ -941,8 +941,12 @@ final class ChannelAppearanceScreenComponent: Component {
return availableSize return availableSize
} }
var requiredBoostSubjects: [BoostSubject] = [.nameColors(colors: resolvedState.nameColor)] let isGroup = self.isGroup
var requiredBoostSubjects: [BoostSubject] = []
if !isGroup {
requiredBoostSubjects.append(.nameColors(colors: resolvedState.nameColor))
}
let replyFileId = resolvedState.replyFileId let replyFileId = resolvedState.replyFileId
if replyFileId != nil { if replyFileId != nil {
requiredBoostSubjects.append(.nameIcon) requiredBoostSubjects.append(.nameIcon)
@ -1025,7 +1029,6 @@ final class ChannelAppearanceScreenComponent: Component {
} }
} }
var isGroup = false
if case let .user(user) = peer { if case let .user(user) = peer {
peer = .user(user peer = .user(user
.withUpdatedNameColor(resolvedState.nameColor) .withUpdatedNameColor(resolvedState.nameColor)
@ -1042,9 +1045,6 @@ final class ChannelAppearanceScreenComponent: Component {
.withUpdatedBackgroundEmojiId(replyFileId) .withUpdatedBackgroundEmojiId(replyFileId)
.withUpdatedProfileBackgroundEmojiId(backgroundFileId) .withUpdatedProfileBackgroundEmojiId(backgroundFileId)
) )
if case .group = channel.info {
isGroup = true
}
} }
let replyIconLevel = Int(BoostSubject.nameIcon.requiredLevel(group: isGroup, context: component.context, configuration: premiumConfiguration)) let replyIconLevel = Int(BoostSubject.nameIcon.requiredLevel(group: isGroup, context: component.context, configuration: premiumConfiguration))

View File

@ -9598,7 +9598,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
} }
if let boostsToUnrestrict = (strongSelf.peerView?.cachedData as? CachedChannelData)?.boostsToUnrestrict, boostsToUnrestrict > 0, bannedPermission == nil { if let boostsToUnrestrict = (strongSelf.peerView?.cachedData as? CachedChannelData)?.boostsToUnrestrict, boostsToUnrestrict > 0, let bannedPermission, !bannedPermission.1 {
strongSelf.interfaceInteraction?.openBoostToUnrestrict() strongSelf.interfaceInteraction?.openBoostToUnrestrict()
return return
} }